I am currently trying to make an RC Car, but first I have started simple by just trying to make a LED light up via a 433 MHz Transceiver and Transmitter. I am using the RadioHead library and I have been able to send character messages because of a tutorial I found, but I have been unable to convert that into a command that could turn an LED on. I have very limited coding skills and I can't find any tutorials for this.
Let's say that you send the character 'n' to mean LED on (illuminated) and 'f' for LED off (dark). Your LED is wired from pin 4 to a resistor, then to the LED and the other leg of the LED goes to ground so it takes a HIGH to illuminate the LED.
That's a very good first step. Please continue to take small steps and build progress. I do not count high enough the number of ppl who present a "complete" project that is no where near to working, and have no ]dea if any pieces would have functioned in simple sketches like you are trying.
Post the code that you've succeeded with. It is a trivial matter to repurpose arrived messages, or characters or whatever in order to accomplish something new or different.
You could use the IDE Autoformat tool first, then copy each sketch and use the <CODE/> tool in the message composition window here and
type or paste code here
Paste your code where it says. One for each sketch, sender and receiver.
The first step, with any library, is to run a couple of the library examples, and verify that they work with your setup. Then, study them to learn how they work.
Here is my code for the transmitter (right now, it can only send a text)
#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile
RH_ASK driver;
void setup()
{
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");
}
void loop()
{
const char * msg = "Hello World!";
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent();
delay(1000);
}
Here is my transceiver:
#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile
RH_ASK driver;
void setup()
{
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");
}
void loop()
{
uint8_t buf[12];
uint8_t buflen = sizeof(buf);
if (driver.recv(buf, &buflen)) // Non-blocking
{
// Message with a good checksum received, dump it.
Serial.print("Message: ");
Serial.println((char*)buf);
}
}