Lehrer Busch
/
130_robot_I2C_LCD_US_Sensor_Lsg
130_robot_I2C_LCD_US_Sensor_Lsg
Revision 0:f3ae37b05bfb, committed 2022-02-23
- Comitter:
- itbusch
- Date:
- Wed Feb 23 18:50:57 2022 +0000
- Commit message:
- 130_robot_I2C_LCD_US_Sensor_Lsg
Changed in this revision
diff -r 000000000000 -r f3ae37b05bfb HCSR04.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HCSR04.lib Wed Feb 23 18:50:57 2022 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/TVZ-Mechatronics-Team/code/HCSR04/#cf3e4e307d15
diff -r 000000000000 -r f3ae37b05bfb UP_US_Sensor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UP_US_Sensor.h Wed Feb 23 18:50:57 2022 +0000 @@ -0,0 +1,17 @@ +Timer timer; +HCSR04 sensor(D2, D4); //Echo, Trugger Pin +float Abstand; + + void Abstandsmessung (void) + { + timer.reset(); + timer.start(); + sensor.startMeasurement(); + while(!sensor.isNewDataReady()) { + // wait for new data + // waiting time depends on the distance + } + Abstand = sensor.getDistance_mm(); + timer.stop(); + wait_ms(500 - timer.read_ms()); // time the loop + } \ No newline at end of file
diff -r 000000000000 -r f3ae37b05bfb main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Feb 23 18:50:57 2022 +0000 @@ -0,0 +1,36 @@ +/* mbed BuschA + */ +#include "mbed.h" +#include "HCSR04.h" //US-Sensor Abstand +#include "UP_US_Sensor.h" + + +lcd mylcd; +PwmOut M1_PWM(D9); +DigitalOut M1_DIR(D7); +HCSR04 sensor(D2, D4); //Echo, Trigger Pin +float Abstand; + +int main() +{ + sensor.setRanges(10, 110); + sensor.getMinRange(), sensor.getMaxRange()); + + while (1) + { + + Abstandsmessung(); //Abstand in cm + + switch (Abstand) + { + case 50: Ausgabe_LCD(0.1); break; + case 100: Ausgabe_LCD(0.3); break; + case 150: Ausgabe_LCD(0.5); break; + case 200: Ausgabe_LCD(0.7); break; + case 250: Ausgabe_LCD(0.9); break; + case 300: Ausgabe_LCD(0.9); break; + } + + } + thread_sleep_for(200); //Sleep = Warten... +} \ No newline at end of file
diff -r 000000000000 -r f3ae37b05bfb mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Wed Feb 23 18:50:57 2022 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#b1796dedeb8accde1cbaecf136fab96895e23d81
diff -r 000000000000 -r f3ae37b05bfb resources/official_armmbed_example_badge.png Binary file resources/official_armmbed_example_badge.png has changed