Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: LineFollowingRobot/main.cpp
- Revision:
- 0:a02a278513d9
- Child:
- 1:a2ceed49374e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LineFollowingRobot/main.cpp Sat Jan 26 18:18:13 2019 +0000 @@ -0,0 +1,46 @@ +#include <mbed.h> +#include "RobotControl_H.h" + +DigitalIn leftIR(PTC6); +DigitalIn midLeftIR(PTC5); +DigitalIn midIR(PTC4); +DigitalIn midRightIR(PTC3); +DigitalIn rightIR(PTC0); + +Ticker sampling; +bool lineSensor[5], toggle2 = false; + + +void Sample(){ + //function attached to the ticker + //assigns the data recieved for each digital in into an array + //toggle is toggled at every ISR, signifying the ISR has occured + + lineSensor[0] = leftIR; + lineSensor[1] = midLeftIR; + lineSensor[2] = midIR; + lineSensor[3] = midRightIR; + lineSensor[4] = rightIR; + + toggle2 = !toggle2; +} + + + + +int main(){ + +//get a first reading +Sample(); +sampling.attach(&Sample, 0.01); + +RobotControl controlLeft(PTC12,PTD4,PTA5); +RobotControl controlRight(PTA13,PTA12,PTA4); + + + + while(1){ + wait(1); + } + +} \ No newline at end of file