Go Down

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

reluxwong

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