def main():
    wanderer = Tortoise()

    while True:

        proximitySensor_1 = wanderer.getSensorData(enums.SensorType.proximity, 1)
        proximitySensor_2 = wanderer.getSensorData(enums.SensorType.proximity, 2)
        proximitySensor_3 = wanderer.getSensorData(enums.SensorType.proximity, 3)
        proximitySensor_4 = wanderer.getSensorData(enums.SensorType.proximity, 4)

        if proximitySensor_1 == 1:
                print "Proximity sensor 1 is ON"
        else:
                print "Proximity sensor 1 is OFF"

        if proximitySensor_2 == 1:
                print "Proximity sensor 2 is ON"
        else:
                print "Proximity sensor 2 is OFF"

        if proximitySensor_3 == 1:
                print "Proximity sensor 3 is ON"
        else:
                print "Proximity sensor 3 is OFF"

        if proximitySensor_4 == 1:
                print "Proximity sensor 4 is ON"
        else:
                print "Proximity sensor 4 is OFF"

        print

        time.sleep(1)
Esempio n. 2
0
def main():
    wanderer = Tortoise()

    while True:

        touchSensor_1 = wanderer.getSensorData(enums.SensorType.touch, 1)
        touchSensor_2 = wanderer.getSensorData(enums.SensorType.touch, 2)
        touchSensor_3 = wanderer.getSensorData(enums.SensorType.touch, 3)

        if touchSensor_1 == 1:
            print "Switch 1 is on"
        else:
            print "Switch 1 is off"

        if touchSensor_2 == 1:
            print "Switch 2 is on"
        else:
            print "Switch 2 is off"

        if touchSensor_3 == 1:
            print "Switch 3 is on"
        else:
            print "Switch 3 is off"

        print

        time.sleep(1)
Esempio n. 3
0
def main():
    wanderer = Tortoise()

    while True:

        touchSensor_1 = wanderer.getSensorData(enums.SensorType.touch, 1)
        touchSensor_2 = wanderer.getSensorData(enums.SensorType.touch, 2)
        touchSensor_3 = wanderer.getSensorData(enums.SensorType.touch, 3)

        if touchSensor_1 == 1:
                print "Switch 1 is on"
        else:
                print "Switch 1 is off"

        if touchSensor_2 == 1:
                print "Switch 2 is on"
        else:
                print "Switch 2 is off"

        if touchSensor_3 == 1:
                print "Switch 3 is on"
        else:
                print "Switch 3 is off"

        print

        time.sleep(1)
Esempio n. 4
0
def main():
    wanderer = Tortoise()

    while True:
        #pass
        wanderer.moveForward(100)
        print wanderer.getSensorData(enums.SensorType.light, 1)
Esempio n. 5
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. 6
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. 7
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. 8
0
def main():
    wanderer = Tortoise()

    while True:
        #print "Light 1: " + str(wanderer.getSensorData(enums.SensorType.light, 1))
        print "Light 2: " + str(wanderer.getSensorData(enums.SensorType.light, 2))
        #print
        time.sleep(0.5)
def main():
    wanderer = Tortoise()

    while True:
        #pass
        wanderer.moveForward(100)
        #print wanderer.getSensorData(enums.SensorType.light, 1)
        if wanderer.getSensorData(enums.SensorType.emergencySwitch, 1) == 1:
                        #print "1"
	        wanderer.setActuatorValue(enums.ActuatorType.led, 1,1)
        else:
                        #print "0"
	        wanderer.setActuatorValue(enums.ActuatorType.led, 1,0)
Esempio n. 10
0
def main():
    wanderer = Tortoise()

    while True:
        #pass
        wanderer.moveForward(100)
        #print wanderer.getSensorData(enums.SensorType.light, 1)
        if wanderer.getSensorData(enums.SensorType.emergencySwitch, 1) == 1:
            #print "1"
            wanderer.setActuatorValue(enums.ActuatorType.led, 1, 1)
        else:
            #print "0"
            wanderer.setActuatorValue(enums.ActuatorType.led, 1, 0)
