Mohammad Mohammad
/
serial_buff
serial comm example
main.cpp
- Committer:
- oliverfang
- Date:
- 2014-02-02
- Revision:
- 2:bd1893295536
- Parent:
- 1:dd2f972ef479
File content as of revision 2:bd1893295536:
#include "mbed.h" #include "PinDetect.h" DigitalOut myled(PTD5); DigitalOut myled1(PTE29); //DigitalIn enable(PTC3); //InterruptIn button(PTC3); //construct an object called button that represents one of the pins //constructor requires a pin name: PTC3 in this case 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); // interrupt button.attach_deasserted(&flip); button.setSampleFrequency(); char buffer[128]; while(1) { // read in every character pc.gets(buffer, 2); // check if carriage return is pressed if((int)buffer[0] == 13) { // print return and new line pc.puts("\r\n"); } else { // otherwise just print the character that was typed pc.puts(buffer); } } }