Last active
January 9, 2022 12:55
-
-
Save nevergone/26d265511ae0f8c579765dc656f744d3 to your computer and use it in GitHub Desktop.
Fénysorompó készítése Micro:bit platformon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def elo_tilos_jelzes_utasitasok(): | |
pins.digital_write_pin(DigitalPin.P0, 0) | |
def on_button_pressed_a(): | |
global szabad | |
while foglalt: | |
basic.pause(100) | |
if szabad: | |
szabad = False | |
elo_tilos_jelzes_utasitasok() | |
else: | |
szabad = True | |
elo_szabad_jelzes_utasitasok() | |
input.on_button_pressed(Button.A, on_button_pressed_a) | |
def elo_szabad_jelzes_utasitasok(): | |
pins.digital_write_pin(DigitalPin.P1, 0) | |
pins.digital_write_pin(DigitalPin.P2, 0) | |
def szabad_jelzes_utasitasok(): | |
global foglalt | |
foglalt = True | |
pins.digital_write_pin(DigitalPin.P0, 1) | |
basic.pause(villog_sebesseg) | |
pins.digital_write_pin(DigitalPin.P0, 0) | |
basic.pause(villog_sebesseg) | |
foglalt = False | |
def tilos_jelzes_utasitasok(): | |
global foglalt | |
foglalt = True | |
pins.digital_write_pin(DigitalPin.P1, 1) | |
pins.digital_write_pin(DigitalPin.P2, 0) | |
basic.pause(villog_sebesseg) | |
pins.digital_write_pin(DigitalPin.P1, 0) | |
pins.digital_write_pin(DigitalPin.P2, 1) | |
basic.pause(villog_sebesseg) | |
pins.digital_write_pin(DigitalPin.P2, 0) | |
foglalt = False | |
foglalt = False | |
villog_sebesseg = 0 | |
szabad = False | |
# A fénysorompó szabad jelzést jelez. | |
szabad = True | |
villog_sebesseg = 500 | |
def on_forever(): | |
if szabad: | |
szabad_jelzes_utasitasok() | |
else: | |
tilos_jelzes_utasitasok() | |
basic.forever(on_forever) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment