mr happy
/
flashing_leds
Reads the voltage from Pin18 (out) based on the output from Pin(20) i.e a self checking voltmeter.
Diff: main.cpp
- Revision:
- 0:7c659fdad918
- Child:
- 1:a4c99d145ce3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Feb 04 22:36:45 2011 +0000 @@ -0,0 +1,32 @@ +#include "mbed.h" + +AnalogIn ain(p20); +DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); + +// use pin 20 and GND to display a binary read out on the lights +// of the voltage across the pins. +// did not validate this in anyway. +// mrhappy + +void bindisplay(int i){ + + // based on Kohei Matsumura code. + wait(0.2); + led1 = i & 0x01; + led2 = i>>1 & 0x01; + led3 = i>>2 & 0x01; + led4 = i>>3 & 0x01; + +} + +int main() { + + while (1){ + + bindisplay( ain * 0x0f ); + + } +} \ No newline at end of file