FSLP_Serial_Output

Committer:
sethnuon
Date:
Tue Oct 20 17:49:32 2015 +0000
Revision:
0:7d0912a942ad
FSLP Serial Output

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sethnuon 0:7d0912a942ad 1 #include "mbed.h"
sethnuon 0:7d0912a942ad 2 Serial pc(USBTX, USBRX);
sethnuon 0:7d0912a942ad 3
sethnuon 0:7d0912a942ad 4 DigitalInOut pinReference(p13);
sethnuon 0:7d0912a942ad 5 DigitalOut driveLine2(p14);
sethnuon 0:7d0912a942ad 6 AnalogIn senseLine3(p15);
sethnuon 0:7d0912a942ad 7
sethnuon 0:7d0912a942ad 8
sethnuon 0:7d0912a942ad 9 int main() {
sethnuon 0:7d0912a942ad 10 while(1) {
sethnuon 0:7d0912a942ad 11 /** output() is used to set the pin reference as an output pin and set it to ground */
sethnuon 0:7d0912a942ad 12 pinReference.output();
sethnuon 0:7d0912a942ad 13 pinReference = 0;
sethnuon 0:7d0912a942ad 14 driveLine2 = 1;
sethnuon 0:7d0912a942ad 15 float force = 0;
sethnuon 0:7d0912a942ad 16 /** read()is used to read in force */
sethnuon 0:7d0912a942ad 17 force = senseLine3.read();
sethnuon 0:7d0912a942ad 18 wait(0.001);
sethnuon 0:7d0912a942ad 19 /** input() is used to set the pin reference as an input */
sethnuon 0:7d0912a942ad 20 pinReference.input();
sethnuon 0:7d0912a942ad 21 driveLine2 = 0;
sethnuon 0:7d0912a942ad 22 float position = 0;
sethnuon 0:7d0912a942ad 23 /** read() is used to read in position */
sethnuon 0:7d0912a942ad 24 position = senseLine3.read();
sethnuon 0:7d0912a942ad 25 pc.printf("Force: %f", force);
sethnuon 0:7d0912a942ad 26 pc.printf(" Position: %f\r\n", position);
sethnuon 0:7d0912a942ad 27 wait(1);
sethnuon 0:7d0912a942ad 28
sethnuon 0:7d0912a942ad 29 }
sethnuon 0:7d0912a942ad 30 }
sethnuon 0:7d0912a942ad 31
sethnuon 0:7d0912a942ad 32