Hi! I’m brand new to arduino & I’m attempting to make a wireless doorbell for a school project (two arduino: one with a button for transmitting the signal, & the other with a receiver & a light to indicate the signal was received) I’m hoping to make it so the button is only lit when the button is being actively pressed. I’m not sure if the issue I’m having is due to my code or wiring so I’ll attach both. Thanks!!
Please read and use this topic, especially the parts about posting code: How to get the best out of this forum - Using Arduino / IDE 1.x - Arduino Forum
Your way forward would be a lot more comfortable executing some more simple tasks to learn.
Communication is difficult. Period.
Please come back posting code as forum expect. Screen shots is not the way.
Hi! Sorry I seemed to have attached the wrong images somehow, those were supposed to be of the arduino themselves. Here is the code!
Receiver code:
#include <RH_ASK.h>
#include <SPI.h>
RH_ASK driver;
const int ledPin = LED_BUILTIN;
const int switch_in = 3;
char *msg;
void setup() {
driver.init();
pinMode(ledPin, OUTPUT);
pinMode(switch_in, INPUT);
digitalWrite(ledPin, LOW);
} void loop()
{ uint8_t buf[RH_ASK_MAX_MESSAGE_LEN]; uint8_t buflen = sizeof(buf);
if (driver.recv(buf, &buflen)) { msg = (char*)buf;
if (strcmp(msg, "Switch_ON") == 0) {
digitalWrite(ledPin, HIGH);
} else if (strcmp(msg, "Switch_OFF") == 0) { digitalWrite(ledPin, LOW);
} } }
Transmitter code:
#include <RH_ASK.h>
#include <SPI.h>
RH_ASK driver;
const int switch_in = 3;
int state = 0;
char *msg;
void setup() {
driver.init();
pinMode(switch_in, INPUT); }
void loop() {
if (digitalRead(switch_in) == HIGH && state == 1) { msg = "Switch_ON";
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent(); delay(200); state = 0; }
else if (digitalRead(switch_in) == LOW)
{ msg = "Switch_OFF";
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent(); delay(200); state = 1; } }
Hi! I’m brand new to arduino & I’m attempting to make a wireless doorbell for a school project (two arduino: one with a button for transmitting the signal, & the other with a receiver & a light to indicate the signal was received) I’m hoping to make it so the button is only lit when the button is being actively pressed. I’m not sure if the issue I’m having is due to my code or wiring so I’ll attach both. Thanks!!
Thanks for posting the photo and code. Would perhaps help to know what the issue is?
Hint: you can copy and paste the code into the post and wrap it in CODE tags. That way it is much easier to read.
Receiver code:
#include <RH_ASK.h>
#include <SPI.h>
RH_ASK driver;
const int ledPin = LED_BUILTIN;
const int switch_in = 3;
char *msg;
void setup() {
driver.init();
pinMode(ledPin, OUTPUT);
pinMode(switch_in, INPUT);
digitalWrite(ledPin, LOW);
} void loop()
{ uint8_t buf[RH_ASK_MAX_MESSAGE_LEN]; uint8_t buflen = sizeof(buf);
if (driver.recv(buf, &buflen)) { msg = (char*)buf;
if (strcmp(msg, "Switch_ON") == 0) {
digitalWrite(ledPin, HIGH);
} else if (strcmp(msg, "Switch_OFF") == 0) { digitalWrite(ledPin, LOW);
} } }
Transmitter code:
#include <RH_ASK.h>
#include <SPI.h>
RH_ASK driver;
const int switch_in = 3;
int state = 0;
char *msg;
void setup() {
driver.init();
pinMode(switch_in, INPUT); }
void loop() {
if (digitalRead(switch_in) == HIGH && state == 1) { msg = "Switch_ON";
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent(); delay(200); state = 0; }
else if (digitalRead(switch_in) == LOW)
{ msg = "Switch_OFF";
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent(); delay(200); state = 1; } }
As for the problem…I’m really not sure what the issue is. The LED is always on, regardless of if the button is being pressed or not. I have no clue if the transmitter is even transmitting a signal & if the receiver is receiving a signal due to the light always being on.
Thank you so much for the tip on attaching the code as well!
Mess tidied.
Using pen and paper, making a schedule could be helpful. No code on earth can compensate for wiring mistakes....
These are the two diagrams that I followed. Since I am only using a small LED i removed the relay & just connected those three wires directly to the LED.
How is the UNO supplied? Using the UNO 5 volt pin might be troubling.
They are both supplied using the USB attachment.
That might not be good enough for the wireless transmitter. A separate, more powerful source might be needed. USB is specified to 0.5 Amps but the transmitter likely needs more.
How would I be able to increase the current? I only have the arduino starter kit.
Add a power supply having the capacity needed. There is no way to crank up the power as far as I can see.
Hello julianab
Use a BT-Module connected to an Arduiono and use your mobile telephone to trigger the doorbell or whatever you like.






