Example #1
0
# os.system('setfont Lat15-TerminusBold32x16')
#print("Left = Run 1, Right = Run 2, Up = Run 3")

#sound and button
sound = Sound()

#creating button
btn = Button()

motorD = LargeMotor(OUTPUT_D)
motorC = LargeMotor(OUTPUT_C)

motorD.off()
motorC.off()

show_text("Up = Run 1, Right = Run 2, Bottom = Run 3")

while True:
    if btn.check_buttons(buttons=['up']):
        #show_text("Currently Running Run 1")
        Robotrun1()
        show_text("Up = Run 1, Right = Run 2, Bottom = Run 3")
    if btn.check_buttons(buttons=['right']):
        #show_text("Currently Running Run 2")
        Robotrun4()
        show_text("Up = Run 1, Right = Run 2, Bottom = Run 3")
    if btn.check_buttons(buttons=['down']):
        #show_text("Currently Running Run 3")
        Robotrun3()
        show_text("Up = Run 1, Right = Run 2, Bottom = Run 3")
Example #2
0
# Connect EV3 color sensor
from spockbots.colorsensor

colorsensor = [0,0,0]
for i in [2]:
    colorsensor[i] = SpockbotsColorSensor(i)


tank = MoveTank(OUTPUT_A, OUTPUT_B)
tank.on(SpeedPercent(-5), SpeedPercent(-5))


while True:

    txt = "exit"
    if button.check_buttons(buttons=['backspace']):
        break
    else:
        txt = "Press Backspace to Stop"

    #print("%s 2: %3d"  % ( txt, colorsensor[2].value(), "\n"))

    for i in [2]:
        colorsensor[i].set_white()
        colorsensor[i].set_black()

tank.off()

f= open("colcal2.txt","w+")
f.write("hi this is a test")
f.write("%3d, %3d" % (colorsensor[2].black, colorsensor[2].white))
Example #3
0
# clear the lcd display
lcd.clear()

# show the steps
lcd.text_pixels( str(steps), True, 80, 50, font='courB18')
lcd.update()

log.info('wait user to supply the steps')
# wait user to supply the steps to go
while( True ):
	if(not btn.buttons_pressed):
		sleep(0.01)
		continue

	if btn.check_buttons(buttons=['up']):
		steps += 1
	elif(btn.check_buttons(buttons=['down']) ):
		steps -= 1
		if( steps < 0 ):
			steps = 0
	elif(btn.check_buttons(buttons=['enter'])):
		break

	# update the steps on screen
	lcd.text_pixels( str(steps), True, 80, 50, font='courB18')
	lcd.update()

	# btn.wait_for_released(buttons=['up','down', 'left', 'right','enter'])

log.info('Climbing ......')