Receives text from a Android or other Bluetooth terminal and displays it on a 4-line HD4480-compatible text LCD. Uses an STM32F407VE "Black Pill" development board.

Dependencies:   TextLCD mbed

Committer:
katbar
Date:
Mon Oct 15 23:49:33 2018 +0000
Revision:
0:2967b94b655c
Bluetooth to HD4480 4-line LCD.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
katbar 0:2967b94b655c 1 /*
katbar 0:2967b94b655c 2 Bluetooth to HD44780 (via Android Blutooth TerminL)
katbar 0:2967b94b655c 3 Kate Barnes
katbar 0:2967b94b655c 4 JY-MCU Bluetooth Module, 4-line HD44780 compatible LCD,
katbar 0:2967b94b655c 5 STM32F407VE Development Board
katbar 0:2967b94b655c 6 */
katbar 0:2967b94b655c 7
katbar 0:2967b94b655c 8 #include "mbed.h"
katbar 0:2967b94b655c 9 #include "TextLCD.h"
katbar 0:2967b94b655c 10
katbar 0:2967b94b655c 11 Serial pc(PA_9, PA_10); // tx, rx. To terminal
katbar 0:2967b94b655c 12 Serial pc2(PA_2, PA_3); // tx, rx. To bluetooth board
katbar 0:2967b94b655c 13
katbar 0:2967b94b655c 14 int main() {
katbar 0:2967b94b655c 15 TextLCD lcd(PE_2,PE_3,PE_4,PE_5,PE_6,PE_7, TextLCD::LCD20x4);
katbar 0:2967b94b655c 16 // Define custom character and assign it to '\1'
katbar 0:2967b94b655c 17 char square[]={ 0x0,0x1f,0x11,0x11,0x11,0x1f,0x0,0x0 };
katbar 0:2967b94b655c 18 lcd.defineChar(1, square);
katbar 0:2967b94b655c 19
katbar 0:2967b94b655c 20 pc.baud(57600);
katbar 0:2967b94b655c 21 pc.printf("Serial terminal online\r\n");
katbar 0:2967b94b655c 22 pc.printf("SystemCoreClock is %d MHz\r\n", (SystemCoreClock/1000000));
katbar 0:2967b94b655c 23
katbar 0:2967b94b655c 24 pc2.baud(9600); // linvor bluetooth module default baud rate
katbar 0:2967b94b655c 25 //pc2.printf("AT");
katbar 0:2967b94b655c 26 //wait(1);
katbar 0:2967b94b655c 27 //if(pc2.readable())
katbar 0:2967b94b655c 28 //{
katbar 0:2967b94b655c 29 // pc.putc(pc2.getc());
katbar 0:2967b94b655c 30 //}
katbar 0:2967b94b655c 31 lcd.printf(" \1 BT Receiver \1");
katbar 0:2967b94b655c 32 lcd.printf(" ");
katbar 0:2967b94b655c 33 lcd.printf(" ");
katbar 0:2967b94b655c 34 lcd.printf(" \1 Barnes \1");
katbar 0:2967b94b655c 35 wait(2);
katbar 0:2967b94b655c 36 lcd.cls();
katbar 0:2967b94b655c 37 while (1)
katbar 0:2967b94b655c 38 {
katbar 0:2967b94b655c 39 if(pc2.readable())
katbar 0:2967b94b655c 40 {
katbar 0:2967b94b655c 41 char SChar = pc2.getc();
katbar 0:2967b94b655c 42 pc.putc(SChar);
katbar 0:2967b94b655c 43 lcd.putc(SChar);
katbar 0:2967b94b655c 44 }
katbar 0:2967b94b655c 45 }
katbar 0:2967b94b655c 46 }