Visweswara R
/
Arch_Analog_POT
Seeedstudio Arch Examples : Analog - Potentiometer example
main.cpp
- Committer:
- viswesr
- Date:
- 2013-10-07
- Revision:
- 1:f81ab0473843
- Parent:
- 0:b1a8b240b3a2
File content as of revision 1:f81ab0473843:
#include "mbed.h" AnalogIn pot(P0_11); /* Potentiometer middle pin connected to P0_11, other two ends connected to GND and 3.3V */ DigitalOut led(LED1); /* LED blinks with a delay based on the analog input read */ int main() { float ain; /* Variable to store the analog input*/ while(1) { ain = pot.read(); /* Read analog value (output will be any value between 0 and 1 */ led = 1; /* Switch ON LED */ wait(ain); /* Wait for 'ain' Seconds (maximum delay is 1 seconds)*/ led = 0; /* Switch Off LED */ wait(ain); /* Wait for 'ain' Seconds (maximum delay is 1 seconds)*/ } }