an analog value is steering 3 LEDs to small to big, a correct bandwith.
This ist a First Test. Nov. 2017[ [/media/uploads/schlaumaier54/analog4x_com_profilab.pdf]]
mainAD_Rs232.cpp
- Committer:
- schlaumaier54
- Date:
- 2015-08-19
- Revision:
- 0:d6a883eceea6
- Child:
- 1:ea2eb4841100
File content as of revision 0:d6a883eceea6:
/* Hardware: Nucleo F103RB Test02 analog ein über RS232 aus mit 9600Baud 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 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 // fprint kann ohne z.B.: Serial pc(USBTX, USBRX); // tx, rx über USB-Chip // dann jedoch nur mit 9600 BAUD // ansonsten z.B.: pc.baud(19200); //------------------------------------ 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 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 if (mess0 => 1800 && mess0 < 2001) { // If the value is greater than 2V then switch the LED off led = 1; } else { led = 0; } if (mess0 < 1800 ) { // If the value is greater than 2V then switch the LED on led2 = 1; } else { led2 = 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 } }