Potentiometer experiment

Dependencies:   mbed C12832

Committer:
t00214916
Date:
Wed Aug 18 15:08:39 2021 +0000
Revision:
0:c82dcc0ff914
Potentiometer experiment

Who changed what in which revision?

UserRevisionLine numberNew contents of line
t00214916 0:c82dcc0ff914 1 #include "mbed.h"
t00214916 0:c82dcc0ff914 2 #include "C12832.h" // LCD on Mbed
t00214916 0:c82dcc0ff914 3
t00214916 0:c82dcc0ff914 4 PwmOut led1 (LED1); // Control the brightness of LED1
t00214916 0:c82dcc0ff914 5 AnalogIn pot1 (p19); //Used to change brightness
t00214916 0:c82dcc0ff914 6 C12832 lcd(p5, p7, p6, p8, p11); // Register the pins needed for LCD
t00214916 0:c82dcc0ff914 7
t00214916 0:c82dcc0ff914 8 int main()
t00214916 0:c82dcc0ff914 9 {
t00214916 0:c82dcc0ff914 10
t00214916 0:c82dcc0ff914 11 while(1) {
t00214916 0:c82dcc0ff914 12 led1 = pot1; // LED1 the same value as POT1
t00214916 0:c82dcc0ff914 13 lcd.locate(0,0); // Area on LCD to start text
t00214916 0:c82dcc0ff914 14 lcd.printf("Potentiometer value 1 = %.2f", pot1.read());
t00214916 0:c82dcc0ff914 15
t00214916 0:c82dcc0ff914 16 lcd.locate(0,10);
t00214916 0:c82dcc0ff914 17 lcd.printf("Potentiometer value 2 = %.2e", pot1.read());
t00214916 0:c82dcc0ff914 18
t00214916 0:c82dcc0ff914 19 wait(0.5);
t00214916 0:c82dcc0ff914 20 }
t00214916 0:c82dcc0ff914 21 }