Analog to 7 Segment (0-3.3 Volt Meter)
Dependencies: mbed
main.cpp@0:35597540ea31, 2015-10-13 (annotated)
- Committer:
- mustwillza
- Date:
- Tue Oct 13 07:36:32 2015 +0000
- Revision:
- 0:35597540ea31
Data
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mustwillza | 0:35597540ea31 | 1 | #include "mbed.h" |
mustwillza | 0:35597540ea31 | 2 | Serial pc(USBTX, USBRX); // tx, rx |
mustwillza | 0:35597540ea31 | 3 | |
mustwillza | 0:35597540ea31 | 4 | AnalogIn ain(PC_0); |
mustwillza | 0:35597540ea31 | 5 | BusOut dout(D6,D7,D8); |
mustwillza | 0:35597540ea31 | 6 | BusOut dout2(D9,D10,D11,D12,D13); |
mustwillza | 0:35597540ea31 | 7 | |
mustwillza | 0:35597540ea31 | 8 | int main(){ |
mustwillza | 0:35597540ea31 | 9 | int value; //First Digit Value |
mustwillza | 0:35597540ea31 | 10 | int dvalue; //Second Digit Value |
mustwillza | 0:35597540ea31 | 11 | float data; //Raw Data (store AnalogRead) |
mustwillza | 0:35597540ea31 | 12 | while(1){ |
mustwillza | 0:35597540ea31 | 13 | data = ain.read(); // Data 0.0 -> 1.0 |
mustwillza | 0:35597540ea31 | 14 | value = data * 3.3; // Data 0.0 -> 3.3 (Int 0 - > 3) |
mustwillza | 0:35597540ea31 | 15 | dout = value; //Bus out 0 - 3 |
mustwillza | 0:35597540ea31 | 16 | |
mustwillza | 0:35597540ea31 | 17 | dvalue = data*33; // Data 00 -> 33 |
mustwillza | 0:35597540ea31 | 18 | dvalue = dvalue %10; // Data 0 - 9 |
mustwillza | 0:35597540ea31 | 19 | dout2 = dvalue; //Bus out number 0 - 9 |
mustwillza | 0:35597540ea31 | 20 | |
mustwillza | 0:35597540ea31 | 21 | } |
mustwillza | 0:35597540ea31 | 22 | } |