Introduction: LCD & Bluetooth - Arduino
In this Instructable, you will learn how to write a text on your smartphone and print it on an LCD via Bluetooth, using an Arduino.
Step 1: Hardware Needed
For this project, you will need:
-an Arduino UNO
-an LCD (Liquid Crystal Display)
-a breadboard
-a 10K potentiometer
-a BT module (I use an HC-05)
-jumper wires
-a Bluetooth app. For Android users, I recommend BlueTerm. Sorry iOS users, BlueTerm is only available for Android... But you can still download equivalent apps.
No tools required
Step 2: Build the Circuit
The image above corresponds to the following guidelines:
First, pin your LCD on the breadboard and power the breadboard by connecting a wire from "5V" (power) on your Arduino to the positive row on the breadboard and another one from "GND" (ground or 0V) to the negative row.
Then connect the LCD to the Arduino:
LCD pin 4 - Arduino pin 2
Pin 6 - pin 3
Pin 11 - pin 4
Pin 12 - pin 5
Pin 13 - pin 6
Pin 14 - pin 7
After that, power the LCD:
LCD pin 1 = GND on the breadboard
Pin 2 = 5V
Pin 5 = GND
Pin 15 = 5V
Pin 16 = GND
Then connect pin 3 on your LCD to the central pin of the 10K potentiometer and power the potentiometer with one pin on GND and the other one on 5V (on the breadboard).
Then connect the Tx(Transmit) pin on your Bluetooth module to the Rx (Receive) on the Arduino, and connect the Rx pin on your BT module to the Tx on the Arduino.
Finally, power the BT module by connecting the VCC (or 5V) to the positive row on the breadboard an connect the GND to the negative one on the breadboard.
Step 3: Code
Now let's write the code:
#include <LiquidCrystal.h> //Include the library that enables you to use the LCD LiquidCrystal lcd(2,3,4,5,6,7);//Declare that your LCD is connected to pins 2,3,4,5,6 & 7 on your Arduino void setup() { lcd.begin(16,2);//16 by 2 are the dimensions of the LCD (in number of characters) Serial.begin(9600);//launch the process of receiving serial data (via bluetooth) at 9600 bits/s } void loop() { if(Serial.available()){ lcd.write(Serial.read());//these two lines mean that if there is data coming from the BT module, the Arduino prints it on the LCD. } } //Before uploading the code to the Arduino, disconnect the Tx and Rx pins, otherwise you won't be able to upload. Once the code uploaded, reconnect them.
Now open BlueTerm, put BlueTooth on and connect HC-05. Then simply write your text and it should be printed on the LCD!
20 Comments
5 years ago
how plz send code
7 years ago
Hi
I added a delay and a lcd.clear in Ur code .But now when I type something it displays and clears the word letter by letter. What can be wrong?
Reply 7 years ago
did you add these functions to delete the word every 4 seconds?
Reply 7 years ago
Yes
Reply 7 years ago
and your problem is that when you type a letter, it clears it after 4 seconds, right?
Reply 7 years ago
Yeah right
Reply 7 years ago
I'm not at my home so I can't try it on my arduino now
but I think the problem is that it deletes the letter you type every 4 seconds, instead of clearing the LCD every 4 seconds,
so what you can try is to create an integer (the text) and say to the Arduino to print it when you press a button (like a text message or an email), and then to clear the LCD every 4 seconds
Gonna send you the code soon ;)
Reply 7 years ago
Ok I'll try that
Reply 7 years ago
hey Prd99! did it finally work?
because while working on another project (BT robot arm), i found out how to make your project work. would you like the code?
Reply 7 years ago
I haven't tried it in many days
Yeah I would like the code?
Reply 7 years ago
I would like the code
Reply 7 years ago
//There you go! It works!
#include <LiquidCrystal.h>
LiquidCrystal lcd(2,3,4,5,6,7);
char buffer[20];
int charsRead;
int val;
void setup(){
Serial.begin(9600);
lcd.begin(16, 2);
}
void loop(){
while(Serial.available() > 0){
charsRead = Serial.readBytesUntil('\n', buffer, sizeof(buffer) - 1);
buffer[charsRead] = '\0';
lcd.print(buffer);
delay(4000);
lcd.clear();
}
}
Reply 7 years ago
Sorry,
you should create a string
7 years ago
//There you go ! It works !
#include <LiquidCrystal.h>
LiquidCrystal lcd(2,3,4,5,6,7);
char buffer[20];
int charsRead;
int val;
void setup(){
Serial.begin(9600);
lcd.begin(16, 2);
}
void loop(){
while(Serial.available() > 0){
charsRead = Serial.readBytesUntil('\n', buffer, sizeof(buffer) - 1);
buffer[charsRead] = '\0';
lcd.print(buffer);
delay(4000);
lcd.clear();
}
}
7 years ago
**
7 years ago
**
7 years ago
Sorry for the image
Here is the code
#include
LiquidCrystal lcd(2,3,4,5,6,7);
void setup() {
lcd.begin(16,2);
Serial.begin(9600);
}
void loop() {
if(Serial.available()){
lcd.write(Serial.read());
delay(4000);
lcd.clear();
}
}
7 years ago
what lcd screen are you using?
Reply 7 years ago
did you get it off amazon?
Reply 7 years ago
I use a 16x2 characters LCD, included in the Arduino starter kit