Lab exercise 2.2 Potentiometers experiment

Dependencies:   mbed C12832

main.cpp

Committer:
ciaranom
Date:
2020-06-20
Revision:
1:1bb7bf26a054
Parent:
0:9f16c71a1120

File content as of revision 1:1bb7bf26a054:

#include "mbed.h"
#include "C12832.h"

PwmOut led1(LED1);
AnalogIn pot1(p19);
C12832 lcd(p5, p7, p6, p8, p11);
float pot1val;  //creating floating number o be read and printed 

int main() {
 while(1) {
 led1 = pot1; // sets output of led1 to the output of pot1 
 wait(0.01);


pot1val = pot1*100;

        lcd.cls(); // clear screen
        wait(.1); // allows time for screen to clear
        lcd.locate(0,0); // lets the location on EDC where to begin printing
        lcd.printf("Pot1 value: %.4f %%", pot1val); //prints value of potentiometer
        wait(1); // holds image on screen for 1 second before screen is clealed
        
        lcd.cls(); // clears screen
        wait(.1); // allows time for screen to clear
        lcd.locate(0,0);; // lets the location on EDC where to begin printing
        lcd.printf("Pot1 value: %.4e", pot1.read()); //prints value of potentiometer
        wait (1); // holds image on screen for 1 second before screen is clealed
        
    
    }
}