Beispiel #1
0
import sys
from time import sleep
from Robot import Robot
from Mover import Mover
from Shooter import Shooter
from Light import Light
from Sonar import Sonar
from nxt.motor import PORT_A, PORT_B, PORT_C
from nxt.sensor import PORT_4, PORT_3, PORT_2, PORT_1

robot = Robot('ICTCLUB2')
robot.extend(Mover(PORT_C, PORT_B))
robot.extend(Light(PORT_3))
robot.extend(Sonar(PORT_1))

# Program start

# start turning left at power = 10%
robot.startturningleft(10)

# every 0.5 seconds print out how far nearest item is while nearest item is > 100cm away
while robot.howfar() > 100:
  print robot.howfar()
  sleep(0.5)

# Something is < 100cm away so stop and shine the red light
print "Intruder"
robot.stopmoving()
robot.lightred()
sleep(5)
Beispiel #2
0
import sys
from time import sleep
from Robot import Robot
from Mover import Mover
from Shooter import Shooter
from Light import Light
from Sonar import Sonar
from nxt.motor import PORT_A, PORT_B, PORT_C
from nxt.sensor import PORT_4, PORT_3, PORT_2, PORT_1


print "Robot"
robot = Robot('ICTCLUB6')
robot.extend(Light(PORT_3))
robot.extend(Mover(PORT_B, PORT_C))
robot.extend(Sonar(PORT_1))

for x in range(1,100):
	print robot.howfar()
	sleep(0.1)

robot.__del__()
Beispiel #3
0
import sys
from time import sleep
from Robot import Robot
from Mover import Mover
from Shooter import Shooter
from Light import Light
from Sonar import Sonar
from nxt.motor import PORT_A, PORT_B, PORT_C
from nxt.sensor import PORT_4, PORT_3, PORT_2, PORT_1

print "Robot2"
robot = Robot('ICTCLUB2')
robot.extend(Light(PORT_3))

i = 0
while i < 60 :
  robot.lightred()
  sleep(1)
  robot.lightblue()
  sleep(1)
  i=i+1
robot.lightoff()
robot.__del__()
Beispiel #4
0
import sys
import curses
from time import sleep
from Robot import Robot
from Mover import Mover
from Shooter import Shooter
from Light import Light
from Sonar import Sonar
from nxt.motor import PORT_A, PORT_B, PORT_C
from nxt.sensor import PORT_4, PORT_3

from pygame.locals import *
from Keyboard import KeyboardController

robot = Robot('ICTCLUB4')
robot.extend(Mover(PORT_C, PORT_B))
robot.extend(Light(PORT_4))
robot.extend(Sonar(PORT_3))
robot.extend(Shooter(PORT_A))

def forward():
    robot.forward(2,99)
    
def stop():
    print 'stop'
    
def shoot():
    robot.shoot()
    
def turnleft():
    robot.startturningleft(30)
import sys
from time import sleep
from Robot import Robot
from RemoteControl import RemoteControl
from nxt.motor import PORT_A, PORT_B, PORT_C
from nxt.sensor import PORT_4, PORT_3, PORT_2, PORT_1

robot = Robot('ICTCLUB2')
robot.extend(RemoteControl(PORT_1,1))

# Program start

while 1==1 :
  print str(robot.red()) + "," + str(robot.blue())

robot.__del__()
Beispiel #6
0
import sys
from time import sleep
from Robot import Robot
from Mover import Mover
from Shooter import Shooter
from Light import Light
from Sonar import Sonar
from nxt.motor import PORT_A, PORT_B, PORT_C
from nxt.sensor import PORT_4, PORT_3, PORT_2, PORT_1

print "Robot3"
robot = Robot('ICTCLUB3')
robot.extend(Mover(PORT_B, PORT_C))

robot.forwards(20,200)
robot.turnright(5,50)
robot.turnleft(5,50)
robot.forwards(5,50)