Advertisement
Guest User

NEEKEIRRR

a guest
May 21st, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. import FA
  2. import time
  3.  
  4. def main():
  5. try:
  6. robotti = FA.Create()
  7. robotti.ComOpen(5)
  8. robotti.LCDBacklight(80)
  9. sivu = 1
  10. x = 0
  11. y = 0
  12. while True:
  13. sw1 = robotti.ReadSwitch(0)
  14. sw2 = robotti.ReadSwitch(1)
  15. if sw1 > x:
  16. sivu = sivu + 1
  17. x = sw1
  18. if sw2 > y:
  19. sivu = sivu -1
  20. y = sw2
  21. if sivu > 3:
  22. sivu = 1
  23. if sivu < 1:
  24. sivu = 3
  25. if sivu == 1:
  26. light_level = robotti.ReadLight()
  27. robotti.LCDClear()
  28. robotti.LCDPrint(28, 0, "Light Sensor")
  29. robotti.LCDLine(0, 9, 127, 9)
  30. robotti.LCDNumber(52, 11, light_level)
  31. robotti.LCDLine(0, 19, 127, 19)
  32. if sivu == 2:
  33. sensor = robotti.ReadIR(2)
  34. robotti.LCDClear()
  35. robotti.LCDPrint(19, 0, "Distance Sensor")
  36. robotti.LCDLine(0, 9, 127, 9)
  37. robotti.LCDNumber(52, 11, sensor)
  38. robotti.LCDLine(0, 19, 127, 19)
  39. if sivu == 3:
  40. vasen = robotti.ReadLine(0)
  41. oikea = robotti.ReadLine(1)
  42. robotti.LCDClear()
  43. robotti.LCDPrint(28, 0, "Line Sensor")
  44. robotti.LCDLine(0, 9, 127, 9)
  45. robotti.LCDLine(64, 9, 64, 31)
  46. robotti.LCDNumber(26, 12, oikea)
  47. robotti.LCDNumber(84, 12, vasen)
  48.  
  49. finally:
  50. robotti.ComClose()
  51. if __name__ == "__main__":
  52. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement