Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <RH_ASK.h>
  2. #include <SPI.h> // Not actually used but needed to compile
  3. const int buttonPin = 2; // the number of the pushbutton pin
  4. const int ledPin = 13;
  5. RH_ASK driver;
  6. int buttonState = 0;
  7.  
  8. void setup()
  9. {
  10. // initialize the LED pin as an output:
  11. pinMode(ledPin, OUTPUT);
  12. // initialize the pushbutton pin as an input:
  13. pinMode(buttonPin, INPUT);
  14.  
  15. Serial.begin(9600); // Debugging only
  16. if (!driver.init())
  17. Serial.println("init failed");
  18. }
  19.  
  20. void loop()
  21. {
  22. buttonState = digitalRead(buttonPin);
  23.  
  24. if (buttonState == HIGH) {
  25. // turn LED on:
  26. digitalWrite(ledPin, HIGH);
  27.  
  28. } else {
  29. // turn LED off:
  30. digitalWrite(ledPin, LOW);
  31. const char *msg = "11";
  32. driver.send((uint8_t *)msg, strlen(msg));
  33. driver.waitPacketSent();
  34. }
  35.  
  36. delay(100);
  37. }r
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement