mr happy
/
flashing_leds
Reads the voltage from Pin18 (out) based on the output from Pin(20) i.e a self checking voltmeter.
Revision 1:a4c99d145ce3, committed 2011-02-04
- Comitter:
- mrhappy
- Date:
- Fri Feb 04 23:08:04 2011 +0000
- Parent:
- 0:7c659fdad918
- Commit message:
- V0.1
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Feb 04 22:36:45 2011 +0000 +++ b/main.cpp Fri Feb 04 23:08:04 2011 +0000 @@ -1,6 +1,8 @@ #include "mbed.h" AnalogIn ain(p20); +AnalogOut aout(p18); + DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); @@ -14,7 +16,7 @@ void bindisplay(int i){ // based on Kohei Matsumura code. - wait(0.2); + wait(0.5); led1 = i & 0x01; led2 = i>>1 & 0x01; led3 = i>>2 & 0x01; @@ -24,9 +26,15 @@ int main() { - while (1){ + float vout = 0; + + while(1) + { + bindisplay( ain * 0xffff ); - bindisplay( ain * 0x0f ); - + vout += 0.1; + aout = vout; + + if (vout > 1) vout = 0; } } \ No newline at end of file