Lab exercise 2.2 Potentiometers experiment

Dependencies:   mbed C12832

Files at this revision

API Documentation at this revision

Comitter:
ciaranom
Date:
Sat Jun 20 14:27:59 2020 +0000
Parent:
0:9f16c71a1120
Commit message:
Added comments

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Jun 20 11:18:25 2020 +0000
+++ b/main.cpp	Sat Jun 20 14:27:59 2020 +0000
@@ -4,27 +4,27 @@
 PwmOut led1(LED1);
 AnalogIn pot1(p19);
 C12832 lcd(p5, p7, p6, p8, p11);
-float pot1val;
+float pot1val;  //creating floating number o be read and printed 
 
 int main() {
  while(1) {
- led1 = pot1;
+ led1 = pot1; // sets output of led1 to the output of pot1 
  wait(0.01);
 
 
 pot1val = pot1*100;
 
-        lcd.cls(); 
-        wait(.1);
-        lcd.locate(0,0);
-        lcd.printf("Pot1 value: %.4f", pot1val);
-        wait(1);
+        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(); 
-        wait(.1);
-        lcd.locate(0,0);;
-        lcd.printf("Pot1 value: %.4e", pot1.read());
-        wait (1);
+        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
         
     
     }