Esempio n. 11
0
def main():
    wanderer = Tortoise()

    while True:

        proximitySensor_1 = wanderer.getSensorData(enums.SensorType.proximity,
                                                   1)
        proximitySensor_2 = wanderer.getSensorData(enums.SensorType.proximity,
                                                   2)
        proximitySensor_3 = wanderer.getSensorData(enums.SensorType.proximity,
                                                   3)
        proximitySensor_4 = wanderer.getSensorData(enums.SensorType.proximity,
                                                   4)

        if proximitySensor_1 == 1:
            print "Proximity sensor 1 is ON"
        else:
            print "Proximity sensor 1 is OFF"

        if proximitySensor_2 == 1:
            print "Proximity sensor 2 is ON"
        else:
            print "Proximity sensor 2 is OFF"

        if proximitySensor_3 == 1:
            print "Proximity sensor 3 is ON"
        else:
            print "Proximity sensor 3 is OFF"

        if proximitySensor_4 == 1:
            print "Proximity sensor 4 is ON"
        else:
            print "Proximity sensor 4 is OFF"

        print

        time.sleep(1)
def main():
    wanderer = Tortoise()

    while True:

        proximitySensor_1 = wanderer.getSensorData(enums.SensorType.proximity, 4)

        if proximitySensor_1 == 1:
                print "Proximity sensor 1 is ON"
        else:
                print "Proximity sensor 1 is OFF"

        print

        time.sleep(0.1)
def main():
    wanderer = Tortoise()

    while True:

        proximitySensor_1 = wanderer.getSensorData(enums.SensorType.proximity,
                                                   4)

        if proximitySensor_1 == 1:
            print "Proximity sensor 1 is ON"
        else:
            print "Proximity sensor 1 is OFF"

        print

        time.sleep(0.1)
Esempio n. 14
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType
import random

Cora = Tortoise()

learnAssoc = 0.0
assocFlag = 0

while True:

    Cora.setLEDValue(1, 0)
    responseFlag = 0

    responseSensor = Cora.getSensorData(SensorType.touch, 1)
    stimulusSensor = Cora.getSensorData(SensorType.touch, 2)

    print "Resp=%f stim=%f learn=%f assoc=%f" % (
        responseSensor, stimulusSensor, learnAssoc, assocFlag)

    # response always triggered by main sensor
    if responseSensor == 1:
        responseFlag = 1

    if stimulusSensor == 1:
        # update accumulator
        if responseSensor == 1:
            learnAssoc = 0.6 * learnAssoc + 0.4
            Cora.setLEDValue(1, 1)
        else:
            learnAssoc = 0.75 * learnAssoc
Esempio n. 15
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Name=Tortoise()

while True:

    touchSensor = Name.getSensorData(SensorType.touch,1)
    print "Front switch is:" 
    print touchSensor
    touchSensor2 = Name.getSensorData(SensorType.touch,3)
    print "Back switch is: " 
    print touchSensor2
    if touchSensor == 1:
        print "Switch is on"
        Name.moveBackwards(30)
        Name.setLEDValue(1, 1) #self.setLEDValue(position, value)
        Name.setLEDValue(2, 0) #self.setLEDValue(position, value)
	touchSensor2Loop = Name.getSensorData(SensorType.touch,3)
	print "Back switch as read inside loop: " 
        print touchSensor2Loop
	if touchSensor2 == 1:
		print "Back switch has been hit"
		Name.moveForwards(30)
		Name.setLEDValue(2, 0) #self.setLEDValue(position, value)
		if touchSensor == 0:
			break
   # else:
        #print "Switch is off"
        #Name.moveForwards(30)
        #Name.setLEDValue(1, 0) #self.setLEDValue(position, value)
Esempio n. 16
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Name=Tortoise()

while True:

    touchSensor = Name.getSensorData(SensorType.touch,1)
    if touchSensor == 1:
        print "Switch is on"
        Name.moveForwards(30)
        Name.setLEDValue(1, 1) #self.setLEDValue(position, value)
    else:
        print "Switch is off"
        Name.setLEDValue(1, 0) #self.setLEDValue(position, value)
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Name=Tortoise()

