0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

pi picoでmicropython その35

Last updated at Posted at 2023-04-06

概要

picoでmicropythonやってみた。
練習問題やってみた。

練習問題

俺言語インタープリタを拡張しLチカを実行せよ。

方針

  • gpioの初期化
  • 変数lの導入 LEDを操作する。
  • 変数"の導入 sleepを実装する。

Lチカのコード

l=0 LED点灯
l=1 LED消灯
"=1 1秒待つ

10 a=0
20 a=a+1
30 l=1
40 "=1
50 l=0
60 "=1
70 #=a<10*20
80 #=300

1秒、点灯、1秒、消灯を10回。

サンプルコード

import time
import sys
led = machine.Pin(25, machine.Pin.OUT)

def ordr():# siki hyouka
   global Ptr, Val, C, Adr
   getvr()# hidari
   Ptr = Ptr + 2
   if READB(Ptr) == ord('"'):
      Ptr = Ptr + 1
      putlp(ord('"'))
   elif READB(Ptr) == ord('!'):
      print()
   else:
      expr()# migi
      if C == ord('?'):
         put(Val)# print
      elif C == ord('l'):# led
         led.value(Val)
      elif C == ord('"'):# sleep
         time.sleep(Val)
      else:
         WRITEB(Adr, Val)# dainyuu

実行結果

image.png

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?