Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if 1
- //ultrasonic sensor//
- void zmain(void)
- {
- Ultra_Start(); // Ultra Sonic Start function
- motor_start();
- motor_forward(0,0);
- vTaskDelay(1000);
- while(1) {
- int d = Ultra_GetDistance();
- // Print the detected distance (centimeters)
- printf("distance = %d\r\n", d);
- motor_forward(100,0);
- if(d<13){
- motor_backward(100,1000);
- Beep(1000,100);
- PWM_WriteCompare1(20);
- PWM_WriteCompare2(100);
- vTaskDelay(1000);
- }
- vTaskDelay(100);
- }
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement