Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <RCSwitch.h>
- RCSwitch mySwitch = RCSwitch();
- String inString = "";
- void setup() {
- Serial.begin(9600);
- mySwitch.enableReceive(0);
- mySwitch.enableTransmit(6);
- pinMode(LED_BUILTIN, OUTPUT);
- Serial.println("Doomsday Machine ONLINE!...");
- }
- void loop() {
- if (mySwitch.available()) {
- int value = mySwitch.getReceivedValue();
- if (value == 0) {
- Serial.println("Unknown encoding");
- } else {
- Serial.println( mySwitch.getReceivedValue() );
- digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
- blinker();
- }
- mySwitch.resetAvailable();
- }
- // Read serial input:
- while (Serial.available() > 0) {
- int inChar = Serial.read();
- if (isDigit(inChar)) {
- inString += (char)inChar;
- }
- if (inChar == '#') {
- long code = inString.toInt();
- mySwitch.send(code, 24);
- blinker();
- Serial.println(code);
- inString = "";
- }
- }
- delay(10);
- }
- void blinker() {
- digitalWrite(LED_BUILTIN, HIGH);
- delay(30);
- digitalWrite(LED_BUILTIN, LOW);
- delay(30);
- digitalWrite(LED_BUILTIN, HIGH);
- delay(30);
- digitalWrite(LED_BUILTIN, LOW);
- delay(30);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement