2017年2月8日 星期三

【MicroPython】LAB01 - 流水灯

【MicroPython】LAB01 - 流水灯


User@User-PC MINGW64 /c/mini3
$ cat test7.py
from machine import Pin
import time

leds = [Pin(i,Pin.OUT) for i in range(2,6)]

#===================================================
# leds 0=d3   , 1=d10   , 2=d4 , 3=d9 , 4=d2 , 5=d1
#      9=sdd2 , 10=sdd3
#     12=d3   , 13=d7   ,14=d5 ,15=d8 ,16=d0
#===================================================

#===========================================================
# from machine import Pin
# p0 = Pin(0, Pin.OUT)    # create output pin on GPIO0
# p0.high()               # set pin to high
# p0.low()                # set pin to low
# p0.value(1)             # set pin to high
#
# p2 = Pin(2, Pin.IN)     # create input pin on GPIO2
# print(p2.value())       # get value, 0 or 1

# p4 = Pin(4, Pin.IN, Pin.PULL_UP) # enable internal pull-up resistor
# p5 = Pin(5, Pin.OUT, value=1) # set pin high on creation
# Available pins are: 0, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16,
# which correspond to the actual GPIO pin numbers of ESP8266 chip
# Note that Pin(1) and Pin(3) are REPL UART TX and RX respectively.
# Also note that Pin(16) is a # special pin (used for wakeup from deepsleep mode)
# and may be not available for use with higher-level classes like
#==========================================================

n = 0

while True:
  n = (n + 1) % 4
  leds[n].value(1)
  time.sleep(0.5)
  leds[n].value(0)
  time.sleep(0.5)

User@User-PC MINGW64 /c/mini3
$ ^C

沒有留言:

張貼留言

2024產專班 作業2 (純模擬)

2024產專班 作業2  (純模擬) 1) LED ON,OFF,TIMER,FLASH 模擬 (switch 控制) 2)RFID卡號模擬 (buttom  模擬RFID UID(不從ESP32) Node-Red 程式 [{"id":"d8886...