Ex 3

Dependencies:   mbed

Committer:
mazmonem
Date:
Mon Oct 09 16:21:52 2017 +0000
Revision:
1:0dafa64a6494
Parent:
0:2e3f58a3a6ac
Ex 3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mazmonem 1:0dafa64a6494 1 /******************************************************
mazmonem 1:0dafa64a6494 2 /ME21001 Group 1-10
mazmonem 1:0dafa64a6494 3 /
mazmonem 1:0dafa64a6494 4 /Lab 04: Exercise 2
mazmonem 1:0dafa64a6494 5 /
mazmonem 1:0dafa64a6494 6 /This program read the the value of the potnetiometer
mazmonem 1:0dafa64a6494 7 /and turns on LED#1 if the value is HIGH.
mazmonem 1:0dafa64a6494 8 /
mazmonem 1:0dafa64a6494 9 /******************************************************/
mazmonem 0:2e3f58a3a6ac 10 #include "mbed.h"
mazmonem 0:2e3f58a3a6ac 11 DigitalIn potentiometer(p17); // digital input variable declaration
mazmonem 0:2e3f58a3a6ac 12 DigitalOut led(LED1);// digital output variable declaration
mazmonem 1:0dafa64a6494 13 int main(){
mazmonem 1:0dafa64a6494 14 while(1) { //repeats indefinitely
mazmonem 1:0dafa64a6494 15 if (potentiometer.read()) { //if the value of the potentiometer is HIGH
mazmonem 1:0dafa64a6494 16 led = 1; //turn LED#1 on
mazmonem 1:0dafa64a6494 17 }
mazmonem 1:0dafa64a6494 18 else { //otherwise
mazmonem 1:0dafa64a6494 19 led = 0; //turn LED#1 off
mazmonem 1:0dafa64a6494 20 }
mazmonem 0:2e3f58a3a6ac 21 }
mazmonem 0:2e3f58a3a6ac 22 }