
c
Dependencies: mbed Grove_LCD_RGB_Backlight
Revision 1:734e32694486, committed 2020-11-07
- Comitter:
- DavidRoss
- Date:
- Sat Nov 07 22:06:33 2020 +0000
- Parent:
- 0:cb2826e4b518
- Child:
- 2:e3219488a466
- Commit message:
- lab6b_no_errors
Changed in this revision
lab6b.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/lab6b.cpp Thu Aug 27 17:22:29 2020 +0000 +++ b/lab6b.cpp Sat Nov 07 22:06:33 2020 +0000 @@ -5,8 +5,7 @@ Description: This program will take keyboard input to position fixed text and to change the colour of screen the text is displayed on. -*/ - +*/ // Include Section #include "Grove_LCD_RGB_Backlight.h" // Grove LCD header file #include "mbed.h" // mbed header file @@ -16,29 +15,32 @@ void position(int x, int y); // positions screen cursor at (x,y) // Hardware definition Section -Grove_LCD_RGB_Backlight lcd(D14,D15); // lcd is associated with (D14,D15) +Grove_LCD_RGB_Backlight LCD(D14,D15); // lcd is associated with (D14,D15) AnalogIn pot(A1); // pot is associated with A1 -const int MAX=10; // MAX is dimension of Buffer Array +const int MAX=20; // MAX is dimension of Buffer Array int main(void) { char buffer[MAX]; // buffer has MAX elements - double voltage; // variable for storing voltage + double voltage,voltage1; // variable for storing voltage int i; // variable used to null array for(i=0;i<=MAX-1;++i) // NULL all elements 0 to MAX-1 { buffer[i]=0; // set element to NULL character } - lcd.clear(); // clear lcd screen - lcd.locate(0,0); // 1st column 1st row - lcd.print("0123456789012345"); // print grid 0-15 - lcd.setRGB(0x00,0x00,0xff); // set background to blue + LCD.clear(); // clear lcd screen + LCD.locate(0,0); // 1st column 1st row + sprintf(buffer,"Reading Voltage"); + LCD.locate(1,0); + LCD.print(buffer); + LCD.setRGB(0x00,0x00,0xff); // set background to blue for(;;) // infinite loop { voltage=pot.read(); // voltage reading (0-1) from pot - voltage=3.33*voltage; // scale to 3.33 volts - lcd.locate(3,1); // 4th column 2nd row - sprintf(buffer,"%5.3f",voltage); // voltage to string in buffer - lcd.print(buffer); // print buffer on lcd + voltage1=3.33*voltage; // scale to 3.33 volts + LCD.locate(2,1); // 4th column 2nd row + sprintf(buffer,"%5.3f %5.3f", + voltage,voltage1); // voltage to string in buffer + LCD.print(buffer); // print buffer on lcd wait(0.05); } } \ No newline at end of file