Pages: [1]   Go Down
Author Topic: Auduino lesson1: LCD and bluetooth exercise  (Read 622 times)
0 Members and 1 Guest are viewing this topic.
China-Shenzhen
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);}
    }
  }
 
}
Logged

Relux Wong

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26293
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

"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.

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 73
Posts: 7197
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Pages: [1]   Go Up
Jump to: