Mohammad Mohammad
/
serial_buff
serial comm example
Diff: main.cpp
- Revision:
- 0:ed9f04f7d1f6
- Child:
- 1:dd2f972ef479
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Feb 01 23:51:06 2014 +0000 @@ -0,0 +1,33 @@ +#include "mbed.h" +#include "PinDetect.h" + +DigitalOut myled(PTD5); +DigitalOut myled1(PTE29); + +//DigitalIn enable(PTC3); +//InterruptIn button(PTC3); +PinDetect button(PTC3); +Serial pc(USBTX,USBRX); + +void flip(){ + myled = !myled; + myled1= !myled1; + pc.puts("look at me bitch\r\n"); +} + +int main() { + //setup LED with debounce + myled = 1; + myled1 = 0; + button.mode(PullUp); + wait(.001); + button.attach_deasserted(&flip); + button.setSampleFrequency(); + + char buffer[128]; + + while(1) { + pc.gets(buffer,4); + pc.printf("i got '%s'\r\n",buffer); + } +}