Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1.  
  2. #if 1
  3. //ultrasonic sensor//
  4. void zmain(void)
  5. {
  6. Ultra_Start(); // Ultra Sonic Start function
  7. motor_start();
  8. motor_forward(0,0);
  9. vTaskDelay(1000);
  10. while(1) {
  11. int d = Ultra_GetDistance();
  12. // Print the detected distance (centimeters)
  13. printf("distance = %d\r\n", d);
  14.  
  15. motor_forward(100,0);
  16. if(d<13){
  17.  
  18. motor_backward(100,1000);
  19. Beep(1000,100);
  20. PWM_WriteCompare1(20);
  21. PWM_WriteCompare2(100);
  22. vTaskDelay(1000);
  23. }
  24. vTaskDelay(100);
  25. }
  26. }
  27. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement