Brady Dove
/
ResistiveSensors
lab
Diff: main.cpp
- Revision:
- 0:451fa025f45e
diff -r 000000000000 -r 451fa025f45e main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Apr 10 01:04:29 2015 +0000 @@ -0,0 +1,37 @@ +#include "mbed.h" + +Serial s(USBTX, USBRX); //serial connection +AnalogIn photoIn(p20); //analog input pin20 and named PhotoIn +Timer t; //timer object for timestamp + +void setupSerial(void) +{ + s.baud(19200); //sets the BaudRate + s.format(7,SerialBase::Even,1); //set DataBits, Parity, and StopBits +} + +int main(void) +{ + setupSerial(); + + float time; //current time + float data; //current data + + + t.reset(); //resets timer + t.start(); //starts timer + + //Loop + int go = 1; + while(go==1) { + //Read data + data = photoIn.read(); + time= t.read(); + + //Print data to serial port + s.printf("%f,%f\n",time,data); + + wait(0.5); + } +} +