Advertisement
Guest User

servo

a guest
Oct 21st, 2014
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. $regfile = "attiny13a.dat"
  2. $crystal = 9600000
  3. $hwstack = 10
  4. $swstack = 10
  5. $framesize = 28
  6. Config Adc = Single , Prescaler = Auto
  7. Config Servos = 1 , Servo1 = Portb.0 , Reload = 6
  8. Start Adc
  9.  
  10. Enable Interrupts
  11.  
  12. Config Portb.0 = Output
  13. Config Pinb.2 = Input
  14.  
  15.  
  16. Dim W As Word , Posa As Integer , Timetowait As Integer , Modee As Integer
  17. Posa = 44
  18. Servo(1) = Posa
  19. Modee = 0
  20. W = Getadc(1)
  21. If W < 20 Then
  22. Modee = 1
  23. End If
  24. Wait 2
  25. Do
  26. While Modee = 1
  27. W = Getadc(1) / 5
  28. W = W + 44
  29. If W < 44 Then
  30. W = 44
  31. End If
  32. If 208 < W Then
  33. W = 208
  34. endif
  35. Posa = W
  36. Servo(1) = Posa
  37. Waitms 10
  38. Wend
  39. While Modee = 0
  40. While Posa < 208
  41. W = Getadc(1)
  42. W = W * 13
  43. Posa = Posa + 1
  44. Servo(1) = Posa
  45. Waitms W
  46. Wend
  47. Wend
  48. Loop
  49.  
  50.  
  51. End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement