-
-
Save JeffersGlass/31c9d3356bc00a115386162ad49c52d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <RH_ASK.h> | |
#ifdef RH_HAVE_HARDWARE_SPI | |
#include <SPI.h> // Not actually used but needed to compile | |
#endif | |
//RH_ASK driver; //Defaults to receive on pin D11 and transmit on pin 5 | |
RH_ASK driver(2000, 4, 5, 0); //Bitrate, rx pin, tx pin, transmit controller pin | |
int potPinServo = A0; | |
int potPinLed = A1; | |
void setup() | |
{ | |
#ifdef RH_HAVE_SERIAL | |
Serial.begin(9600); // Debugging only | |
#endif | |
if (!driver.init()) | |
#ifdef RH_HAVE_SERIAL | |
Serial.println("init failed"); | |
#else | |
; | |
#endif | |
pinMode(potPinServo, INPUT); | |
pinMode(potPinLed, INPUT); | |
} | |
void loop() | |
{ | |
byte servoReading = map(analogRead(potPinServo), 0, 1024, 0, 255); | |
byte ledReading = map(analogRead(potPinLed), 0, 1024, 0, 255); | |
byte readings[] = {servoReading, ledReading}; | |
const uint8_t * msg = readings; | |
driver.send(msg, sizeof(msg)); | |
driver.waitPacketSent(); | |
delay(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment