Example code 06
Dependencies: mbed
Fork of STMNucleoF401RE_ExampleCode_06_VariableR by
Il circuito
Diff: main.cpp
- Revision:
- 2:67c48dcc85f0
- Parent:
- 1:25052aedb239
diff -r 25052aedb239 -r 67c48dcc85f0 main.cpp --- a/main.cpp Wed Oct 19 08:50:13 2016 +0000 +++ b/main.cpp Wed Mar 01 14:04:14 2017 +0000 @@ -9,7 +9,7 @@ // Instanzia un oggetto di tipo AnalogIn che chiamo analog_value, e lo assegna al pin A0 AnalogIn analog_value(A0); - +BusOut Bar(PC_8,PC_6,PC_5,PA_12,PA_11,PB_12,PB_2,PB_1,PB_15,PB_14); DigitalOut led(LED1); int main() { @@ -17,14 +17,24 @@ while(1) { meas = analog_value.read(); // It reads the analog input value (value from 0.0 to 1.0) + + // int i=int(10*meas); + // meas = meas * 3300; // Change the value to be in the 0 to 3300 range + float i=(meas/330); + printf("intero = %.2f \r\n", i); printf("measure = %.2f mV\r\n", meas); - if (meas > 2000) { // If the value is greater than 2V then switch the LED on - led = 1; + + // printf("calcolo i = %.2f mV\r\n", i); + int j=int(i); + printf("valore j = %d\n", j); + Bar =1<<j; + if (meas < 2500) { // If the value is greater than 2V then switch the LED on + led = 1; } else { led = 0; } - wait(0.2); // 200 ms + wait(.1); // 200 ms } }