Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 2:be979d53b674
- Parent:
- 1:352debc405fd
--- a/main.cpp Tue May 19 22:18:01 2020 +0000
+++ b/main.cpp Wed May 20 04:59:56 2020 +0000
@@ -4,16 +4,19 @@
#include "mbed.h"
-AnalogIn analog_value(A0);
+AnalogIn analog_value(PA_0);
+Serial pc(PA_9, PA_10, 9600);
-DigitalOut led(LED1);
+DigitalOut red(PA_7);
+DigitalOut yellow(PB_0);
+DigitalOut blue(PB_1);
int main()
{
float meas_r;
float meas_v;
- printf("\nAnalogIn example\n");
+ pc.printf("\nAnalogIn example\n");
while(1) {
@@ -21,15 +24,23 @@
meas_v = meas_r * 3300; // Converts value in the 0V-3.3V range
// Display values
- printf("measure = %f = %.0f mV\n", meas_r, meas_v);
+ pc.printf("%f,%.0f\r\n", meas_r, meas_v);
// LED is ON is the value is below 1V
- if (meas_v < 1000) {
- led = 1; // LED ON
- } else {
- led = 0; // LED OFF
+ if (meas_v > 2000) {
+ red = 1; // LED ON
+ yellow = 0;
+ blue = 0;
+ }else if(meas_v > 1200) {
+ red = 1; // LED ON
+ yellow = 1;
+ blue = 0;
+ }else{
+ red = 1; // LED ON
+ yellow = 1;
+ blue = 1;
}
- wait(1.0); // 1 second
+ wait(0.2); // 1 second
}
}