Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Include RadioHead Amplitude Shift Keying Library
- #include <RH_ASK.h>
- // Include dependant SPI Library
- #include <SPI.h>
- // Create Amplitude Shift Keying Object
- RH_ASK rf_driver;
- int i;
- void setup()
- {
- // Initialize ASK Object
- rf_driver.init();
- // Setup Serial Monitor
- Serial.begin(9600);
- pinMode(13,OUTPUT);
- }
- void loop()
- {
- // Set buffer to size of expected message
- uint8_t buf[1];
- uint8_t buflen = sizeof(buf);
- // Check if received packet is correct size
- if (rf_driver.recv(buf, &buflen))
- {
- // Message received with valid checksum
- //Serial.print("Message Received: ");
- Serial.println((char*)buf);
- i= atoi((char*)buf);
- if (i==1){digitalWrite(13,HIGH);}
- else if (i==0){digitalWrite(13,LOW);}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement