from myro import*
init("simulator")
lightLeft = getLight("left")
lightCenter = getLight("center")
lightRight = getLight("right")
def pressC():
key = "x"
while key != "C":
key = raw_input("Enter C to continue: ")
def main():
senses()
pressC()
Leftsensorvalues = []
Centersensorvalues = []
Rightsensorvalues = []
forward(1,1)
for i in range(20):
turnLeft(.35,1)
lightLeft
Leftsensorvalues.append(lightLeft)
lightCenter
Centersensorvalues.append(lightCenter)
lightRight
Rightsensorvalues.append(lightRight)
print "Left Sensor Values:" + str(Leftsensorvalues)
print "Center Sensor Values:" + str(Centersensorvalues)
print "Right Sensor Values:" + str(Rightsensorvalues)
Leftaverage = sum(Leftsensorvalues) / 15
Centeraverage = sum(Centersensorvalues) / 15
Rightaverage = sum(Rightsensorvalues) / 15
print "Left average:" + str(Leftaverage)
print "Center average:" + str(Centeraverage)
print "Right average" + str(Rightaverage)
main()
Printing All Sensor values
Page 1 of 11 Replies - 270 Views - Last Post: 18 December 2012 - 09:39 AM
#1
Printing All Sensor values
Posted 18 December 2012 - 08:57 AM
So, I've tried a few ways to make it print all the values but it's not working... Can someone help please?
Replies To: Printing All Sensor values
#2
Re: Printing All Sensor values
Posted 18 December 2012 - 09:39 AM
I do not know myro. So just a wild guess:
In line 26 (also in 29, 32) you actually wanted to write:
Just writing
does nothing. It is just a variable name and you do nothing with it.
So in your next line
only the value you read at the very beginning gets appended to your list.
In line 26 (also in 29, 32) you actually wanted to write:
lightLeft = getLight("left")
Just writing
lightLeft
does nothing. It is just a variable name and you do nothing with it.
So in your next line
Leftsensorvalues.append(lightLeft)
only the value you read at the very beginning gets appended to your list.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|