![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
c
Dependencies: mbed Grove_LCD_RGB_Backlight
lab6b.cpp
- Committer:
- DavidRoss
- Date:
- 2020-08-27
- Revision:
- 0:cb2826e4b518
- Child:
- 1:734e32694486
File content as of revision 0:cb2826e4b518:
/* Title: Program to position text on different coloured backgrounds. Author: Dave Ross Date: Mar 21st, 2019 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 // Function Prototype Section void clear(void); // clears the PC screen 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) AnalogIn pot(A1); // pot is associated with A1 const int MAX=10; // MAX is dimension of Buffer Array int main(void) { char buffer[MAX]; // buffer has MAX elements double voltage; // 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 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 wait(0.05); } }