Blue LED matrix (8x16) program. Gets text string through bluetooth and displays it on led matrix. Also has a clock function- get system time from a phone through bluetooth and enters clock mode. In clock mode it acts as a clock showing hours and minutes and blinking led every second. Clock mode can be broken if a text string is received through bluetooth.

Dependencies:   mbed

Committer:
DaniusKalv
Date:
Sun Nov 02 11:25:00 2014 +0000
Revision:
9:ed7e8a6fc537
Parent:
7:ca5ed7936472
Child:
10:ee58d712c7fb
Added lower case letters

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DaniusKalv 0:06ac39308380 1 #include "mbed.h"
DaniusKalv 0:06ac39308380 2 #include "matrix.h"
DaniusKalv 2:3cc1e2dec7a2 3 #include "text.h"
DaniusKalv 6:76b89d8b62a0 4 #include <string>
DaniusKalv 2:3cc1e2dec7a2 5
DaniusKalv 2:3cc1e2dec7a2 6 text generator;
DaniusKalv 3:35a47548d29d 7 matrix display(p13, p12, p11, p14, p15, p17, p16);
DaniusKalv 6:76b89d8b62a0 8 DigitalOut led(LED1);
DaniusKalv 5:76dd6da3e640 9 Serial pc(USBTX, USBRX);
DaniusKalv 5:76dd6da3e640 10 Serial bluetooth(p28,p27);
DaniusKalv 7:ca5ed7936472 11 char line[99];
DaniusKalv 6:76b89d8b62a0 12 void receive();
DaniusKalv 0:06ac39308380 13
DaniusKalv 0:06ac39308380 14 int main() {
DaniusKalv 6:76b89d8b62a0 15 pc.baud(115200);
DaniusKalv 5:76dd6da3e640 16 bluetooth.baud(38400);
DaniusKalv 6:76b89d8b62a0 17 bluetooth.attach(&receive, Serial::RxIrq);
DaniusKalv 9:ed7e8a6fc537 18 generator.generate("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
DaniusKalv 5:76dd6da3e640 19 while(true){
DaniusKalv 6:76b89d8b62a0 20 if (strlen(line) > 0){
DaniusKalv 6:76b89d8b62a0 21 led = 0;
DaniusKalv 5:76dd6da3e640 22 generator.generate(line);
DaniusKalv 6:76b89d8b62a0 23 memset(line, 0, sizeof(line));
DaniusKalv 5:76dd6da3e640 24 }
DaniusKalv 3:35a47548d29d 25 display.show();
DaniusKalv 5:76dd6da3e640 26 }
DaniusKalv 6:76b89d8b62a0 27 }
DaniusKalv 6:76b89d8b62a0 28
DaniusKalv 6:76b89d8b62a0 29 void receive(){
DaniusKalv 6:76b89d8b62a0 30 led = 1;
DaniusKalv 6:76b89d8b62a0 31 int i, j = 0;
DaniusKalv 6:76b89d8b62a0 32 i = 10 * (bluetooth.getc() - 48);
DaniusKalv 6:76b89d8b62a0 33 i += bluetooth.getc() - 48;
DaniusKalv 6:76b89d8b62a0 34 do{
DaniusKalv 6:76b89d8b62a0 35 line[j] = bluetooth.getc();
DaniusKalv 6:76b89d8b62a0 36 j++;
DaniusKalv 6:76b89d8b62a0 37 wait(0.0004);
DaniusKalv 6:76b89d8b62a0 38 }
DaniusKalv 7:ca5ed7936472 39 while(bluetooth.readable() && (j < i) && (j < 99));
DaniusKalv 0:06ac39308380 40 }