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

main.cpp

Committer:
DaniusKalv
Date:
2014-11-02
Revision:
9:ed7e8a6fc537
Parent:
7:ca5ed7936472
Child:
10:ee58d712c7fb

File content as of revision 9:ed7e8a6fc537:

#include "mbed.h"
#include "matrix.h"
#include "text.h"
#include <string>

text generator;
matrix display(p13, p12, p11, p14, p15, p17, p16);
DigitalOut led(LED1);
Serial pc(USBTX, USBRX);
Serial bluetooth(p28,p27);
char line[99];
void receive();

int main() {
    pc.baud(115200);
    bluetooth.baud(38400);
    bluetooth.attach(&receive, Serial::RxIrq);
    generator.generate("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
    while(true){
        if (strlen(line) > 0){  
            led = 0;  
            generator.generate(line);
            memset(line, 0, sizeof(line));
        }
        display.show();
    }
}

void receive(){
    led = 1;
    int i, j = 0;
    i = 10 * (bluetooth.getc() - 48);
    i += bluetooth.getc() - 48;
    do{ 
        line[j] = bluetooth.getc();
        j++;
        wait(0.0004);       
    }
    while(bluetooth.readable() && (j < i) && (j < 99));
}