Advertisement
cmass

스마트 교통 신호등

Oct 28th, 2019
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. from microbit import *          # 마이크로비트 모듈의 모든 명령 사용
  2.  
  3. while True:                      # 무한 반복
  4.     pin0.write_digital(1)       # 0번핀에 연결된 빨간 LED 켜기(켜기: 1, 끄기: 0)
  5.     sleep(3000)                 # 3초 지연
  6.     pin0.write_digital(0)       # 0번핀에 연결된 빨간색 LED 끄기
  7.     pin1.write_digital(1)       # 1번핀에 연결된 녹색 LED 켜기
  8.     for a in range(6):          # a값이 0에서 5까지 총 6회 반복하기
  9.         display.show(5-a)       # 25개 LED 디스플레이에 5초 카운팅 보여 주기
  10.         sleep(1000)             # 1초 지연
  11.     pin1.write_digital(0)       # 1번핀에 연결된 녹색 LED 끄기
  12.     pin0.write_digital(1)       # 노란색을 만들기 위해 0번핀에 연결된 빨간색 LED 켜기
  13.     pin1.write_digital(1)       # 노란색을 만들기 위해 1번핀에 연결된 녹색 LED 켜기
  14.     display.clear()             # 25개 LED 디스플레이 초기화
  15.     sleep(2000)                 # 2초 지연
  16.     pin0.write_digital(0)       # 0번핀에 연결된 빨간색 LED 끄기
  17.     pin1.write_digital(0)       # 1번핀에 연결된 녹색 LED 끄기
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement