an analog value is steering 3 LEDs to small to big, a correct bandwith.

Dependencies:   mbed

This ist a First Test. Nov. 2017[ [/media/uploads/schlaumaier54/analog4x_com_profilab.pdf]]

Files at this revision

API Documentation at this revision

Comitter:
schlaumaier54
Date:
Tue Sep 08 17:18:30 2015 +0000
Parent:
0:d6a883eceea6
Commit message:
an analog value is steering three LEDs. Three limits are given, to small to big, value ok.

Changed in this revision

mainAD_Rs232.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r d6a883eceea6 -r ea2eb4841100 mainAD_Rs232.cpp
--- a/mainAD_Rs232.cpp	Wed Aug 19 13:48:29 2015 +0000
+++ b/mainAD_Rs232.cpp	Tue Sep 08 17:18:30 2015 +0000
@@ -4,16 +4,17 @@
 Ziel: Verschiedene Analogwerte einlesen
 Aufgaben: Pinbezeichnungen testen
 Konkret: Eine zweite und dritte externe LED hinzufügen. Funktion:
-LED1 leuchtet zwischen 1,8Volt und 2Volt;  LED2 leuchtet unterhalb 1,8V; LED3 leuchtet oberhalb 2V
+LED1 leuchtet zwischen 1,6Volt und 2,2Volt;  LED2 leuchtet unterhalb 1,6V; LED3 leuchtet oberhalb 2,2V
 Aug 2015
 */
 
 #include "mbed.h"
- 
+
 AnalogIn analog_value0(A0);      //Entspricht Pin PA_0
 DigitalOut led(LED1);   //LED1 auf der Platine vom Nucleo-Board
 DigitalOut led2(D7);   //D7 auf ARDUINO Steckleite = PA_8
 DigitalOut led3(D6);   //D6 auf ARDUINO Steckleite = PB_10
+
 //------------------------------------
 // Hyperterminal configuration
 // 9600 bauds, 8-bit data, no parity
@@ -22,40 +23,36 @@
 // ansonsten z.B.: pc.baud(19200);
 //------------------------------------
 
-int main() 
+int main()
 {
-    
+
     float mess0;
 
     printf("\nAnalogIn example\n");
-    
-    while(1) 
-    {
-       mess0 = analog_value0.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
-       mess0 = mess0 * 3300; // Change the value to be in the 0 to 3300 range -> milliVolt
+
+    while(1) {
+        mess0 = analog_value0.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
+        mess0 = mess0 * 3300; // Change the value to be in the 0 to 3300 range -> milliVolt
         printf("Analogwert0 = %.2f mVolt\r\n", mess0);  //Rs232 output-> You will see this in Terminalprogramm on PC
-                    //%.2f -> Anzeige mit 2Stellen hinter Komma
-                    //\r = Wagenruecklauf  \n =neue Zeile
+        //%.2f -> Anzeige mit 2Stellen hinter Komma
+        //\r = Wagenruecklauf  \n =neue Zeile
 
-        if (mess0 => 1800 && mess0 < 2001) { // If the value is greater than 2V then switch the LED off
-          led = 1;
+        if ((mess0 > 1599 && mess0 < 2201)) { // If the value is greater than 1,6V and smaller 2,2V  then switch the LED off
+            led = 1;
+        } else {
+            led = 0;
         }
-        else {
-          led = 0;
-        }
-        if (mess0 < 1800 ) { // If the value is greater than 2V then switch the LED on
-          led2 = 1;
+        if (mess0 < 1600 ) { // If the value is greater than 1,6V then switch the LED on
+            led2 = 1;
+        } else {
+            led2 = 0;
         }
-        else {
-          led2 = 0;
+        if (mess0 >2200 ) { // If the value is greater than 2,2V then switch the LED on
+            led3 = 1;
+        } else {
+            led3 = 0;
         }
-         if (mess0 > ) { // If the value is greater than 2V then switch the LED on
-          led3 = 1;
-        }
-        else {
-          led3 = 0;
-        }
-        
+
         wait(0.5); // 500 ms
     }
 }
diff -r d6a883eceea6 -r ea2eb4841100 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Sep 08 17:18:30 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7e07b6fb45cf
\ No newline at end of file