140_robot_H_Bridge8835_DIR_PWM_US_LCD
Dependencies: HCSR04 LCD_i2C_JDS
UP_US_Sensor.h@0:7f52b9bd4591, 2022-02-23 (annotated)
- Committer:
- itbusch
- Date:
- Wed Feb 23 18:53:14 2022 +0000
- Revision:
- 0:7f52b9bd4591
140_robot_H_Bridge8835_DIR_PWM_US_LCD
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
itbusch | 0:7f52b9bd4591 | 1 | Timer timer; |
itbusch | 0:7f52b9bd4591 | 2 | HCSR04 sensor(D2, D4); //Echo, Trugger Pin |
itbusch | 0:7f52b9bd4591 | 3 | float Abstand; |
itbusch | 0:7f52b9bd4591 | 4 | |
itbusch | 0:7f52b9bd4591 | 5 | void Abstandsmessung (void) |
itbusch | 0:7f52b9bd4591 | 6 | { |
itbusch | 0:7f52b9bd4591 | 7 | timer.reset(); |
itbusch | 0:7f52b9bd4591 | 8 | timer.start(); |
itbusch | 0:7f52b9bd4591 | 9 | sensor.startMeasurement(); |
itbusch | 0:7f52b9bd4591 | 10 | while(!sensor.isNewDataReady()) { |
itbusch | 0:7f52b9bd4591 | 11 | // wait for new data |
itbusch | 0:7f52b9bd4591 | 12 | // waiting time depends on the distance |
itbusch | 0:7f52b9bd4591 | 13 | } |
itbusch | 0:7f52b9bd4591 | 14 | Abstand = sensor.getDistance_mm(); |
itbusch | 0:7f52b9bd4591 | 15 | timer.stop(); |
itbusch | 0:7f52b9bd4591 | 16 | |
itbusch | 0:7f52b9bd4591 | 17 | } |