Ex 3

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
mazmonem
Date:
Mon Oct 09 16:21:52 2017 +0000
Parent:
0:2e3f58a3a6ac
Commit message:
Ex 3

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Oct 05 15:51:17 2017 +0000
+++ b/main.cpp	Mon Oct 09 16:21:52 2017 +0000
@@ -1,13 +1,22 @@
+/******************************************************
+/ME21001 Group 1-10
+/
+/Lab 04: Exercise 2
+/
+/This program read the the value of the potnetiometer
+/and turns on LED#1 if the value is HIGH. 
+/
+/******************************************************/
 #include "mbed.h"
 DigitalIn potentiometer(p17); // digital input variable declaration
 DigitalOut led(LED1);// digital output variable declaration
-int main() {
-while(1) {
-if (potentiometer.read()) {
-    led = 1;
+int main(){
+    while(1) { //repeats indefinitely
+        if (potentiometer.read()) { //if the value of the potentiometer is HIGH
+            led = 1; //turn LED#1 on
+        } 
+        else { //otherwise
+            led = 0; //turn LED#1 off
+        }
     }
-else {
-led = 0;
-}   
-}
 }
\ No newline at end of file