Seeedstudio Arch Examples : Analog - Potentiometer example

Dependencies:   mbed

Committer:
viswesr
Date:
Mon Oct 07 12:30:57 2013 +0000
Revision:
1:f81ab0473843
Parent:
0:b1a8b240b3a2
Minor changes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
viswesr 0:b1a8b240b3a2 1 #include "mbed.h"
viswesr 0:b1a8b240b3a2 2
viswesr 0:b1a8b240b3a2 3 AnalogIn pot(P0_11); /* Potentiometer middle pin connected to P0_11, other two ends connected to GND and 3.3V */
viswesr 0:b1a8b240b3a2 4 DigitalOut led(LED1); /* LED blinks with a delay based on the analog input read */
viswesr 0:b1a8b240b3a2 5
viswesr 0:b1a8b240b3a2 6 int main()
viswesr 0:b1a8b240b3a2 7 {
viswesr 1:f81ab0473843 8 float ain; /* Variable to store the analog input*/
viswesr 0:b1a8b240b3a2 9
viswesr 0:b1a8b240b3a2 10 while(1) {
viswesr 0:b1a8b240b3a2 11 ain = pot.read(); /* Read analog value (output will be any value between 0 and 1 */
viswesr 1:f81ab0473843 12 led = 1; /* Switch ON LED */
viswesr 1:f81ab0473843 13 wait(ain); /* Wait for 'ain' Seconds (maximum delay is 1 seconds)*/
viswesr 1:f81ab0473843 14 led = 0; /* Switch Off LED */
viswesr 1:f81ab0473843 15 wait(ain); /* Wait for 'ain' Seconds (maximum delay is 1 seconds)*/
viswesr 0:b1a8b240b3a2 16 }
viswesr 0:b1a8b240b3a2 17 }