Lab exercise 2.2 Potentiometers experiment

Dependencies:   mbed C12832

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "C12832.h"
00003 
00004 PwmOut led1(LED1);
00005 AnalogIn pot1(p19);
00006 C12832 lcd(p5, p7, p6, p8, p11);
00007 float pot1val;  //creating floating number o be read and printed 
00008 
00009 int main() {
00010  while(1) {
00011  led1 = pot1; // sets output of led1 to the output of pot1 
00012  wait(0.01);
00013 
00014 
00015 pot1val = pot1*100;
00016 
00017         lcd.cls(); // clear screen
00018         wait(.1); // allows time for screen to clear
00019         lcd.locate(0,0); // lets the location on EDC where to begin printing
00020         lcd.printf("Pot1 value: %.4f %%", pot1val); //prints value of potentiometer
00021         wait(1); // holds image on screen for 1 second before screen is clealed
00022         
00023         lcd.cls(); // clears screen
00024         wait(.1); // allows time for screen to clear
00025         lcd.locate(0,0);; // lets the location on EDC where to begin printing
00026         lcd.printf("Pot1 value: %.4e", pot1.read()); //prints value of potentiometer
00027         wait (1); // holds image on screen for 1 second before screen is clealed
00028         
00029     
00030     }
00031 }