Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import FA
- import time
- def main():
- try:
- robotti = FA.Create()
- robotti.ComOpen(5)
- robotti.LCDBacklight(80)
- sivu = 1
- x = 0
- y = 0
- while True:
- sw1 = robotti.ReadSwitch(0)
- sw2 = robotti.ReadSwitch(1)
- if sw1 > x:
- sivu = sivu + 1
- x = sw1
- if sw2 > y:
- sivu = sivu -1
- y = sw2
- if sivu > 3:
- sivu = 1
- if sivu < 1:
- sivu = 3
- if sivu == 1:
- light_level = robotti.ReadLight()
- robotti.LCDClear()
- robotti.LCDPrint(28, 0, "Light Sensor")
- robotti.LCDLine(0, 9, 127, 9)
- robotti.LCDNumber(52, 11, light_level)
- robotti.LCDLine(0, 19, 127, 19)
- if sivu == 2:
- sensor = robotti.ReadIR(2)
- robotti.LCDClear()
- robotti.LCDPrint(19, 0, "Distance Sensor")
- robotti.LCDLine(0, 9, 127, 9)
- robotti.LCDNumber(52, 11, sensor)
- robotti.LCDLine(0, 19, 127, 19)
- if sivu == 3:
- vasen = robotti.ReadLine(0)
- oikea = robotti.ReadLine(1)
- robotti.LCDClear()
- robotti.LCDPrint(28, 0, "Line Sensor")
- robotti.LCDLine(0, 9, 127, 9)
- robotti.LCDLine(64, 9, 64, 31)
- robotti.LCDNumber(26, 12, oikea)
- robotti.LCDNumber(84, 12, vasen)
- finally:
- robotti.ComClose()
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement