pneumatik/IR_pneumatics.ino

57 lines
973 B
Arduino
Raw Permalink Normal View History

2024-03-24 14:07:51 +01:00
#include <IRremote.h>
#include <Servo.h>
// 1 = 69;
// 2 = 70;
// 3 = 71;
// 4 = 68;
// 5 = 64;
// 6 = 67;
// 7 = 7;
// 8 = 21;
// 9 = 9;
// 0 = 25;
// Asterisk = 22;
// Rhombus = 13;
// OK = 28;
// Up = 24;
// Down = 82;
// Left = 8;
// Right = 90;
2024-03-24 14:40:16 +01:00
const int IR_pin = 11;
2024-03-24 14:07:51 +01:00
int IrWert = 0;
2024-03-24 14:40:16 +01:00
const int Z1_pin = 9;
Servo pneu_servoZ1;
2024-03-24 14:07:51 +01:00
void setup() {
2024-03-24 14:40:16 +01:00
IrReceiver.begin(IR_pin);
pneu_servoZ1.attach(Z1_pin);
2024-03-24 14:35:44 +01:00
pneu_servoZ1.write(50);
Serial.begin(9600);
2024-03-24 14:35:44 +01:00
Serial.println("verbunden");
2024-03-24 14:07:51 +01:00
}
void loop() {
if (IrReceiver.decode()) {
IrReceiver.resume();
IrWert = IrReceiver.decodedIRData.command;
if (IrWert == 24) {
2024-03-24 14:35:44 +01:00
pneu_servoZ1.write(35);
2024-03-24 14:07:51 +01:00
delay(500);
2024-03-24 14:35:44 +01:00
Serial.println("Z1 aus");
2024-03-24 14:07:51 +01:00
}
if (IrWert == 28) {
2024-03-24 14:35:44 +01:00
pneu_servoZ1.write(50);
2024-03-24 14:07:51 +01:00
delay(500);
2024-03-24 14:35:44 +01:00
Serial.println("Z1 gesperrt");
2024-03-24 14:07:51 +01:00
}
if (IrWert == 82) {
pneu_servoZ1.write(60);
2024-03-24 14:07:51 +01:00
delay(500);
2024-03-24 14:35:44 +01:00
Serial.println("Z1 ein");
2024-03-24 14:07:51 +01:00
}
}
}