while True:

    proxSensor = Name.getSensorData(SensorType.proximity,1)
    proxSensor2 = Name.getSensorData(SensorType.proximity,2)
    if proxSensor == 1 and proxSensor2 == 0:
        print "Obstacle detected in front"
        Name.setLEDValue(1, 1) #self.setLEDValue(position, value)
    	Name.setLEDValue(2, 0) #self.setLEDValue(position, value)
    	Name.moveBackwards(100)
    if proxSensor == 1 and proxSensor2 == 1:
    	print "Obstacles detected in front and behind!"
    	Name.setLEDValue(1, 1) #self.setLEDValue(position, value)
   	Name.setLEDValue(2, 1) #self.setLEDValue(position, value)
    if proxSensor == 0 and proxSensor2 == 1:
        print "Obstacle detected behind"
        Name.setLEDValue(1, 0) #self.setLEDValue(position, value)
    	Name.setLEDValue(2, 1) #self.setLEDValue(position, value)
    	Name.moveForwards(100)
    else:
        print "No obstacle detected"
        Name.doRandomMovement()
        Name.setLEDValue(1, 0) #self.setLEDValue(position, value)
   	Name.setLEDValue(2, 0) #self.setLEDValue(position, value)
Esempio n. 18
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Elsie=Tortoise()

while True:

    proxSensor = Elsie.getSensorData(SensorType.proximity,2)
    if proxSensor == 1:
        print "Obstacle detected behind"
        Elsie.setLEDValue(1, 1) #self.setLEDValue(position, value)
	Elsie.moveForwards(150)
    else:
        print "No obstacle detected"
        Elsie.setLEDValue(1, 0) #self.setLEDValue(position, value)
        Elsie.doRandomMovement()
Esempio n. 19
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Name = Tortoise()

lastFrontSwitch = 0
lastBackSwitch = 0

while True:
    currentFrontSwitch = Name.getSensorData(SensorType.touch, 3)
    currentBackSwitch = Name.getSensorData(SensorType.touch, 1)

    forwards = abs(lastBackSwitch - currentBackSwitch)
    backwards = abs(lastFrontSwitch - currentFrontSwitch)

    if forwards == 1 and backwards == 0:
        lastFrontSwitch = currentFrontSwitch
        print "Moving forwards"
        Name.moveForwards(5)

    if backwards == 1 and forwards == 0:
        lastbackSwitch = currentBackSwitch
        print "Moving backwards"
        Name.moveBackwards(5)
    else:
        print "No switches on"
Esempio n. 20
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Elsie = Tortoise()

while True:

    proxSensor = Elsie.getSensorData(SensorType.proximity, 2)

    if proxSensor == 1:

        print "Obstacle detected behind"
        Elsie.setLEDValue(2, 1)  #self.setLEDValue(position, value)
        Elsie.moveForwards(150)

    else:

        print "No obstacle detected"
        Elsie.setLEDValue(2, 0)  #self.setLEDValue(position, value)
        Elsie.doRandomMovement()
Esempio n. 21
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

# F  B 
# 0  0  move forwards
# 1  0  move backwards
# 1  1  move forwards
# 0  1  move backwards

Name=Tortoise()

while True:

    forwardSwitch = Name.getSensorData(SensorType.touch, 1)
    backwardSwitch = Name.getSensorData(SensorType.touch, 2)
#    if (forwardSwitch == backwardSwitch):
    if (forwardSwitch == 0 and backwardSwitch == 0) or (forwardSwitch == 1 and backwardSwitch == 1):
	print "monkey"
	if forwardSwitch == 1:
                print "Switch 1 is on"
        else:
                print "Switch 1 is off"

        if backwardSwitch == 1:
                print "Switch 2 is on"
        else:
                print "Switch 2 is off"

	print " "
        Name.moveForwards(100)
        Name.setLEDValue(1, 1) #self.setLEDValue(position, value)
Esempio n. 22
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType
import random

Cora=Tortoise()

learnAssoc = 0.0
assocFlag = 0

while True:

    Cora.setLEDValue(1, 0) 
    responseFlag = 0

    responseSensor = Cora.getSensorData(SensorType.touch,1)
    stimulusSensor = Cora.getSensorData(SensorType.touch,2)

    print "Resp=%f stim=%f learn=%f assoc=%f" % (responseSensor,stimulusSensor,learnAssoc,assocFlag)

    # response always triggered by main sensor
    if responseSensor == 1:
        responseFlag = 1

    if stimulusSensor == 1:
        # update accumulator
        if responseSensor == 1:
            learnAssoc = 0.6*learnAssoc + 0.4
            Cora.setLEDValue(1, 1) 
        else:
            learnAssoc = 0.75*learnAssoc
        # check association thresholds
