zayedalam
Published © MPL-2.0

How to type on LCD using Bluetooth

I made a very simple project just using Arduino Nano to connect LCD 16x2 screen with Bluetooth module to display letters using Andriod app.

BeginnerFull instructions provided355
How to type on LCD using Bluetooth

Things used in this project

Story

Read more

Schematics

Paste the code in any version of arduino app

Code

lcdbluetooth.ino

Arduino
#include <LiquidCrystal_I2C.h>  //For defining the lcd
#include <Wire.h>               //Same here too
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);//This is the  address of the LCD.If you have another address,change it.
char data = '5'; //Variable for storing received data  
int xpos=0;//Columm of the LCD
int ypos=0;//Row of the LCD

void setup() {
  // put your setup code here, to run once:
    Serial.begin(9600); //Sets the baud for serial data transmission 
    lcd.begin(16,2);//Setting up the lCD
    lcd.clear();//Clearing the waste                            

}

void loop() {
  // put your main code here, to run repeatedly:
  if(Serial.available() > 0)  // Perform only when you receive data:  
   {  
      data = Serial.read();         
if(data=='-'){//That means if we insert backspace key - in the android app
  xpos--; //Delete it - come back one character
if (xpos<0 && ypos==1) //if already reached to beginning of line2
 {
  ypos=0; //come to line 1
  xpos=15; //last column
 }
  
  Serial.print("Backspace received: xpos=");//Testing if the backspace key works
  Serial.println(xpos);
  lcd.setCursor(xpos,ypos);
  lcd.blink();//Knowing where are we inserting backspace key
  lcd.print(" ");
  lcd.setCursor(xpos,ypos);
 
  
  
}
else{ //else print the data
  lcd.setCursor(xpos,ypos); //set the chracter location
   lcd.print(data); //print character on LCD
   Serial.println(xpos); // for debug
   lcd.noBlink(); //remove any blinking if set due to backspace
xpos++; // increase the column position
}
if(xpos>15){//if the first line is full,
  xpos=0; //Goto first column of
  ypos++;//the next line.
}
if(xpos<0)
{xpos=0;
  
}

}

}//Have fun!!!!

Credits

zayedalam

zayedalam

0 projects • 0 followers

Comments