Arduino Doorbell
SUPPLIES
-2 bread boards
-buzzer
-jumper wires
-2 arduino/genuino with power cables
-rf transmitter and reciever
-push button
-100 ohm resistor
Function
This project is a working doorbell which the main function is using code to program the arduino in a way where the push button with the transmitter send a signal to the receiving end with the buzzer and receiver which will initiate the doorbell buzz sound with a wireless connection.
Step 1: Transmitter Board
How this project is supposed to work is having 2 bread boards and 2 arduiono/genuinos wired to them. for the transmitter board we connect the push button with the 100 ohm resistor connected to ground and a wire connected to power on the breadboard. Then connect the transmitter to the breadboard and wire the button to both the transmitter and arduino as shown in the picture.
Step 2: Receiver Board
On the receiver board is where the buzzer goes. Connect one wire to ground through the receiver and connect a wire to a pin of your choice which you can later customize in your code. Connect the receiver to the breadboard and wire it to the arduino as shown in the picture.
Step 3: Transmitter Code
// ask_transmitter.pde
// -*- mode: C++ -*-
// Simple example of how to use RadioHead to transmit messages
// with a simple ASK transmitter in a very simple way.
// Implements a simplex (one-way) transmitter with an TX-C1 module
#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile
RH_ASK driver;
// RH_ASK driver(2000, 2, 4, 5); // ESP8266 or ESP32: do not use pin 11
void setup()
{
Serial.begin(9600); // Debugging only
pinMode(5,INPUT);
if (!driver.init())
Serial.println("init failed");
}
void loop()
}
if(digitalRead(5)==HIGH){
const char *msg = "a";
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent();
delay(200);
}
}
Step 4: Receiver Code
#include <RH.ASK.h>
#include <SPI.h> // Not actualy used but needed to compile
#include "pitches.h" //add Equivalent frequency for musical note
#include "themes.h" //add Note vale and duration
RH_ASK driver;
void setup()
{
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");
else
Serial.println("done");
RH_ASK driver;
void setup()
{
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");
else
Serial.println("done");
}
void Play_Pirates()
{
for (int thisNote = 0; thisNote < (sizeof(Pirates_note)/sizeof(int)); thisNote++) {
int noteDuration = 1000 / Pirates_duration[thisNote];//convert duration to time delay
tone(8, Pirates_note[thisNote], noteDuration);
int pauseBetweenNotes = noteDuration * 1.05; //Here 1.05 is tempo, increase to play it slower
delay(pauseBetweenNotes);
noTone(8); //stop music on pin 8
}
}
void loop()
{
uint8_t buf[1];
uint8_t buflen = sizeof(buf);
if (driver.recv(buf, &buflen)) // Non-blocking
{
Serial.println("Selected -> 'He is a Pirate' ");
Play_Pirates();
Serial.println("stop");
}
}