Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Data transmitter sketch
// data transmitter sketch
//
// https://pmdway.com/blogs/product-guides-for-arduino/tutorial-using-long-range-315mhz-rf-wireless-transceivers-with-arduino
//
//
#include <VirtualWire.h>
// use onboard LED for status
const int ledPin = 13;
// we'll send the value of analog pin 1
const int Sensor1Pin = A1;
int Sensor1Data;
char Sensor1CharMsg[4];
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(A1, INPUT);
vw_setup(2000); // data speed in bps
vw_set_tx_pin(12); //digital pin to data transmitter
}
void loop()
{
// get data from analog pin 1
Sensor1Data = analogRead(Sensor1Pin);
// convert data from integer to character array
itoa(Sensor1Data, Sensor1CharMsg, 10);
digitalWrite(13, true); // onboard LED on to indicate transmitting
vw_send((uint8_t *)Sensor1CharMsg, strlen(Sensor1CharMsg)); // send array
vw_wait_tx(); // wait until data is sent
digitalWrite(13, false); // onboard LED off to indicate finished transmitting
delay(1000); // wait
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.