Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <RH_ASK.h>
- #include <SPI.h> // Not actually used but needed to compile
- const int buttonPin = 2; // the number of the pushbutton pin
- const int ledPin = 13;
- RH_ASK driver;
- int buttonState = 0;
- void setup()
- {
- // initialize the LED pin as an output:
- pinMode(ledPin, OUTPUT);
- // initialize the pushbutton pin as an input:
- pinMode(buttonPin, INPUT);
- Serial.begin(9600); // Debugging only
- if (!driver.init())
- Serial.println("init failed");
- }
- void loop()
- {
- buttonState = digitalRead(buttonPin);
- if (buttonState == HIGH) {
- // turn LED on:
- digitalWrite(ledPin, HIGH);
- } else {
- // turn LED off:
- digitalWrite(ledPin, LOW);
- const char *msg = "11";
- driver.send((uint8_t *)msg, strlen(msg));
- driver.waitPacketSent();
- }
- delay(100);
- }r
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement