140_robot_H_Bridge8835_DIR_PWM_US_LCD
Dependencies: HCSR04 LCD_i2C_JDS
Revision 0:7f52b9bd4591, committed 2022-02-23
- Comitter:
- itbusch
- Date:
- Wed Feb 23 18:53:14 2022 +0000
- Commit message:
- 140_robot_H_Bridge8835_DIR_PWM_US_LCD
Changed in this revision
diff -r 000000000000 -r 7f52b9bd4591 HCSR04.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HCSR04.lib Wed Feb 23 18:53:14 2022 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/TVZ-Mechatronics-Team/code/HCSR04/#cf3e4e307d15
diff -r 000000000000 -r 7f52b9bd4591 LCD_Bua.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LCD_Bua.h Wed Feb 23 18:53:14 2022 +0000 @@ -0,0 +1,11 @@ +lcd mylcd; +PwmOut M1_PWM(D9); +DigitalOut M1_DIR(D7); + +void Ausgabe_LCD (Abstand) +{ + mylcd.cursorpos(0x00); + mylcd.printf(" Hallo robot"); + mylcd.cursorpos(0x40); + mylcd.printf("Distanz: %3d", Abstand); +} \ No newline at end of file
diff -r 000000000000 -r 7f52b9bd4591 LCD_i2C_JDS.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LCD_i2C_JDS.lib Wed Feb 23 18:53:14 2022 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/itbusch/code/LCD_i2C_JDS/#68d6c4c092fb
diff -r 000000000000 -r 7f52b9bd4591 UP_US_Sensor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UP_US_Sensor.h Wed Feb 23 18:53:14 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(); + + } \ No newline at end of file
diff -r 000000000000 -r 7f52b9bd4591 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Feb 23 18:53:14 2022 +0000 @@ -0,0 +1,39 @@ +/* mbed BuschA + */ + +#include "mbed.h" +#include "HCSR04.h" //US-Sensor Abstand +#include "UP_US_Sensor.h" +#include "LCD.h" +#include "LCD_Bua.h" + +DigitalIn CableSwitch(D2); //PullUp auf Board, PA_10 +PwmOut M1_PWM(D9); +DigitalOut M1_DIR(D7); + +int main() +{ + sensor.setRanges(10, 110); + sensor.getMinRange(), sensor.getMaxRange(); + M1_PWM.period_ms(10); // PWM-Periode + M1_DIR = 1; // Vorwärts... + M1_PWM = 0.8; //Start-Speed + + while (1) + { + + Abstandsmessung(); //Abstand in cm + + switch (Abstand) + { + case 50: M1_PWM = 0.1; break; + case 100: M1_PWM = 0.3; break; + case 150: M1_PWM = 0.5; break; + case 200: M1_PWM = 0.7; break; + case 250: M1_PWM = 0.9; break; + case 300: M1_PWM = 1.0; break; + } + + } + thread_sleep_for(200); //Sleep = Warten... +} \ No newline at end of file
diff -r 000000000000 -r 7f52b9bd4591 mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Wed Feb 23 18:53:14 2022 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#b1796dedeb8accde1cbaecf136fab96895e23d81
diff -r 000000000000 -r 7f52b9bd4591 resources/official_armmbed_example_badge.png Binary file resources/official_armmbed_example_badge.png has changed