MP Quick Start

From ElectroDragon
Revision as of 00:44, 17 June 2020 by Chao (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Plug In

  • You will get a portable disk "TPYBFLASH", size 100KB
  • Include files:
boot.py -> no need change
main.py -> board main python script
README.txt
tpybcdc.inf -> Board USB shell driver
  • Drag new main.py file to update code

LED Flow Demo Code

# main.py -- put your code here!
leds = [pyb.LED(i) for i in range(1,5)]

sw=pyb.Switch()
def test():
    pyb.LED(1).on()
    pyb.LED(2).on()
    pyb.LED(3).on()
    pyb.LED(4).on()
    pyb.delay(2000)
sw.callback(test)

for l in leds:
    l.off()

n = 0

try:
   while True:
      n = (n + 1) % 4
      leds[n].toggle()
      pyb.delay(50)
finally:
    for l in leds:
        l.off()

REPL

  • Must use putty for first time, less easy to get error
  • press CTRL+C to stop or CTRL+D to run program again.
  • get >>> to start.

Note

  • Only restart or re-power after the files is fully copied, the on board status led indicating file transfer should turn off after it done