serial comm example

Dependencies:   PinDetect mbed

Committer:
oliverfang
Date:
Sat Feb 01 23:58:09 2014 +0000
Revision:
1:dd2f972ef479
Parent:
0:ed9f04f7d1f6
Child:
2:bd1893295536
testing commit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mohammmo 0:ed9f04f7d1f6 1 #include "mbed.h"
mohammmo 0:ed9f04f7d1f6 2 #include "PinDetect.h"
mohammmo 0:ed9f04f7d1f6 3
oliverfang 1:dd2f972ef479 4 // Hi Mohammed, I am testing the commit system
oliverfang 1:dd2f972ef479 5
mohammmo 0:ed9f04f7d1f6 6 DigitalOut myled(PTD5);
mohammmo 0:ed9f04f7d1f6 7 DigitalOut myled1(PTE29);
mohammmo 0:ed9f04f7d1f6 8
mohammmo 0:ed9f04f7d1f6 9 //DigitalIn enable(PTC3);
mohammmo 0:ed9f04f7d1f6 10 //InterruptIn button(PTC3);
mohammmo 0:ed9f04f7d1f6 11 PinDetect button(PTC3);
mohammmo 0:ed9f04f7d1f6 12 Serial pc(USBTX,USBRX);
mohammmo 0:ed9f04f7d1f6 13
mohammmo 0:ed9f04f7d1f6 14 void flip(){
mohammmo 0:ed9f04f7d1f6 15 myled = !myled;
mohammmo 0:ed9f04f7d1f6 16 myled1= !myled1;
mohammmo 0:ed9f04f7d1f6 17 pc.puts("look at me bitch\r\n");
mohammmo 0:ed9f04f7d1f6 18 }
mohammmo 0:ed9f04f7d1f6 19
mohammmo 0:ed9f04f7d1f6 20 int main() {
mohammmo 0:ed9f04f7d1f6 21 //setup LED with debounce
mohammmo 0:ed9f04f7d1f6 22 myled = 1;
mohammmo 0:ed9f04f7d1f6 23 myled1 = 0;
mohammmo 0:ed9f04f7d1f6 24 button.mode(PullUp);
mohammmo 0:ed9f04f7d1f6 25 wait(.001);
mohammmo 0:ed9f04f7d1f6 26 button.attach_deasserted(&flip);
mohammmo 0:ed9f04f7d1f6 27 button.setSampleFrequency();
mohammmo 0:ed9f04f7d1f6 28
mohammmo 0:ed9f04f7d1f6 29 char buffer[128];
mohammmo 0:ed9f04f7d1f6 30
mohammmo 0:ed9f04f7d1f6 31 while(1) {
mohammmo 0:ed9f04f7d1f6 32 pc.gets(buffer,4);
mohammmo 0:ed9f04f7d1f6 33 pc.printf("i got '%s'\r\n",buffer);
mohammmo 0:ed9f04f7d1f6 34 }
mohammmo 0:ed9f04f7d1f6 35 }