CPP 72
HC05 LCD Guest on 3rd February 2024 08:57:19 AM
  1. //Mohamadi & Abasi
  2. #include <SoftwareSerial.h>
  3. #include <LiquidCrystal.h>
  4.  
  5. // initialize the library by associating any needed LCD interface pin
  6. // with the arduino pin number it is connected to
  7. const int rs = 8, en = 9, d4 = 10, d5 = 11, d6 = 12, d7 = 13;
  8. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
  9.  
  10. SoftwareSerial bt(2,3); /* (Rx,Tx) */  
  11.  
  12. void setup() {
  13.   bt.begin(9600);  /* Define baud rate for software serial communication */
  14.   Serial.begin(9600);  /* Define baud rate for serial communication */
  15.   lcd.begin(16, 2);
  16. }
  17. char counter = 0;
  18. void loop() {
  19.     if (bt.available())  /* If data is available on serial port */
  20.     {
  21.       char a = bt.read();
  22.       Serial.println("my name is optimus prime");
  23.       lcd.print(a);
  24.       counter++;
  25.       if(a == '#'){
  26.         lcd.clear();
  27.         counter = 0;
  28.         lcd.setCursor(0, 0);
  29.       }
  30.       if(counter == 16){
  31.         lcd.setCursor(0, 1);
  32.       }
  33.       if(counter == 32){
  34.         lcd.clear();
  35.         lcd.setCursor(0, 0);
  36.         counter = 0;
  37.       }
  38.     }
  39. }

Hightechrobo bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.