Esempio n. 23
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Grey = Tortoise()

while True:

    touchSensor = Grey.getSensorData(SensorType.touch, 1)

    if touchSensor == 1:

        print "Switch is on"
        Grey.setLEDValue(1, 1)  #self.setLEDValue(position, value)
        Grey.moveForwards(50)

    else:

        print "Switch is off"
        Grey.setLEDValue(1, 0)  #self.setLEDValue(position, value)
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Name=Tortoise()

lastFrontSwitch = 0
lastBackSwitch = 0

while True:
	currentFrontSwitch = Name.getSensorData(SensorType.touch,3)
	currentBackSwitch = Name.getSensorData(SensorType.touch,1)
    
	forwards = abs(lastBackSwitch - currentBackSwitch)
	backwards = abs(lastFrontSwitch - currentFrontSwitch)

	if forwards==1 and backwards==0:
		lastFrontSwitch=currentFrontSwitch
		print "Moving forwards"
        	Name.moveForwards(5)
		
	if backwards ==1 and forwards==0:
		lastbackSwitch=currentBackSwitch
		print "Moving backwards"
		Name.moveBackwards(5)
	else:
		print "No switches on"

Esempio n. 25
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Elmer = Tortoise()

while True:

    proxSensor = Elmer.getSensorData(SensorType.proximity, 1)
    proxSensor2 = Elmer.getSensorData(SensorType.proximity, 2)

    if proxSensor == 1 and proxSensor2 == 0:

        print "Obstacle detected in front"
        Elmer.setLEDValue(1, 1)  #self.setLEDValue(position, value)
        Elmer.setLEDValue(2, 0)  #self.setLEDValue(position, value)
        Elmer.moveBackwards(150)

    elif proxSensor == 1 and proxSensor2 == 1:

        print "Obstacles detected in front and behind!"
        Elmer.setLEDValue(1, 1)  #self.setLEDValue(position, value)
        Elmer.setLEDValue(2, 1)  #self.setLEDValue(position, value)

    elif proxSensor == 0 and proxSensor2 == 1:

        print "Obstacle detected behind"
        Elmer.setLEDValue(1, 0)  #self.setLEDValue(position, value)
        Elmer.setLEDValue(2, 1)  #self.setLEDValue(position, value)
        Elmer.moveForwards(150)

    else:
Esempio n. 26
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

# F  B 
# 0  0  move forwards
# 1  0  move backwards
# 1  1  move forwards
# 0  1  move backwards

Walter=Tortoise()

while True:

    forwardSwitch = Walter.getSensorData(SensorType.touch, 1)
    backwardSwitch = Walter.getSensorData(SensorType.touch, 2)
#    if (forwardSwitch == backwardSwitch):
    if (forwardSwitch == 0 and backwardSwitch == 0) or (forwardSwitch == 1 and backwardSwitch == 1):
	print "Moving forwards"
	if forwardSwitch == 1:
                print "Switch 1 is on"
        else:
                print "Switch 1 is off"

        if backwardSwitch == 1:
                print "Switch 2 is on"
        else:
                print "Switch 2 is off"

	print " "
        Walter.setLEDValue(1, 1) #self.setLEDValue(position, value)
        Walter.setLEDValue(2, 0) #self.setLEDValue(position, value)
Esempio n. 27
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType
Walter=Tortoise()

lastMove = "forward"

while True:

    frontSwitch = Walter.getSensorData(SensorType.touch, 1)
    backSwitch = Walter.getSensorData(SensorType.touch, 2)

    if frontSwitch ==1 and backSwitch ==0:
        print "Obstacle in front - moving backwards"    
        Walter.setLEDValue(1, 0) #self.setLEDValue(position, value)
        Walter.setLEDValue(2, 1) #self.setLEDValue(position, value)
        Walter.moveBackwards(100)
        lastMove = "back"
    elif backSwitch ==1 and frontSwitch ==1:
        print "Can't move!"    
    elif frontSwitch ==0 and backSwitch ==1:
        print "Obstacle behind - moving forwards"    
        Walter.setLEDValue(1, 1) #self.setLEDValue(position, value)
        Walter.setLEDValue(2, 0) #self.setLEDValue(position, value)
        Walter.moveForwards(100)
        lastMove = "forward"
    else:
        print "Exploring"
        Walter.setLEDValue(1, 1) #self.setLEDValue(position, value)
        Walter.setLEDValue(2, 1) #self.setLEDValue(position, value)
	if lastMove == "forward":
	        Walter.moveForwards(100)
