- //Mohamadi & Abasi
- #include <SoftwareSerial.h>
- #include <LiquidCrystal.h>
- // initialize the library by associating any needed LCD interface pin
- // with the arduino pin number it is connected to
- const int rs = 8, en = 9, d4 = 10, d5 = 11, d6 = 12, d7 = 13;
- LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
- SoftwareSerial bt(2,3); /* (Rx,Tx) */
- void setup() {
- bt.begin(9600); /* Define baud rate for software serial communication */
- Serial.begin(9600); /* Define baud rate for serial communication */
- lcd.begin(16, 2);
- }
- char counter = 0;
- void loop() {
- if (bt.available()) /* If data is available on serial port */
- {
- char a = bt.read();
- Serial.println("my name is optimus prime");
- lcd.print(a);
- counter++;
- if(a == '#'){
- lcd.clear();
- counter = 0;
- lcd.setCursor(0, 0);
- }
- if(counter == 16){
- lcd.setCursor(0, 1);
- }
- if(counter == 32){
- lcd.clear();
- lcd.setCursor(0, 0);
- counter = 0;
- }
- }
- }
Recent Pastes