kathan parikh
/
hiworld
hi
Diff: hiworld.cpp
- Revision:
- 0:cce248cfb763
- Child:
- 1:7ca26e605828
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hiworld.cpp Tue Jul 17 01:57:35 2018 +0000 @@ -0,0 +1,34 @@ +/************************************************************ +Program: Hello World for the Pololu Robot +File: HiWorld.cpp +Author: Your Name +Date: Today's date +Description: A simple robot program. +************************************************************/ + +// includes needed for all mbed programs +#include "mbed.h" +#include "m3pimaze.h" + +// variables for the robot and a blue led on the robot +m3pi robot(p23, p9, p10); +DigitalOut blueLed(LED1); + +int main() +{ + float voltage; // define a variable + robot.cls(); // clear the robot lcd display + robot.locate(0, 0); // position the lcd cursor (column 0, row 0) + robot.printf("HI WORLD"); // display the message + + while(1) // this makes the program repeat the following statements forever + { // repeating starts here + voltage = robot.battery(); // get the robot battery voltage + robot.locate(0, 1); // position the lcd cursor (column 0, row 1) + robot.printf("VB=%.3f", voltage); // display the battery voltage + blueLed = 1; // turn on blue led 1 + wait(0.5); // wait for half a second + blueLed = 0; // turn off blue led 1 + wait(0.5); // wait for half a second + } // loop round and repeat the above statements +} \ No newline at end of file