VU Metar
Dependencies: mbed
main.cpp
- Committer:
- Kzupancic
- Date:
- 2015-12-03
- Revision:
- 0:506a7414abf8
File content as of revision 0:506a7414abf8:
#include "mbed.h" DigitalOut LEeD1(LED1); DigitalOut LEeD2(LED2); DigitalOut LEeD3(LED3); DigitalOut LEeD4(LED4); Serial pc(USBTX, USBRX); AnalogIn Ain(p20); float ADCdata; int main() { pc.printf("ADC Data Values... \n\r"); while(1) { ADCdata=Ain; pc.printf("%f\n\r",ADCdata); wait(0.5); if (ADCdata<0.2) { LEeD1=0; LEeD2=0; LEeD3=0; LEeD4=0; } else if ((ADCdata>0.2)&&(ADCdata<0.4)) { LEeD1=1; LEeD2=0; LEeD3=0; LEeD4=0; } else if ((ADCdata>0.4)&&(ADCdata<0.6)) { LEeD1=1; LEeD2=1; LEeD3=0; LEeD4=0; } else if ((ADCdata>0.6)&&(ADCdata<0.8)) { LEeD1=1; LEeD2=1; LEeD3=1; LEeD4=0; } else if ((ADCdata>0.8)&&(ADCdata<1)) { LEeD1=1; LEeD2=1; LEeD3=1; LEeD4=1; } } }