kathan parikh
/
hiworld
hi
hiworld.cpp@0:cce248cfb763, 2018-07-17 (annotated)
- Committer:
- parikhkathan
- Date:
- Tue Jul 17 01:57:35 2018 +0000
- Revision:
- 0:cce248cfb763
- Child:
- 1:7ca26e605828
hi
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
parikhkathan | 0:cce248cfb763 | 1 | /************************************************************ |
parikhkathan | 0:cce248cfb763 | 2 | Program: Hello World for the Pololu Robot |
parikhkathan | 0:cce248cfb763 | 3 | File: HiWorld.cpp |
parikhkathan | 0:cce248cfb763 | 4 | Author: Your Name |
parikhkathan | 0:cce248cfb763 | 5 | Date: Today's date |
parikhkathan | 0:cce248cfb763 | 6 | Description: A simple robot program. |
parikhkathan | 0:cce248cfb763 | 7 | ************************************************************/ |
parikhkathan | 0:cce248cfb763 | 8 | |
parikhkathan | 0:cce248cfb763 | 9 | // includes needed for all mbed programs |
parikhkathan | 0:cce248cfb763 | 10 | #include "mbed.h" |
parikhkathan | 0:cce248cfb763 | 11 | #include "m3pimaze.h" |
parikhkathan | 0:cce248cfb763 | 12 | |
parikhkathan | 0:cce248cfb763 | 13 | // variables for the robot and a blue led on the robot |
parikhkathan | 0:cce248cfb763 | 14 | m3pi robot(p23, p9, p10); |
parikhkathan | 0:cce248cfb763 | 15 | DigitalOut blueLed(LED1); |
parikhkathan | 0:cce248cfb763 | 16 | |
parikhkathan | 0:cce248cfb763 | 17 | int main() |
parikhkathan | 0:cce248cfb763 | 18 | { |
parikhkathan | 0:cce248cfb763 | 19 | float voltage; // define a variable |
parikhkathan | 0:cce248cfb763 | 20 | robot.cls(); // clear the robot lcd display |
parikhkathan | 0:cce248cfb763 | 21 | robot.locate(0, 0); // position the lcd cursor (column 0, row 0) |
parikhkathan | 0:cce248cfb763 | 22 | robot.printf("HI WORLD"); // display the message |
parikhkathan | 0:cce248cfb763 | 23 | |
parikhkathan | 0:cce248cfb763 | 24 | while(1) // this makes the program repeat the following statements forever |
parikhkathan | 0:cce248cfb763 | 25 | { // repeating starts here |
parikhkathan | 0:cce248cfb763 | 26 | voltage = robot.battery(); // get the robot battery voltage |
parikhkathan | 0:cce248cfb763 | 27 | robot.locate(0, 1); // position the lcd cursor (column 0, row 1) |
parikhkathan | 0:cce248cfb763 | 28 | robot.printf("VB=%.3f", voltage); // display the battery voltage |
parikhkathan | 0:cce248cfb763 | 29 | blueLed = 1; // turn on blue led 1 |
parikhkathan | 0:cce248cfb763 | 30 | wait(0.5); // wait for half a second |
parikhkathan | 0:cce248cfb763 | 31 | blueLed = 0; // turn off blue led 1 |
parikhkathan | 0:cce248cfb763 | 32 | wait(0.5); // wait for half a second |
parikhkathan | 0:cce248cfb763 | 33 | } // loop round and repeat the above statements |
parikhkathan | 0:cce248cfb763 | 34 | } |