Esempio n. 28
0
from tortoise import Tortoise
from enums import Direction, SensorType

Name=Tortoise()

while True:

    touchSensorValue = Name.getSensorData(SensorType.touch, 1)

    if touchSensorValue == 1:

        print "Touch sensor is being pressed"
        Name.setLEDValue(1, 1)
        Name.moveForwards(50)

    else:

        print "Nothing is pressing the touch sensor"
        Name.setLEDValue(1, 0)
Esempio n. 29
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Elmer=Tortoise()

while True:

    proxSensor = Elmer.getSensorData(SensorType.proximity,1)
    proxSensor2 = Elmer.getSensorData(SensorType.proximity,2)

    if proxSensor == 1 and proxSensor2 == 0:

        print "Obstacle detected in front"
        Elmer.setLEDValue(1, 1) #self.setLEDValue(position, value)
        Elmer.setLEDValue(2, 0) #self.setLEDValue(position, value)
        Elmer.moveBackwards(150)

    elif proxSensor == 1 and proxSensor2 == 1:

        print "Obstacles detected in front and behind!"
        Elmer.setLEDValue(1, 1) #self.setLEDValue(position, value)
        Elmer.setLEDValue(2, 1) #self.setLEDValue(position, value)

    elif proxSensor == 0 and proxSensor2 == 1:

        print "Obstacle detected behind"
        Elmer.setLEDValue(1, 0) #self.setLEDValue(position, value)
        Elmer.setLEDValue(2, 1) #self.setLEDValue(position, value)
        Elmer.moveForwards(150)

    else:
Esempio n. 30
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType
Walter=Tortoise()

lastMove = "forward"

while True:

    frontSwitch = Walter.getSensorData(SensorType.touch, 1)
    backSwitch = Walter.getSensorData(SensorType.touch, 2)

    if frontSwitch ==1 and backSwitch ==0:

        print "Obstacle in front - moving backwards"    
        Walter.setLEDValue(1, 0) #self.setLEDValue(position, value)
        Walter.setLEDValue(2, 1) #self.setLEDValue(position, value)
        lastMove = "back"

    elif backSwitch ==1 and frontSwitch ==1:

        print "Can't move!"    

    elif frontSwitch ==0 and backSwitch ==1:

        print "Obstacle behind - moving forwards"    
        Walter.setLEDValue(1, 1) #self.setLEDValue(position, value)
        Walter.setLEDValue(2, 0) #self.setLEDValue(position, value)
        lastMove = "forward"

    else:
        print "Exploring"
Esempio n. 31
0
from tortoise import Tortoise
from enums import Direction, SensorType

#In this version they fix the values and fill in the else.

# Change this to 1 when you've calibrated and have some values for not enough light, good light and too much light.
calibrated = 1;


# 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?
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

# F  B
# 0  0  move forwards
# 1  0  move backwards
# 1  1  move forwards
# 0  1  move backwards

Name = Tortoise()

while True:

    forwardSwitch = Name.getSensorData(SensorType.proximity, 1)
    backwardSwitch = Name.getSensorData(SensorType.proximity, 2)
    #    if (forwardSwitch == backwardSwitch):
    if (forwardSwitch == 0
            and backwardSwitch == 0) or (forwardSwitch == 1
                                         and backwardSwitch == 1):
        print "monkey"
        if forwardSwitch == 1:
            print "Switch 1 is on"
        else:
            print "Switch 1 is off"

        if backwardSwitch == 1:
            print "Switch 2 is on"
        else:
            print "Switch 2 is off"

        print " "
Esempio n. 33
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Grey = Tortoise()

