Maria Monem
/
ME21001_Lab04_Exercise_03
Ex 3
Diff: main.cpp
- Revision:
- 1:0dafa64a6494
- Parent:
- 0:2e3f58a3a6ac
--- 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