ã¯ãªã¼ãã¼ã¹ã¿ã³ã
ããã¿å é»å¼ã¯ãªã¼ãã¼ã®ã¹ã¿ã³ããä½ãã¾ãããããã¯ï¼å·æ©ã§ãã
ããå°ãå°ãããã¦ãå®å®ããããªã¨æã£ã¦ãï¼å·æ©ãä½ãã¾ããã
Picoã§ãã«ã¹ã«ã¦ã³ã
ãã«ã¹ã®ç¶æ ï¼Highã¾ãã¯Lowï¼ãé«éã§è¦³å¯ãã¦ãLâHã®åãæ¿ããæ¤åºãããã¨ã§ããã«ã¹ãã«ã¦ã³ããã¾ãã
Â
ãã¹ãç¨ã«Picoã®GP16ãPWMåºåã«ãã¦ãããããã®ã¾ã¾GP17ã«å ¥åãã¦ãã«ã¦ã³ãã§ãããã©ãããã£ã¦ã¿ã¾ãããPWMã®å¨æ³¢æ°ã1kHzã«ãã¦ãTimerã§1ç§æ¯ã«å²ãè¾¼ã¿ãããã¾ãã
>>> %Run -c $EDITOR_CONTENT
MPY: soft reboot
1001
1000
1000
1000
1000
Â
10kHzã¾ã§ã¯ä½ã¨ãã«ã¦ã³ãã§ãã¦ãã¾ãã
>>> %Run -c $EDITOR_CONTENT
MPY: soft reboot
9996
9992
9996
9996
9995
Â
100kHzã ã¨ã ãã§ããã
>>> %Run -c $EDITOR_CONTENT
MPY: soft reboot
16138
15774
16271
15921
16093
Â
pythonã®whileã«ã¼ãããã½ã³ã³ã®ã¹ããã¯ã®éçã§ãããããï¼
Â
ãããã§èª¿ã¹ãã¨ãã¯ãã«ã¹ã®ç«ã¡ä¸ããæ¤åºã®é¨åã§ãã£ã¨è¤éãªãã¨ããã£ã¦ãã¾ãããã»ã»ã»ããã§ã¯æä½éã®é¨åã ãæãåºãã¾ãããããã§ä½ãä¸å ·åãçããã対çãèãããã¨ã«ãã¾ãã
Â
Â
from machine import Pin, PWM, Timer
import time
Â
pwm = PWM(Pin(16, Pin.OUT))   # PWMåºå
pwm.duty_u16(2**16//2)       # Dutyæ¯=50%
pwm.freq(1000)              # PWMå¨æ³¢æ°è¨å®
inp = Pin(17, Pin.IN)           # GP16ããã®ã¾ã¾GP17ã«å
¥åãã
Â
# å²ãè¾¼ã¿æã«å¼ã³åºãããé¢æ°
# ã«ã¦ã³ãæ°ã表示ãã¦ãããªã»ãããã
def reset(timer):
 global count
 print(count)
 count = 0
Â
# 1ç§æ¯ã«å²ãè¾¼ã¿ãã
timer = Timer()
timer.init(freq = 1, mode = Timer.PERIODIC, callback = reset)
Â
count = 0
oldval = 0
while True:
 newval = inp.value()           # å
¥åå¤ãèªã¿è¾¼ã
 if oldval == 0 and newval == 1:  # ãã«ã¹ã®ç«ã¡ä¸ãããæ¤åºããã
  count += 1                 # ã«ã¦ã³ããã
 oldval = newval               # ç¾å¨ã®å
¥åå¤ãoldvalã«ä¿å
Â
Raspberry Pi Picoï¼7ã»ã°LED
7ã»ã°LEDã®ä½¿ãæ¹ãåãã£ãã®ã§ãRaspberry Pi Picoã§ç¹ç¯ããã¦ã¿ã¾ããããããï¼åã§ã§ããï¼ã©ãºããªã¼ã»ãã¤Picoã§ã¯ãããé»åå·¥ä½è¶ å ¥éããåèã«ãã¾ããã
- 7ã»ã°ãã©ã¤ãICï¼TC4511BPï¼
- 7ã»ã°LEDï¼C-551SRï¼â¦ã«ã½ã¼ãã³ã¢ã³
Â
TC4511ã®ãã¼ã¿ã·ã¼ããè¦ãã¨ãé»æºé»å§ã¯3Vï½18Vã¨ãªã£ã¦ãã¾ããããä¸è¿°ã®æ¬ã§ã¯Picoã®3.3Vé»æºã§ã¯ãªããVBUSã®5Vã使ã£ã¦ãã¾ããã3.3Vã ã¨ãã¾ããããªãããã§ãï¼è©¦ãåã«ã°ããã¦ãã¾ãã¾ãããï¼ãLTbarã¨BIbarã¯3.3Vã§ã5Vã§ãå¯ã
Â
ãã¨ã¯pythonããã°ã©ã ãåããã ãã
ä¾ï¼10é²æ°ã®5ï¼2é²æ°ã®0101ï¼ã表示ããå ´å
å³ã«0åã·ããâ0101 & 0001â1âAãã³ã«åºå
å³ã«1åã·ããâ0010 & 0001â0âBãã³ã«åºå
å³ã«2åã·ããâ0001 & 0001â1âCãã³ã«åºå
å³ã«3åã·ããâ0000 & 0001â0âDãã³ã«åºå
Â
from machine import Pin
import time
Â
A = Pin(0, Pin.OUT)
B = Pin(1, Pin.OUT)
C = Pin(2, Pin.OUT)
D = Pin(3, Pin.OUT)
Â
# 0ï½9ã¾ã§ã®æ°åã表示ãã
for i in range(10):
 A.value((i >> 0) & 1)
 B.value((i >> 1) & 1)
 C.value((i >> 2) & 1)
 D.value((i >> 3) & 1)
 time.sleep(0.5)        # 0.5ç§å¾ ã¤
7ã»ã°LEDã§ãã¸ã¿ã«ãµã¤ã³ã
7ã»ã°ã¡ã³ãLEDã®ä½¿ãæ¹ãåå¼·ããããã«ãèª æå æ°å 社ãé»åå·¥ä½å¤§å³éãï¼ä¼è¤å°æªèï¼ãåèã«ãã¦ã0ãã9ã¾ã§ã®æ°åãã©ã³ãã ã«è¡¨ç¤ºãããã¸ã¿ã«ãµã¤ã³ããä½æãã¾ãããï¼ä¸è¿°ã®æç®ã§ã¯ããã¸ãµã¤ãã¨ããã¿ã¤ãã«ãã¤ãã¦ãã¾ãããï¼
- ã¿ã¤ãã¼ICï¼555ï¼â¦ã¯ããã¯ä¿¡å·ãçºçãããã¹ã¤ããã§ã¯ããã¯ãON/OFFããã
- ã«ã¦ã³ã¿ã¼ICï¼74LS90ï¼â¦ã¯ããã¯ãã«ã¦ã³ãããã9ã¾ã§æ°ããã0ã«æ»ãã
- 7ã»ã°ã¡ã³ããã©ã¤ãICï¼74LS47ï¼â¦4æ¡ã®2é²æ°ãå ¥åãã¦ããã®æ°ã®å½¢ã«å¯¾å¿ããã»ã°ã¡ã³ããå ããããä¾ï¼0101ãå ¥åãããã¨7ã»ã°LEDã®ACDFGãå ãã
- 7ã»ã°ã¡ã³ãLEDï¼A-551SRDï¼â¦7447ãLowã¬ãã«ã§åä½ããã¿ã¤ãã®ãããã¢ãã¼ãã³ã¢ã³ã使ç¨ãï¼åè·¯å³ã®LEDã¯éãåçªã«ãªã£ã¦ãã¾ãããé åã¯A-551SRDã¨åããï¼
ã¿ã¤ãã¼ICã®æµæã¨ã³ã³ãã³ãµã¯1kΩã470Ωã10μFã«ããã¨å¨æ³¢æ°60Hzããã¥ã¼ãã£ã¼æ¯60%ãããã®ããã§ãã便å©ãªè¨ç®ãµã¤ããããã¾ããã
https://www.zea.jp/audio/schematic/sc_file/018.htm
åããã¨ã¯åãã¾ãããä½åãã£ã¦ã1ã¨7ãåºãªããé ç·ãééã£ã¦ããããã»ã»ã»ã
Â
Â