Go Down

Topic: Auduino lesson1: LCD and bluetooth exercise (Read 738 times) previous topic - next topic

Auduino lesson1:Use my cell phone(Android) Control the LCD display via bluetooth. Source code as below: the variable parameter 'serialreceive' is very impotant, if you directly use Serial.read(), it will be error.
#include <LiquidCrystal.h>

LiquidCrystal lcd(12,11,2,3,4,5,6,7,8,9,10);
void setup(){
  lcd.begin(16,2);
  Serial.begin(9600);
  lcd.clear();
  lcd.print("Hello,Cathy Lee!");
}
char serialreceive;

void loop(){
  if(Serial.available()){
    delay(100);
    while(Serial.available()>0){
      serialreceive=Serial.read();
      if (serialreceive=='R')
      {lcd.clear();
       lcd.print("oh,yeah!");
      Serial.print("Hello");}
     else
        if (serialreceive=='L'){
   //     lcd.clear();
        lcd.setCursor(3,2);
        lcd.print("wonderful!");
        Serial.print("Get it!");
      }
      else
        if (serialreceive=='c')
        lcd.clear();
     else {
      //serialreceive=Serial.read();
      //lcd.clear();
      lcd.write(serialreceive);
      Serial.write(serialreceive);}
    }
  }
 
}
Relux Wong

AWOL

Was there a question, or do you want me to move this to the "Exhibition and gallery" section?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

liudr


Was there a question, or do you want me to move this to the "Exhibition and gallery" section?


And add a couple of pictures and a video, you make a decent tutorial.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy