Mohammad Mohammad
/
serial_buff
serial comm example
main.cpp@0:ed9f04f7d1f6, 2014-02-01 (annotated)
- Committer:
- mohammmo
- Date:
- Sat Feb 01 23:51:06 2014 +0000
- Revision:
- 0:ed9f04f7d1f6
- Child:
- 1:dd2f972ef479
Hi Oliver, I'm trying the commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mohammmo | 0:ed9f04f7d1f6 | 1 | #include "mbed.h" |
mohammmo | 0:ed9f04f7d1f6 | 2 | #include "PinDetect.h" |
mohammmo | 0:ed9f04f7d1f6 | 3 | |
mohammmo | 0:ed9f04f7d1f6 | 4 | DigitalOut myled(PTD5); |
mohammmo | 0:ed9f04f7d1f6 | 5 | DigitalOut myled1(PTE29); |
mohammmo | 0:ed9f04f7d1f6 | 6 | |
mohammmo | 0:ed9f04f7d1f6 | 7 | //DigitalIn enable(PTC3); |
mohammmo | 0:ed9f04f7d1f6 | 8 | //InterruptIn button(PTC3); |
mohammmo | 0:ed9f04f7d1f6 | 9 | PinDetect button(PTC3); |
mohammmo | 0:ed9f04f7d1f6 | 10 | Serial pc(USBTX,USBRX); |
mohammmo | 0:ed9f04f7d1f6 | 11 | |
mohammmo | 0:ed9f04f7d1f6 | 12 | void flip(){ |
mohammmo | 0:ed9f04f7d1f6 | 13 | myled = !myled; |
mohammmo | 0:ed9f04f7d1f6 | 14 | myled1= !myled1; |
mohammmo | 0:ed9f04f7d1f6 | 15 | pc.puts("look at me bitch\r\n"); |
mohammmo | 0:ed9f04f7d1f6 | 16 | } |
mohammmo | 0:ed9f04f7d1f6 | 17 | |
mohammmo | 0:ed9f04f7d1f6 | 18 | int main() { |
mohammmo | 0:ed9f04f7d1f6 | 19 | //setup LED with debounce |
mohammmo | 0:ed9f04f7d1f6 | 20 | myled = 1; |
mohammmo | 0:ed9f04f7d1f6 | 21 | myled1 = 0; |
mohammmo | 0:ed9f04f7d1f6 | 22 | button.mode(PullUp); |
mohammmo | 0:ed9f04f7d1f6 | 23 | wait(.001); |
mohammmo | 0:ed9f04f7d1f6 | 24 | button.attach_deasserted(&flip); |
mohammmo | 0:ed9f04f7d1f6 | 25 | button.setSampleFrequency(); |
mohammmo | 0:ed9f04f7d1f6 | 26 | |
mohammmo | 0:ed9f04f7d1f6 | 27 | char buffer[128]; |
mohammmo | 0:ed9f04f7d1f6 | 28 | |
mohammmo | 0:ed9f04f7d1f6 | 29 | while(1) { |
mohammmo | 0:ed9f04f7d1f6 | 30 | pc.gets(buffer,4); |
mohammmo | 0:ed9f04f7d1f6 | 31 | pc.printf("i got '%s'\r\n",buffer); |
mohammmo | 0:ed9f04f7d1f6 | 32 | } |
mohammmo | 0:ed9f04f7d1f6 | 33 | } |