FSLP_Serial_Output

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 Serial pc(USBTX, USBRX);
00003 
00004 DigitalInOut pinReference(p13);
00005 DigitalOut driveLine2(p14);
00006 AnalogIn senseLine3(p15);
00007 
00008 
00009 int main() {
00010     while(1) {
00011   /** output() is used to set the pin reference as an output pin and set it to ground */
00012        pinReference.output();
00013        pinReference = 0;
00014        driveLine2 = 1;
00015        float force = 0; 
00016        /** read()is used to read in force */
00017        force = senseLine3.read();
00018        wait(0.001);
00019        /** input() is used to set the pin reference as an input */
00020        pinReference.input();
00021        driveLine2 = 0;
00022        float position = 0;
00023        /** read() is used to read in position */
00024        position = senseLine3.read();
00025        pc.printf("Force: %f", force);
00026        pc.printf("     Position: %f\r\n", position);
00027        wait(1);
00028     
00029     }
00030 }
00031 
00032