while True:

    touchSensor = Grey.getSensorData(SensorType.touch, 1)

    if touchSensor == 1:

        print "Switch is on"
        Grey.setLEDValue(1, 1)  # self.setLEDValue(position, value)
        Grey.moveForwards(50)

    else:

        print "Switch is off"
        Grey.setLEDValue(1, 0)  # self.setLEDValue(position, value)
Esempio n. 34
0
from tortoise import Tortoise
from enums import Direction, SensorType
# In this version, they test the robot first and then fix the values and fill in the else. If format is good, but too much work, then prefill else.

# 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: 
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

# F  B 
# 0  0  move forwards
# 1  0  move backwards
# 1  1  move forwards
# 0  1  move backwards

Name=Tortoise()

while True:

    forwardSwitch = Name.getSensorData(SensorType.proximity, 1)
    backwardSwitch = Name.getSensorData(SensorType.proximity, 2)
#    if (forwardSwitch == backwardSwitch):
    if (forwardSwitch == 0 and backwardSwitch == 0) or (forwardSwitch == 1 and backwardSwitch == 1):
	print "monkey"
	if forwardSwitch == 1:
                print "Switch 1 is on"
        else:
                print "Switch 1 is off"

        if backwardSwitch == 1:
                print "Switch 2 is on"
        else:
                print "Switch 2 is off"

	print " "
        Name.moveForwards(30)
        Name.setLEDValue(1, 1) #self.setLEDValue(position, value)
Esempio n. 36
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Dennis=Tortoise()

while True:

    Dennis.setLEDValue(1, 0)
    Dennis.setLEDValue(2, 0)

    rightSensor = Dennis.getSensorData(SensorType.proximity,1)
    leftSensor = Dennis.getSensorData(SensorType.proximity,2)

    if rightSensor == 1:

        print "Obstruction right"
        Dennis.setLEDValue(1, 1) 
        Dennis.turnOnTheSpot(20,Direction.backwards_right)

    elif leftSensor == 1:

        print "Obstruction left"
        Dennis.setLEDValue(2,1)
        Dennis.turnOnTheSpot(20,Direction.backwards_left)

    else:

        print "I'm wandering..."
        Dennis.moveForwards(30)

Esempio n. 37
0
from tortoise import Tortoise
from enums import Direction, SensorType

Name = Tortoise()

while True:

    touchSensorValue = Name.getSensorData(SensorType.touch, 1)

    if touchSensorValue == 1:

        print "Touch sensor is being pressed"
        Name.setLEDValue(1, 1)
        Name.moveForwards(50)

    else:

        print "Nothing is pressing the touch sensor"
        Name.setLEDValue(1, 0)
Esempio n. 38
0
from tortoise import Tortoise
from enums import Direction, SensorType
# In this version, they test the robot first and then fix the values and fill in the else. If format is good, but too much work, then prefill else.

# 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:
Esempio n. 39
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Name = Tortoise()

while True:

    touchSensor = Name.getSensorData(SensorType.touch, 1)
    print "Front switch is:"
    print touchSensor
    touchSensor2 = Name.getSensorData(SensorType.touch, 3)
    print "Back switch is: "
    print touchSensor2
    if touchSensor == 1:
        print "Switch is on"
        Name.moveBackwards(30)
        Name.setLEDValue(1, 1)  #self.setLEDValue(position, value)
        Name.setLEDValue(2, 0)  #self.setLEDValue(position, value)
        touchSensor2Loop = Name.getSensorData(SensorType.touch, 3)
        print "Back switch as read inside loop: "
        print touchSensor2Loop
        if touchSensor2 == 1:
            print "Back switch has been hit"
            Name.moveForwards(30)
            Name.setLEDValue(2, 0)  #self.setLEDValue(position, value)
            if touchSensor == 0:
                break
# else:
#print "Switch is off"
#Name.moveForwards(30)
#Name.setLEDValue(1, 0) #self.setLEDValue(position, value)
Esempio n. 40
-8
def main():
    wanderer = Tortoise()

    while True:
        # print "Light 1: " + str(wanderer.getSensorData(enums.SensorType.light, 1))
        print "Light 2: " + str(wanderer.getSensorData(enums.SensorType.light, 2))
        # print
        time.sleep(0.5)