Exemplo n.º 1
0
    l.set_color("RIGHT", "RED")

    print("[BTTRC] - Starten...")

    printprocess = Process(target=processQueue)
    printprocess.start()

    chat2printprocess = Process(target=chat2print)
    chat2printprocess.start()

    morse2chatprocess = Process(target=morse2chat)
    morse2chatprocess.start()

    Chat.send("[BTTRC] - Gestartet!", nosound=True)

    print("[BTTRC] - Gestartet!")

    b.wait_for_bump("left")

    print("[BTTRC] - Beenden...")

    printprocess.terminate()
    chat2printprocess.terminate()
    morse2chatprocess.terminate()

    Chat.send("[BTTRC] - Beendet!", nosound=True)

    print("[BTTRC] - Beendet!")

    l.all_off()
#!/usr/bin/env python3
from ev3dev2.motor import MoveSteering, OUTPUT_B, OUTPUT_C
from ev3dev2.sensor.lego import ColorSensor
from ev3dev2.button import Button
from ev3dev2.sound import Sound
from time import sleep

cl = ColorSensor()
btn = Button()
sound = Sound()
steer_pair = MoveSteering(OUTPUT_B, OUTPUT_C)

sound.speak('Press the Enter key when the sensor is in dim light')
btn.wait_for_bump('enter')
dim = cl.ambient_light_intensity
sound.beep()

sound.speak('Press the Enter key when the sensor is in bright light')
btn.wait_for_bump('enter')
bright = cl.ambient_light_intensity
sound.beep()
sound.speak('3, 2, 1, go!')

while not btn.any():  # Press any key to exit
    intensity = cl.ambient_light_intensity
    steer = (200 * (intensity - dim) / (bright - dim)) - 100
    steer = min(max(steer, -100), 100)
    steer_pair.on(steering=steer, speed=30)
    sleep(0.1)  # wait for 0.1 seconds
Exemplo n.º 3
0
#!/usr/bin/env python3
from ev3dev2.button import Button
from ev3dev2.display import Display
from ev3dev2.sound import Sound

btn = Button()
sound = Sound()
lcd = Display()
sound.beep()
while True:
    '''btn.wait_for_bump('left')
     lcd.text_pixels('left', x=40, y=50, font='courB24')
     lcd.update()
     sleep(1)
     sound.beep()'''
    '''btn.wait_for_pressed(['up', 'down'])
     lcd.text_pixels('up or down', x=40, y=50, font='courB24')
     lcd.update()
     sleep(1)
     sound.beep()'''
    btn.wait_for_bump('right')
    lcd.text_pixels('right', x=40, y=50, font='courB24')
    lcd.update()
    sleep(1)
    sound.beep()