Esempio n. 1
0
def main():
	Bob=Tortoise()
	while True:
		if Bob.getSensorData(SensorType.light,1)<4:
			Bob.doRandomStep()
			print "where are you?"
		elif Bob.getSensorData(SensorType.light,1)<9:
			Bob.moveForward(30)
			print "ah-ha!"
		else :
			Bob.moveBackward(30)
			print "Burning burning!"
Esempio n. 2
0
def main():
	Mike = Tortoise()

	while True:
		if Mike.getSensorData(SensorType.light, 1) < 6:
			Mike.doRandomStep()
			print "Where's the light?"
		elif 6<= Mike.getSensorData(SensorType.light, 1)  and Mike.getSensorData(SensorType.light, 1) <9:
			print "Found Light"
			Mike.moveForward(30)	
		else: 
			print "Argh! Too much light!"
			Mike.moveBackward(30)
Esempio n. 3
0
def main():
    Mike = Tortoise()

    while True:
        if Mike.getSensorData(SensorType.light, 1) < 6:
            Mike.doRandomStep()
            print "Where's the light?"
        elif 6 <= Mike.getSensorData(SensorType.light,
                                     1) and Mike.getSensorData(
                                         SensorType.light, 1) < 9:
            print "Found Light"
            Mike.moveForward(30)
        else:
            print "Argh! Too much light!"
            Mike.moveBackward(30)
Esempio n. 4
0
# Name your tortoise here.
Name = Tortoise()

if (calibrated == 0):
    print "Let's use different levels of light to see what calibrated readings we get"
    raw_input(
        "First let's see what the room gives us, press enter when you're done")
    print Name.getSensorData(SensorType.light, 1)
    raw_input(
        "Now try it with a light source right up close and press enter when you're done"
    )
    print Name.getSensorData(SensorType.light, 1)
    raw_input("And now try somewhere in the middle")
    print Name.getSensorData(SensorType.light, 1)

while True and (calibrated == 1):
    # First we need a reading from the light sensor
    lightSensorReading = Name.getSensorData(SensorType.light, 1)

    # Can you tune the light sensor values for the conditions based on your calibration findings?
    if lightSensorReading < 1:
        Name.moveForward(30, Direction)
        print "Where's the light?"
    elif 1 <= lightSensorReading and lightSensorReading < 2:
        print "Found the light!"
        Name.moveBackward(30)
    else:
        print "Argh! Too much light!"
        Name.doRandomStep()
Esempio n. 5
0
# Change this to 1 when you've calibrated and have some values for not enough light, good light and too much light.
calibrated = 0;

# Name your tortoise here.
Name = Tortoise()

if (calibrated==0):
	print "Let's use different levels of light to see what calibrated readings we get"
	raw_input("First let's see what the room gives us, press enter when you're done")
	print Name.getSensorData(SensorType.light,1)
	raw_input("Now try it with a light source right up close and press enter when you're done")
	print Name.getSensorData(SensorType.light,1)
	raw_input("And now try somewhere in the middle")
	print Name.getSensorData(SensorType.light,1)

while True and (calibrated==1):
	# First we need a reading from the light sensor
	lightSensorReading = Name.getSensorData(SensorType.light,1)
	
	# Can you tune the light sensor values for the conditions based on your calibration findings?
	if lightSensorReading < 1:
		Name.moveForward(30, Direction)
		print "Where's the light?"
	elif 1<= lightSensorReading  and lightSensorReading <2:
		print "Found the light!"
		Name.moveBackward(30)	
	else: 
		print "Argh! Too much light!"
		Name.doRandomStep()
Esempio n. 6
0

# Name your tortoise here.
Frankie = Tortoise()

if (calibrated==0):
	print "Let's use different levels of light to see what calibrated readings we get"
	raw_input("First let's see what the room gives us, press enter when you're done")
	print Frankie.getSensorData(SensorType.light,1)
	raw_input("Now try it with a light source right up close and press enter when you're done")
	print Frankie.getSensorData(SensorType.light,1)
	raw_input("And now try somewhere in the middle")
	print Frankie.getSensorData(SensorType.light,1)

while True and (calibrated==1):
	# First we need a reading from the light sensor
	lightSensorReading = Frankie.getSensorData(SensorType.light, 1)

	# Can you tune the light sensor values for the conditions based on your calibration findings?
	if lightSensorReading < 4:
		Frankie.doRandomStep()
		print "Where's the light?"
	elif 4<= lightSensorReading  and lightSensorReading <9:
		# What should we be printing here?
		print "I am a happy turtle"
		Frankie.moveForward(30)	
	else: 
		print "Argh! Too much light!"
		# So your tortoise has found too much light. How should they move now?
		Frankie.moveBackward(30)