Example code for ADC Workshop IEEE TAMU
Dependencies: mbed
main.cpp@0:3ac4b3f82983, 2015-04-03 (annotated)
- Committer:
- matthewrdestefano
- Date:
- Fri Apr 03 21:08:30 2015 +0000
- Revision:
- 0:3ac4b3f82983
ADC Workshop V1;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
matthewrdestefano | 0:3ac4b3f82983 | 1 | #include "mbed.h" |
matthewrdestefano | 0:3ac4b3f82983 | 2 | AnalogIn voltage(PTB0); // set the analog input to pin PTB0 |
matthewrdestefano | 0:3ac4b3f82983 | 3 | |
matthewrdestefano | 0:3ac4b3f82983 | 4 | int main(void) { |
matthewrdestefano | 0:3ac4b3f82983 | 5 | |
matthewrdestefano | 0:3ac4b3f82983 | 6 | PwmOut led(LED_GREEN); // set green LED as PWM output |
matthewrdestefano | 0:3ac4b3f82983 | 7 | while (true) // infinite loop |
matthewrdestefano | 0:3ac4b3f82983 | 8 | { |
matthewrdestefano | 0:3ac4b3f82983 | 9 | led = 1.0 - voltage.read(); // update the LED brightness with ADC data |
matthewrdestefano | 0:3ac4b3f82983 | 10 | } |
matthewrdestefano | 0:3ac4b3f82983 | 11 | } |
matthewrdestefano | 0:3ac4b3f82983 | 12 |