140_robot_H_Bridge8835_DIR_PWM_US_LCD
Dependencies: HCSR04 LCD_i2C_JDS
main.cpp
- Committer:
- itbusch
- Date:
- 2022-02-23
- Revision:
- 0:7f52b9bd4591
File content as of revision 0:7f52b9bd4591:
/* 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... }