Hardware components | ||||||
![]() |
| × | 2 | |||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
| × | 2 | ||||
![]() |
| × | 2 | |||
![]() |
| × | 2 | |||
![]() |
| × | 2 | |||
Software apps and online services | ||||||
![]() |
| |||||
![]() |
| |||||
I made this project as a helpful communication hub for road trips. I originally tried to do this with an Arduino Wifi Rev2 and a Node MCU V3, using their WiFi capabilities. I soon realized that this would not work and bought some nRF24L01 transceivers from Amazon. I subsequently spent several hours trying to get the Node to receive data. I eventually switched to an Arduino Uno and a Leonardo. This worked much better. Two Arduino Unos would also work.
How it worksThis project uses two nRF24L01 transmitters to send data back and forth. It uses a joystick to scroll through the messages, then when the joystick button is pressed, it sends the number of the message it is on. Note: This code will only work as intended if the message lists are the exact same (I copy and pasted them.) When the Arduino receives the number, it prints: "New Message:" and then the message. The way it does this is by printing the message list of the message number
Optional: Add a buzzerIf you want to add a buzzer to buzz when there is a new message, attach the + side to pin 7 on each Arduino. I also added some more messages to each Arduino. The code is attached at the bottom
Libraries Needed:LiquidCrystal_I2C
Used to control the I2C LCD.
Available from the Arduino Library Manager
SPI
Built into Arduino IDE.
nRF24L01 and RF24
Available from Arduino Library Manager as NRFLite and RF24
#include <LiquidCrystal_I2C.h> // I2C LCD library
LiquidCrystal_I2C lcd(0x27, 16, 2); // define the LCD
#include <SPI.h> // SPI library for the transceiver
#include <nRF24L01.h> // include both of the libraries needed for the transceiver
#include <RF24.h>
const String messages[26] = { // messages
"Hello",
"How are you?",
"Good",
"Tired",
"Hungry",
"Bathroom break?",
"Yes",
"No",
"Food Break?",
"Where are you?",
"Behind you",
"In front of you",
"Beside you",
"Ha!",
"BRB",
"Disconnecting...",
"No!",
"Turn left",
"Turn right",
"Too fast",
"Too slow",
"Food soon?",
"Break soon?",
"Ok"
};
int messageNumber = 0; // which message the LCD is showing
const int VRX = 0; // joystick pin (analog)
const int VRY = 1; // joystick pin (analog)
const int SW = 8; // joystick button pin (digital)
#define CE_PIN 9 // CE of radio
#define CSN_PIN 10 // CSN of radio
const byte sendAddress[5] = {'R','x','A','A','A'}; // address to send data
const byte receiveAddress[5] = {'T','x','A','A','A'}; // address to receive data
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
int dataReceived;
int dataToSend;
void setup() {
pinMode(SW, INPUT); // set the button pin as input
digitalWrite(SW, HIGH);
Serial.begin(9600); // begin Serial monitor (debugging)
Serial.println("Starting lcd");
lcd.backlight(); // turn on LCD backlight
lcd.init(); // start the LCD
lcd.clear(); // clear the LCD
Serial.println("Starting Radio");
radio.begin(); // start radio
radio.setDataRate( RF24_250KBPS ); // set data rate
radio.setRetries(3,5); // delay, count
radio.openWritingPipe(sendAddress); // open a pipe for data sending
radio.openReadingPipe(1, receiveAddress); // open a pipe for receiving data
Serial.println();
radio.startListening(); // start listening for data
}
//====================
void loop() {
if (radio.available()){ // if there is data available:
radio.read(&dataReceived, sizeof(dataReceived)); // get the data
lcd.clear(); // clear the LCD
lcd.setCursor(0, 0);
lcd.print("New message:"); // print "New Message:" at 0, 0 (top left)
lcd.setCursor(0, 1);
lcd.print(messages[dataReceived]); // print the received message at 0, 1 (bottom left)
delay(5000); // wait five seconds
}
changeMessage(); // change the message
if (digitalRead(SW) == LOW){ // if the joystick button is pressed, send the message
sendData();
}
delay(100); // do this ten times a second
}
//====================
void changeMessage(){
int x = analogRead(VRY); // read the VRY pin (joystick pins forward)
x = map(x, 0, 1023, -9, 10); // 10: left
int y = analogRead(VRX); // the VRX pin reads the movement of the joystick to/from the pins on the front. If the joystick is held sideways, reverse these two values
y = map(y, 0, 1023, -9, 10); // -9: forwards You may need to change the -9 to a -10. My joystick was slightly off, so I had to correct it
if (y < -1){ // change the message
messageNumber -= 1;
delay(500);
}
if (y > 1){ // change the message
messageNumber += 1;
delay(500);
}
if (messageNumber < 0){ // if the message number is less than the number of messages, reset it
messageNumber = 26;
}
if (messageNumber > 26){ // if the message number is more than the number of messages, reset it
messageNumber = 0;
}
lcd.clear(); // clear LCD
lcd.setCursor(0, 0);
lcd.print(">"); // print the ">" to the LCD
lcd.setCursor(1, 0);
lcd.print(messages[messageNumber]); // print the current message
lcd.setCursor(1, 1);
if ((messageNumber + 1) < 26){ // print the message after the current message
lcd.print(messages[messageNumber + 1]);
}
if ((messageNumber + 1) == 26){
lcd.print(messages[0]);
}
}
void sendData(){ // send the number of the current message (ONLY WORKS IF BOTH MESSAGE LISTS ARE THE SAME!!!)
dataToSend = messageNumber;
radio.stopListening();
radio.write(&dataToSend, sizeof(dataToSend));
delay(5);
radio.startListening();
}
#include <LiquidCrystal_I2C.h> // I2C LCD library
LiquidCrystal_I2C lcd(0x27, 16, 2); // define the LCD
#include <SPI.h> // SPI library for the transceiver
#include <nRF24L01.h> // include both of the libraries needed for the transceiver
#include <RF24.h>
const String messages[26] = { // messages
"Hello",
"How are you?",
"Good",
"Tired",
"Hungry",
"Bathroom break?",
"Yes",
"No",
"Food Break?",
"Where are you?",
"Behind you",
"In front of you",
"Beside you",
"Ha!",
"BRB",
"Disconnecting...",
"No!",
"Turn left",
"Turn right",
"Too fast",
"Too slow",
"Food soon?",
"Break soon?",
"Ok"
};
int messageNumber = 0; // which message the LCD is showing
const int VRX = 0; // joystick pin (analog)
const int VRY = 1; // joystick pin (analog)
const int SW = 8; // joystick button pin (digital)
#define CE_PIN 9 // CE of radio
#define CSN_PIN 10 // CSN of radio
const byte sendAddress[5] = {'T','x','A','A','A'}; // address to send data
const byte receiveAddress[5] = {'R','x','A','A','A'}; // address to receive data
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
int dataReceived;
int dataToSend;
void setup() {
pinMode(SW, INPUT); // set the button pin as input
digitalWrite(SW, HIGH);
Serial.begin(9600); // begin Serial monitor (debugging)
Serial.println("Starting lcd");
lcd.backlight(); // turn on LCD backlight
lcd.init(); // start the LCD
lcd.clear(); // clear the LCD
Serial.println("Starting Radio");
radio.begin(); // start radio
radio.setDataRate( RF24_250KBPS ); // set data rate
radio.setRetries(3,5); // delay, count
radio.openWritingPipe(sendAddress); // open a pipe for data sending
radio.openReadingPipe(1, receiveAddress); // open a pipe for receiving data
Serial.println();
radio.startListening(); // start listening for data
}
//====================
void loop() {
while (!radio.available()){
;
}
if (radio.available()){ // if there is data available:
radio.read(&dataReceived, sizeof(dataReceived)); // get the data
lcd.clear(); // clear the LCD
lcd.setCursor(0, 0);
lcd.print("New message:"); // print "New Message:" at 0, 0 (top left)
lcd.setCursor(0, 1);
lcd.print(messages[dataReceived]); // print the received message at 0, 1 (bottom left)
delay(5000); // wait five seconds
}
changeMessage(); // change the message
if (digitalRead(SW) == LOW){ // if the joystick button is pressed, send the message
sendData();
}
delay(100); // do this ten times a second
}
//====================
void changeMessage(){
int x = analogRead(VRY); // read the VRY pin (joystick pins forward)
x = map(x, 0, 1023, -9, 10); // 10: left
int y = analogRead(VRX); // the VRX pin reads the movement of the joystick to/from the pins on the front. If the joystick is held sideways, reverse these two values
y = map(y, 0, 1023, -9, 10); // -9: forwards You may need to change the -9 to a -10. My joystick was slightly off, so I had to correct it
if (y < -1){ // change the message
messageNumber -= 1;
delay(500);
}
if (y > 1){ // change the message
messageNumber += 1;
delay(500);
}
if (messageNumber < 0){ // if the message number is less than the number of messages, reset it
messageNumber = 26;
}
if (messageNumber > 26){ // if the message number is more than the number of messages, reset it
messageNumber = 0;
}
lcd.clear(); // clear LCD
lcd.setCursor(0, 0);
lcd.print(">"); // print the ">" to the LCD
lcd.setCursor(1, 0);
lcd.print(messages[messageNumber]); // print the current message
lcd.setCursor(1, 1);
if ((messageNumber + 1) < 26){ // print the message after the current message
lcd.print(messages[messageNumber + 1]);
}
if ((messageNumber + 1) == 26){
lcd.print(messages[0]);
}
}
void sendData(){ // send the number of the current message (ONLY WORKS IF BOTH MESSAGE LISTS ARE THE SAME!!!)
dataToSend = messageNumber;
radio.stopListening();
radio.write(&dataToSend, sizeof(dataToSend));
delay(5);
radio.startListening();
}
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const String messages[26] = {
"Hello",
"How are you?",
"Good",
"Tired",
"Hungry",
"Bathroom break?",
"Yes",
"No",
"Food Break?",
"Where are you?",
"Behind you",
"In front of you",
"Beside you",
"Ha!",
"BRB",
"Disconnecting...",
"No!",
"Turn left",
"Turn right",
"Too fast",
"Too slow",
"Food soon?",
"Break soon?",
"Ok"
};
int messageNumber = 0;
const int VRX = 0;
const int VRY = 1;
const int SW = 8;
#define CE_PIN 9
#define CSN_PIN 10
const int buzzerPin = 7;
const byte sendAddress[5] = {'R','x','A','A','A'};
const byte receiveAddress[5] = {'T','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
int dataReceived;
int dataToSend;
void setup() {
pinMode(buzzerPin, OUTPUT);
pinMode(SW, INPUT);
digitalWrite(SW, HIGH);
Serial.begin(9600);
Serial.println("Starting lcd");
lcd.backlight();
lcd.init();
lcd.clear();
Serial.println("Starting Radio");
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.setRetries(3,5); // delay, count
radio.openWritingPipe(sendAddress);
radio.openReadingPipe(1, receiveAddress);
Serial.println();
radio.startListening();
}
//====================
void loop() {
if (radio.available()){
radio.read(&dataReceived, sizeof(dataReceived));
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("New message:");
lcd.setCursor(0, 1);
lcd.print(messages[dataReceived]);
for(int i = 0; i < 15; i++){ // buzz the buzzer 10 times a second for 3 seconds
digitalWrite(buzzerPin, HIGH);
delay(100);
digitalWrite(buzzerPin, LOW);
delay(100);
}
delay(2000)
}
changeMessage();
if (digitalRead(SW) == LOW){
sendData();
}
delay(100);
}
//====================
void changeMessage(){
int x = analogRead(VRY);
x = map(x, 0, 1023, -9, 10); // 10: left
int y = analogRead(VRX);
y = map(y, 0, 1023, -9, 10); // -9: forwards
if (y < -1){
messageNumber -= 1;
delay(500);
}
if (y > 1){
messageNumber += 1;
delay(500);
}
if (messageNumber < 0){
messageNumber = 26;
}
if (messageNumber > 26){
messageNumber = 0;
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(">");
lcd.setCursor(1, 0);
lcd.print(messages[messageNumber]);
lcd.setCursor(1, 1);
if ((messageNumber + 1) < 26){
lcd.print(messages[messageNumber + 1]);
}
if ((messageNumber + 1) == 26){
lcd.print(messages[0]);
}
}
void sendData(){
dataToSend = messageNumber;
radio.stopListening();
radio.write(&dataToSend, sizeof(dataToSend));
delay(5);
radio.startListening();
}
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const String messages[26] = {
"Hello",
"How are you?",
"Good",
"Tired",
"Hungry",
"Bathroom break?",
"Yes",
"No",
"Food Break?",
"Where are you?",
"Behind you",
"In front of you",
"Beside you",
"Ha!",
"BRB",
"Disconnecting...",
"No!",
"Turn left",
"Turn right",
"Too fast",
"Too slow",
"Food soon?",
"Break soon?",
"Ok"
};
int messageNumber = 0;
const int VRX = 0;
const int VRY = 1;
const int SW = 8;
#define CE_PIN 9
#define CSN_PIN 10
const int buzzerPin = 7;
const byte sendAddress[5] = {'T','x','A','A','A'};
const byte receiveAddress[5] = {'R','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
int dataReceived;
int dataToSend;
void setup() {
pinMode(buzzerPin, OUTPUT);
pinMode(SW, INPUT);
digitalWrite(SW, HIGH);
Serial.begin(9600);
Serial.println("Starting lcd");
lcd.backlight();
lcd.init();
lcd.clear();
Serial.println("Starting Radio");
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.setRetries(3,5); // delay, count
radio.openWritingPipe(sendAddress);
radio.openReadingPipe(1, receiveAddress);
Serial.println();
radio.startListening();
}
//====================
void loop() {
while(!radio.available()){
;
}
if (radio.available()){
radio.read(&dataReceived, sizeof(dataReceived));
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("New message:");
lcd.setCursor(0, 1);
lcd.print(messages[dataReceived]);
for(int i = 0; i < 15; i++){ // buzz the buzzer 10 times a second for 3 seconds
digitalWrite(buzzerPin, HIGH);
delay(100);
digitalWrite(buzzerPin, LOW);
delay(100);
}
delay(2000)
}
changeMessage();
if (digitalRead(SW) == LOW){
sendData();
}
delay(100);
}
//====================
void changeMessage(){
int x = analogRead(VRY);
x = map(x, 0, 1023, -9, 10); // 10: left
int y = analogRead(VRX);
y = map(y, 0, 1023, -9, 10); // -9: forwards
if (y < -1){
messageNumber -= 1;
delay(500);
}
if (y > 1){
messageNumber += 1;
delay(500);
}
if (messageNumber < 0){
messageNumber = 26;
}
if (messageNumber > 26){
messageNumber = 0;
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(">");
lcd.setCursor(1, 0);
lcd.print(messages[messageNumber]);
lcd.setCursor(1, 1);
if ((messageNumber + 1) < 26){
lcd.print(messages[messageNumber + 1]);
}
if ((messageNumber + 1) == 26){
lcd.print(messages[0]);
}
}
void sendData(){
dataToSend = messageNumber;
radio.stopListening();
radio.write(&dataToSend, sizeof(dataToSend));
delay(5);
radio.startListening();
}



_ztBMuBhMHo.jpg?auto=compress%2Cformat&w=48&h=48&fit=fill&bg=ffffff)











_3u05Tpwasz.png?auto=compress%2Cformat&w=40&h=40&fit=fillmax&bg=fff&dpr=2)


Comments