d
Dependencies: mbed
Lab2_2.cpp@0:1de11c7b1807, 2016-10-31 (annotated)
- Committer:
- cha45689
- Date:
- Mon Oct 31 14:48:31 2016 +0000
- Revision:
- 0:1de11c7b1807
ddd
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cha45689 | 0:1de11c7b1807 | 1 | |
cha45689 | 0:1de11c7b1807 | 2 | #include "mbed.h" |
cha45689 | 0:1de11c7b1807 | 3 | |
cha45689 | 0:1de11c7b1807 | 4 | AnalogIn analog_value(A2); |
cha45689 | 0:1de11c7b1807 | 5 | DigitalOut i(D10); |
cha45689 | 0:1de11c7b1807 | 6 | BusOut leds(D2, D3, D4, D5); |
cha45689 | 0:1de11c7b1807 | 7 | BusOut leds1(D6, D7, D8, D9); |
cha45689 | 0:1de11c7b1807 | 8 | int main() { |
cha45689 | 0:1de11c7b1807 | 9 | while(1) { |
cha45689 | 0:1de11c7b1807 | 10 | double meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0) |
cha45689 | 0:1de11c7b1807 | 11 | printf ("\n%f",meas); |
cha45689 | 0:1de11c7b1807 | 12 | meas = meas * 33; // Change the value to be in the 0 to 3300 range |
cha45689 | 0:1de11c7b1807 | 13 | int b=meas; |
cha45689 | 0:1de11c7b1807 | 14 | int c = b % 10; |
cha45689 | 0:1de11c7b1807 | 15 | int d = b % 100 - c; |
cha45689 | 0:1de11c7b1807 | 16 | leds=c; |
cha45689 | 0:1de11c7b1807 | 17 | leds1=d/10; |
cha45689 | 0:1de11c7b1807 | 18 | i=1; |
cha45689 | 0:1de11c7b1807 | 19 | |
cha45689 | 0:1de11c7b1807 | 20 | } |
cha45689 | 0:1de11c7b1807 | 21 | } |
cha45689 | 0:1de11c7b1807 | 22 | // When the board read data on analog value to over 3.3 v., There will be error |