ç§ã®æ¯åã¯ã ãã°ããã£ãã¯ã³ã³ã¹ãã©ã¯ã¿ãŒMagformersã«ãã£ãããšãããã¯ãããŸããã åãã³ã³ã¹ãã©ã¯ã¿ãŒã玹ä»ãããŠããäžé£ã®FixiksãèŠãŠã¿ããšãåäŸã¯ããç¶ããããªããã£ã¯ãã£ãã¯ã¹ã«ã¯èŒããŠãã詳现ããããŸãããç§ãã¡ã«ã¯ãããŸãããïŒããšå°ããŸããã
ãMagformers Neon LED Setãã®ã»ãããå®éã«ãããéåžžã®ãã«ãã£ã³ã°ãããã¯ã«å ããŠãLEDãåããèŠçŽ ããããŸãã ãã®æç¹ãŸã§ã«ãèãããããã¹ãŠã®åœ¢ç¶ãšãµã€ãºã®ç£ç³ã®ç®±å šäœããã§ã«éããŠããã®ã§ïŒç§ã«ãšã£ãŠã¯ã äžåœã®ãã°ãã©ãŒããŒã¯å ã®ãã®ãããå£ã£ãŠããŸããïŒãé»çã®ããã ãã«å¥ã®ã»ãããè³Œå ¥ãããã¯ãããŸããã§ããã ããã«ããã®ã»ããã¯ãããã¯ã©ã€ããªãã®åæ§ã®ã»ãããããå€§å¹ ã«ã³ã¹ããããããŸãã
ããã«ããæåã¯ã»ãã®æ°ãã«ã§ããã®ã»ãšãã©ã¯ãã§ã«æã£ãŠãããšæšå®ããã®ã§ãã¢ã«ã°ã«ã«ãéããããšã«ããŸããã ã¯ãããªãªãžãã«ã«ã¯ãªãå¹æããããŸãã
ç«ã®äžã«ã¯ãATTiny85ã®ãŠã€ã³ã«ãŒãšWS8212 LEDã®LEDããã«ã®ãªãã·ã§ã³ããããŸãã åè·¯ãããããªãŒãããã®å šäœãã©ã®ããã«äŸçµŠãããããããŠéäžã§ããéããæçœã§ãªãåé¡ã«ã€ããŠè©±ããŸãã ãŸãããããžã§ã¯ãã®ãœãããŠã§ã¢ã³ã³ããŒãã³ãã«ã€ããŠè©³ãã説æããŸãã
æåã®ã¹ããã
éåžžã®LEDïŒRGBã§ãããïŒã®èŒãã¯éå±ã§å¹³å¡ãªããã«æããŸããã ããããWS8212ã®ãããªãã®ãæããã®ã¯é¢çœããã§ãã ebeeã§ã¯ãåå¥ã®LEDãšæ倧16x16ãµã€ãºã®ãããªãã¯ã¹ã®äž¡æ¹ãæäŸãããŸããã ããã€ãã®ç°ãªãã¢ãžã¥ãŒã«ãè³Œå ¥ããã®ã§ã4x4ãããªãã¯ã¹ã決å®ããŸããã ã¢ãžã¥ãŒã«ã«ã¯ããŸããŸãªèŠèŠå¹æã«ãµããããã®LEDããããããããŸãããã¢ãžã¥ãŒã«ã®ãµã€ãºã¯ãã¶ã€ããŒã®æ£æ¹åœ¢ãããã¯ã®ãŠã£ã³ããŠã«å¹æµããŸãã
LEDãããªãã¯ã¹ãå¶åŸ¡ããã«ã¯ããã€ã¯ãã³ã³ãããŒã©ãŒã®1ã€ã®ãã³ã§ååã§ãããããarduino nanoã§ããã¹ãã®ããã«èŠããŸãïŒããã«ãã±ãŒã¹ã«åãŸããŸããïŒã ããããATTiny85ã³ã³ãããŒã©ãŒã®digisparkã¯ããŒã³ã¯ã¡ããã©è¯ãããšãå€æããŸãããã¡ã¢ãªãŒãšãã³ã¯ããã»ã©å€ããããŸããããLEDãŠã€ã³ã«ãŒã«ã¯ååã§ãã ãã®ã¢ãžã¥ãŒã«ã¯Arduino IDEãšå®å šã«çµ±åãããUSBããŒãããŒããŒãæèŒãããŠããããããã®ã¢ãžã¥ãŒã«ã®ããã°ã©ãã³ã°ã¯éåžžã«ç°¡åã§å¿«é©ã§ãã ç§ã¯ãã£ãšè©ŠããŠã¿ãããšæã£ãŠããŸããã
æãåçŽãªã¹ããŒã ããå§ããŸããã
ãã®åœ¢åŒã§ã¯ããã¹ãŠã®ã°ããŒ/ããªã³ã¯ã¢ã«ãŽãªãºã ïŒä»¥äžã«ã€ããŠïŒããã°ãããããã°ã§ããŸããã ããããã¯ã€ã€ãŒã§åãããã¡ãã¯ããã§ã¯ãããŸãããããããªãŒã®é»åã«ã€ããŠèããå¿ èŠããããŸãã ããã«ããã£ã³ã¬ãŒããããªãŒã§ç Žç£ããªãããã«ïŒããã«ãããã¯ãšã³ãããŒãã«åãŸããªãïŒããªããŠã ã䜿çšããããšã決å®ãããŸããã ãªããŠã é»æ± ãããã®ã§ãå é»æ¹æ³ãèããå¿ èŠããããŸãã ãã³ã§ãTP4056ãããäžã§ãã®æ©äŒã«è³Œå ¥ãããã人æ°ã®ãå é»ã³ã³ãããŒã©ãŒãèŠã€ããŸããã
ããããããã«ã¯æ©èœããŸããã§ããã Digispark ATTiny85ã¢ãžã¥ãŒã«ã®åè·¯ã¯ãã®ããã«ããŸãèšèšãããŠããŸãã-USBé»æºã¯ãããŸãããé»æºã¯ãã€ã¯ãã³ã³ãããŒã©ã«çŽæ¥äŸçµŠãããŸãïŒ+5ãã¹çµç±ïŒããŸãã¯VINå ¥åããã§ãããé»æºã¯7805ãªãã¢ã¹ã¿ãã©ã€ã¶ãŒãééããŸãã USBã³ãã¯ã¿ãšãã€ã¯ãã³ã³ãããŒã©ã®éã®ééã«æ¿å ¥ããããã®ã¯æäŸãããŸããã åè·¯ãå°ãä¿®æ£ããäœåãªè©³çŽ°ãåé€ããå¿ èŠããããŸããã
ãã®ãããUSBé»æºãVINãã³ã«äŸçµŠãããŠãããå é»åšå ¥åã«é²ã¿ãŸãã å é»åšã®åºåïŒå®éã«ã¯ãããããªãŒã¯çŽæ¥æ¥ç¶ãããŠããŸãïŒã¯ã5Vããããä»ããŠããŒãã«æ»ããŸãã ãŸããå®éã«ã¯3ã4.2VïŒããããªãŒé»å§ïŒããããŸãããããã¯éåžžã«æ£åžžã§ã-ãã€ã¯ãã³ã³ãããŒã©ãŒã®åäœé»å§ç¯å²ã¯1.8ã5.5Vã§ãã ãŸããLEDã¢ãžã¥ãŒã«ã§ãã2.7Vããæ£åžžã«åäœããŸããã3.2Væªæºã§ã¯éè²ã®LEDãå°ãäžè¶³ããè²ãå°ãé»è²ã«ãæµ®ããŠããŸããã
ãšãã«ã®ãŒãç¯çŽããããã«ãåžžæç¹ç¯ã®D2 LEDãæ¶ããŸããã äžè¬çãªã¹ããŒã ã¯æ¬¡ã®ããã«ãªããŸã
å é»åšã®USBã³ãã¯ã¿ããåè·¯ã«çµŠé»ããããšã¯å¯èœã§ãããã³ã³ãããŒã©ãŒããŒãã®USBã³ãã¯ã¿ãä»ããŠãã¡ãŒã ãŠã§ã¢ãã¢ããããŒãããæ©èœã¯å€±ãããŸãã å é»çšãšãã¡ãŒã ãŠã§ã¢çšã®2ã€ã®USBã³ãã¯ã¿ãããŸããŸãªç®çã§æ®ãããšãã§ããŸãããããã¯äœããã®åœ¢ã§ééã£ãŠããŸãã
eBayã§6x25x35ãµã€ãºã®ããããªãŒãè³Œå ¥ããŸããããäžè¯åã§ããããç絡ãŸãã¯é«å é»é»æµïŒããŒãã®ããã©ã«ãå é»é»æµã¯1Aã§ãããé»æµãæžããããã«1ã€ã®æµæåšãã¯ãã ä»ãããå¿ èŠããããŸãïŒã§ããã殺ããŸããã ãããã«ãããè² è·ãæ¥ç¶ããããšãã10 mAã§ããããããªãŒã®é»å§ã¯1 Vã«äœäžããŸããã ãã¹ãã®æç¹ã§ãç§ã¯å°ããªã¯ã¯ããã³ãã¿ãŒããååæ»ãã ãªãããããªãŒã«åãæ¿ããŸããã å°ãåŸã«ãå¥ã®å£²ãæã«ããããªãŒã泚æããŸããããããã¯è¯ãããšãããããŸããã
ååãšããŠãããã§åæ¢ããæ¥ç¶ã¯ã€ã€ãã¯ãã ä»ãããŠãããçš®ã®ã±ãŒã¹ã«ãã¹ãŠãéãã«æŒã蟌ãããšã¯å¯èœã§ãããåè·¯ã®æ¶è²»éã枬å®ããããšã«ããŸããã ãããŠæ³£ããã ããŠãåäœç¶æ ïŒé»çãå®å šã«å ããšãïŒã§ã¯ããã®ããšã¯æ倧130mAãæ¶è²»ãããããå®éæã®æ¶è²»ã¯25mA以äžã§ãïŒ ã€ãŸã ãã®ãŠã€ã³ã«ãŒã¯ã600mAhã®ããããªãŒã1æ¥ãããããã«æ¶èãããŸãïŒ
çŽ10 mAãLEDãæ¶è²»ããããšãå€æããŸããã ç¹ç¯ããŠããªããŠãããã€ã¯ãã³ã³ãããŒã©ãŒã¯ããããã§åäœããã³ãã³ããåŸ æ©ããŸãã ã€ãŸã LEDã®ãã¯ãŒããŠã³åè·¯ãèãåºãå¿ èŠããããŸãã
æ®ãã®15 mAã¯ãã€ã¯ãã³ã³ãããŒã©ãŒã«ãã£ãŠæ¶è²»ãããŸãã ã¯ããããã¯ãããã«çœ®ãããšãã§ããããŒã¿ã·ãŒãã«ãããšãæ¶è²»ã¯ãã€ã¯ãã¢ã³ãã¢ã§æž¬å®ãããŸãããå®éã«ã¯1 mAæªæºãåŸãããšãã§ããŸããã§ããã ADCããªãã«ããŠããã³ãå ¥åã«å€æããŸããã åè·¯ã®ã©ããã«äœããã®æŒããããããã«èŠããŸãããé»åæ©åšã«ã€ããŠã®ç§ã®ãããããªç¥èã§ã¯ãããèŠã€ããŠç解ããã«ã¯äžååã§ãã
ã¹ããŒã ãè€éã«ããŸã
ããããç§ã¯ãç§èªèº«ããã¹ãã®ããã«PT1502ããããè³Œå ¥ããããšãæãåºããŸããã ãã®ãããã¯ãããã€ãã®å¶åŸ¡å ¥åãåããé»æºãåãããªããŠã é»æ± å é»ã³ã³ãããŒã©ãŒã§ãã å¯äžã®é£ç¹ã¯ãè¶ å°ååè·¯ã4x4 mm QFN20ããã±ãŒãžã«å ¥ã£ãŠãããã¹ãã©ãããå¿ èŠãªããšã§ãã ãããèªå® ã§ã¯ãã ä»ãããããšã¯å°é£ã§ãããå¯èœã§ãã éåžžã®LUTã§ã¯æéã¯é£ãããäžåœãã泚æããå¿ èŠããããŸãã ããããç§ãã¡ã¯å°é£ãæããŸããããïŒ
ããã€ãã®ããã¯ã¹ã§ãã¹ããŒã ã次ã®ããã«èª¬æã§ããŸãã
ãªãç¶æ ã§ã¯ãã³ã³ãããŒã©ãŒãšLEDã«é»åã¯äŸçµŠãããŸããã ããã€ã¹ã«ã¯ãé»æºããã¿ã³ãããããŠã€ã³ã«ãŒããªã³ã«ããŸãïŒã¢ãŒããåãæ¿ããŸãïŒã LEDã¯ãããšãã°1åéç¹ç¯ãããŠãŒã¶ãŒã®æäœããªãå ŽåïŒèª°ããã¿ã³ãæŒããªãå ŽåïŒãããã€ã¹ã¯ãªãã«ãªããŸãã ã€ãŸã ã¹ãªãŒãç¶æ ã«ãªãã ãã§ãªããPower Holdä¿¡å·ã«ãã£ãŠèªèº«ã®é»æºããªãã«ããŸãã ãããŠããã€ã¯ãã³ã³ãããŒã©ãšLEDã®äž¡æ¹ãäžåºŠã«ãã¹ãŠãªãã«ããŸãã é»æºãªã³ããã³ãªãæ©èœã¯PT1502ãããå ã«å®è£ ãããŠããŸã
ããšã¯ãåè·¯å³ãæããŠåè·¯åºæ¿ãäœæããã ãã§ãã ãã®ã¹ããŒã ã®å€§éšåã¯ãPT1502ããŒã¿ã·ãŒããšDigispark ATTiny85ã¢ãžã¥ãŒã«ã§æ§æãããŠããŸãã PT1502ãã¯ãŒã³ã³ãããŒã©ãŒãã€ã¯ããããã¯æ©èœçã«ããã€ãã®éšåã«åå²ãããŠãããããåè·¯å ã®ãããã¯ã«åå²ãããŠããŸãã
å®éãããã¯ç¬èªã®ããŒãã¹ãåãããªããŠã é»æ± å é»ã³ã³ãããŒã©ãŒã§ãã LED1ã¯å é»ç¶æ ã瀺ããŸã-ãªã³ã®å Žåãå é»ã¯ãªã³ã§ãã æµæR6ã¯å é»é»æµã470mAã«èšå®ããŸãã ç§ã¯600mAhã®ããããªãŒãæã£ãŠããã®ã§ãååãšããŠãé»æµãå¢ãããŠãæ倧600mAãŸã§780-800ãªãŒã ã®æµæã眮ãããšãã§ããŸãã ãã ããããããªãŒã®ç¹å¥ãªå質ã«ã€ããŠã¯ç¢ºä¿¡ããããŸããããããã£ããå é»ããæ¹ãè¯ãã®ã§ãããé·æã¡ããŸãã
é»æºãã©ã³ãæ€èšãã
SW1ãã¿ã³ã¯ã·ã¹ãã å šäœãèµ·åããŸã-PT1502ãããã¯ããèªäœãèµ·åãããã¹ãŠã®é»æºïŒãã¡3ã€ïŒãèµ·åããŸãã é»æºãã€ã³ã¹ããŒã«ããããšããã€ã¯ãåè·¯ã¯RESETä¿¡å·ã解æŸããŠãã€ã¯ãã³ã³ãããŒã©ãŒãèµ·åããŸãã ãããã°ãç°¡åã«ããããã«ãåå¥ã®ãªã»ãããã¿ã³ãè¿œå ããŸããã
HOLDä¿¡å·ã¯ãã·ã¹ãã å šäœããªãã«ããããã«äœ¿çšãããŸãã ãã€ã¯ãã³ã³ãããŒã©ãŒãèµ·åãããšããã®ã©ã€ã³ã§ãŠããããèšå®ããå¿ èŠããããŸãã åæšäºå ¥ããæéã«ãªããšããã€ã¯ãã³ã³ãããŒã©ã¯HOLDã©ã€ã³ã«ãŒããèšå®ããPT1502é»æºãããã¯ãã¹ãŠã®é»æºãåæ¢ããŸãã
BAT_LOWåºåã®å©ããåããŠäœããããªãŒã¬ãã«ã远跡ããããšã¯å¯èœã§ããããã®èšäºã§ã¯ãããæ¡ç¹ããŸãã-ããŒã¿ãä¿åããå¿ èŠã¯ãªããæéå ã«ããããªãŒåãã«æ°ä»ããªãå Žåã¯äœãççºããŸããã æ»ã¬ã»ã©æ»ã¬ã ãããã念ã®ãããåç· åœ¹äŒã¯ãã®ããžãã¹ã®é£çµ¡å ãæäŸããŸããã
SW1ãã¿ã³ã«æ»ããŸãããã é»æºããªã³ã«ãããããšå¶åŸ¡ããããã«ã2ã€ã®åå¥ã®ãã¿ã³ãäœæããªãããšã«ããŸããã ãããã£ãŠãåããã¿ã³ãATTiny85ã«ãæ¥ç¶ãããåäœäžã«ç¹æ» ã¢ãŒããåãæ¿ãããŸãã ååšåšR7ãR8ã®å€ã¯ãPB2ãã€ã¯ãã³ã³ãããŒã©ãŒã®ããŒããçŒããªãããã«éžæãããŸãã ãã¹ãŠã®ããããªãŒé»å§ç¯å²ïŒ3.3-4.2VïŒã§ãæå®ãããããŒã¿ã·ãŒãå¶éïŒ0.7 * VCC-VCC + 0.5VïŒå ã§ã³ã³ãããŒã©ãŒã®è¶³ã«é»å§ãäŸçµŠãããŸãã
é»æºãæ€èšãã
ããã¯ããã«ã¹DC-DCã³ã³ããŒã¿ãŒã§ãã åºåé»å§ã¯æµæR10ãR11ã«ãã£ãŠèšå®ãããããŒã¿ã·ãŒãã®åŒã«åŸã£ãŠ3.3Vã«èšå®ãããŸãã ä»ã®ãã¹ãŠã¯åçŽãªã¹ãã©ããã§ãã
è¯ãããšã«ã¯ããã®ãããªã ãŸãããé»æºã¯å®éã«ã¯å¿ èŠãããŸãããäžè¬ã«ããããªãŒããçŽæ¥ãã€ã¯ãã³ã³ãããŒã©ãŒã«é»åãäŸçµŠããããšãå¯èœã§ãã ãã®ãœãŒã¹ã¯ãã§ã«PT1502ãããã«å®è£ ãããŠãããå¿ èŠãªãšãã«ãªã³/ãªãã§ããã®ã§ã䜿çšããªãã®ã¯ãªãã§ããïŒ
ãããã«ã¯2ã€ã®ç·åœ¢å®å®è£ 眮ããããŸãããç§ã¯ãããã䜿çšããŸããã æ®å¿µãªãããå€æããããã«ããã®ãœãŒã¹ã«å ¥åé»å§ãäŸçµŠããå¿ èŠããããŸããããããªããšããã€ã¯ãåè·¯ã¯é»åããŸã ååã«å®å®ããŠããªããšå€æãããã€ã¯ãã³ã³ãããŒã©ãèµ·åããŸããïŒ
è«çéšåã«ç§»ããŸãããã
USBã±ãŒãã«ã¯ãå€æŽãããã«DigisparkããŒãããã©ãããããŸãã ããã¯ãUSBé»å§ïŒ3.3Vãå®è¡ïŒãšãã€ã¯ãã³ã³ãããŒã©ã®ä¿¡å·ïŒãªãªãžãã«ã§ã¯5Vã§é§åïŒãäžèŽãããããã«å¿ èŠã§ãã ç§ã®å Žåããã€ã¯ãã³ã³ãããŒã©ã3.3Vã§é§åããããããåè·¯ãç°¡çŽ åã§ããŸããã念ã®ãããããŒãäžã®å ã®åè·¯ãšé¢å©ããŸããã
ãã€ã¯ãã³ã³ãããŒã©ãŒã®ãã€ã³ãã£ã³ã°ã«ã¯èå³æ·±ããã®ã¯ãããŸããã
æåŸã®ä»äžãã¯ã³ãã¯ã¿ã§ã
å®éãUSBãµããŒããåããATTiny85ãšããªããŠã ããããªãŒãåããé»æºã³ã³ãããŒã©ãŒã§ããã®ãããªãããã°ããŒããæã«å ¥ããŸããã ãããã£ãŠãLEDã«ã©ã€ã³ãåºåããã ãã«ãšã©ãŸããŸããã§ããã 代ããã«ããã€ã¯ãã³ã³ãããŒã©ãŒã®ãã¹ãŠã®ã©ã€ã³ãããã«æã£ãŠããŸãã-åæã«ããã°ã©ããŒã«æ¥ç¶ãããšäŸ¿å©ã§ãã
ãããŠãã»ãŒãã¹ãŠã®åç·ãç¹å®ã®æ©èœïŒPB1-ä¿çåç·ãPB2-é»æºãã¿ã³ãPB3 / PB4-USBãPB5-ãªã»ããïŒã«å³å¯ã«çµã³ä»ããŠãå°æ¥ãããã€ãã®å¶éããã€ãã¹ã§ããããã«ããŸãã ããšãã°ãUSBã±ãŒãã«ãã¯ãã ä»ããããPB3 / PB4ã©ã€ã³ã解æŸããªãã§ãã ããã ãŸãã¯ãããšãã°ããªã»ãããäžæ¢ããŠPB5ã解æŸããŸãã ãããŸã§ã®éãPB0ã®ã¿ãããªãŒã®ãŸãŸã§ãLEDãæ¥ç¶ããŸãã
ããŒãã«æž¡ããŸãã 40x40mmã®ããŒãã®ãµã€ãºãã³ã³ããŒãã³ãã®æ°ãPT1502ãããã®QFN20ããŠãžã³ã°ã®å¶éãèãããšãããŒããèªå® ã§è£œé ããããšããèããŠããŸããã§ããã ãããã£ãŠãç§ã¯ããã«æãã³ã³ãã¯ããª2å±€ããŒããç¹æ®ãå§ããŸããã ããã¯ç§ãåŸããã®ã§ã
䜿ããããã®ããã«ãè£åŽã§ãã¹ãŠã®å¯èœãªåºåæ©èœã«çœ²åããŸããïŒã¢ã€ãã¢ã¯DigisparkããŒãã«åŒã£ããã£ãŠããŸãïŒ
JLCPCBã§ããŒãã泚æããŸãã ã æ£çŽãªãšãããå質ã«ããŸãæºè¶³ããŠããŸãããããããäœåºŠãã¯ãã ä»ããããšãPT1502ã®å°ããªæ¥ç¹ã®è¿ãã®ãã¹ã¯ãå°ãæã£ãŠããŸããŸãã ããŠãå°ããªç¢æãå°ãæµ®ããã§ããŸããã ãã ãããã¹ãŠãåããŠã¯ãã ä»ããããå Žåã¯ãæšæºã§ãã
QFN20ãã¯ãã ä»ãããã«ã¯ãã¯ãã ããŠãå¿ èŠã§ããä»ã®ãã¹ãŠã®ãã®ã¯ãç¹å®ã®ã¯ãã ããŠã§ç¹å®ã®ã¹ãã«ã§ã¯ãã ä»ãã§ããŸãã ããã¯ãã¯ãã ä»ããããããŒãã®å€èŠ³ã§ã
æ¬äœ
身äœã«ç§»ãæã§ãã 3Dããªã³ã¿ãŒã§å°å·ããŸããã 食ãæ°ã®ãªããã¶ã€ã³-ããã¯ã¹ãšãã¿ã³ã ãã¶ã€ããŒã®æšæºçãªæ£æ¹åœ¢ã¢ãžã¥ãŒã«ã«ãã¿ã«ãã€ã³ã¹ããŒã«ããããã®ç¹å¥ãªããã¯ãããã¯ã¹ã«çšæãããŠããŸãã
ã¡ã€ã³ããŒããšããããªãŒã¯ã±ãŒã¹ã«åçŽãããŠããŸãã
LEDããã«ã¯ã«ããŒã«åãä»ããããŠãããã«ããŒã¯ã¡ã€ã³ããã¯ã¹ã«ããžã§åºå®ãããŠããŸã
æåã¯ããžã§LEDããã«ãã«ããŒã«ãã蟌ãããšãèããŠããŸããããæçµçã«ã¯äž¡é¢ããŒãã«è²Œãä»ããŸããã ãã®ããã«ãªã£ã
ãã®åœ¢åŒã§ã¯ãããã€ã¹ã¯ãã§ã«äœ¿çšã§ããŸãããããã§ãstillãããã«èŠããŸã-ååãªãã£ãã¥ãŒã¶ãŒããããŸããã
ç§ã¯ã建ç©ã®ãã©ã€ã€ãŒã§ã®ãããããã«ã®åçž®ã®æè¡ã䜿çšããŠããã£ãã¥ãŒã¶ãŒã®æåã®ããŒãžã§ã³ãäœãããšããŸããïŒèªç©ºæ©ã®ã¢ãã«ã§èŠããŸããïŒã
ãã®ãããæåã«ç©ºçœãå¿ èŠã§ãã ç§ã¯ç³èãããããäœããããã3Dããªã³ã¿ãŒã§å°å·ãããã©ãŒã ã«æ³šããŸããã æåã®ããŒãžã§ã³ã§ã¯ãéåã¯ã¯ã³ããŒã¹ã§ããã£ã¹ããã£ã¹ã¯ãåãåºãããšãã§ããŸããã§ããã ãã®ããã2ããŒã¹ã®ãã©ãŒã ãäœæããå¿ èŠããããŸããã
ãã®æ¹æ³ã®èãæ¹ã¯æ¬¡ã®ãšããã§ãã ãããŒãšãŒã°ã«ãã®ããã«ããã©ã³ã¯ã®äžã«çœ®ãã建èšçšãã¢ãã©ã€ã€ãŒãšäžç·ã«åº§ããŸãã ããã¯ãç°ãªãçä¹³ã®äžãã20åã®ç°ãªã容åšã®äžéšãå移æ€ããã ãã§ããæãç®ã泡ã®ãªããã®ãã®ãããŸãé 眮ããããšã¯ã§ããŸããã§ããã ã©ããããäœããã®çç©ºè£ çœ®ããã§ã³ã¹ã§å²ã¿ããã©ã¹ããã¯ã·ãŒããåãä»ããå¿ èŠããããŸãã äžè¬çã«ããã®ãããªæè¡ã«ã¯é£ããããããšãå€æããŸããã
ããªããºããäžå¹³ãèšã£ãåŸãæ°ã¡ãŒãã«ã®Verbatim PET Transparentãã©ã¹ããã¯ãããŒããèŠã€ããŸããã ãã å°å·ããããã«ãã£ãã¥ãŒã¶ãŒãè©Šãããšã«ããŸããã ããªã³ã¿ã®å ¥ãå£ã§ã¯ãã©ã¹ããã¯ã¯éæã«èŠããŸãããå®éã®éšåã¯ãããã§ãã ããã¯ãããããå éšæ§é ã«ãããã®ã§ãã ã¬ã€ã€ãŒã¯ããªã¥ãŒã ãå®å šã«ã¯åããŸããããã®ã£ãããã®ã£ãããšéãªããŸãã ããã«ãè¡šé¢ãããæ»ããã«ããããã«ãµã³ãããŒããŒã§éšåãåŠçããããšãããšãããã«ããããããããŸãã ãã ããããã¯ãŸãã«ç§ãå¿ èŠãšãããã®ã§ãã
ç§ã¯ãã£ãã¥ãŒã¶ãŒã®ããŠã³ããæ°ã«ããã®ãé¢åã ã£ãã®ã§ããããã°ã«ãŒã«è¿œå ããŸããã ãããã£ãŠãç§ã®ãã¶ã€ã³ã¯æ¡ä»¶ä»ãã§æãããã¿å¯èœã«ãªããŸããã ããçš®ã®ã©ããã®çºæãšæ··åãããå¯èœæ§ããããŸããããã§ã«éæãªãã©ã¹ããã¯ãããŒããäžè¶³ããŠããŸãã ããã§ãããã¡ã«ãã«ããŸãããã
ãã¡ãŒã ãŠã§ã¢
LEDãŠã€ã³ã«ãŒã®å Žåãç¹ã«ãã€ã¯ãã³ã³ãããŒã©ãŒã®åšèŸºã«é£ã³èŸŒãå¿ èŠã¯ãããŸãããGPIOãæäœããããã®æ©èœã¯2ã€ããã°ååã§ãã ããããã¢ãžã¥ãŒã«ã¯Arduinoãã©ãããã©ãŒã ã«ãããã³ã°ãããŠããã®ã§ãããã掻çšããŠã¿ãŸãããïŒ
æåã«ãããã€ãã®å®çŸ©ãšå®æ°
// Number of total LEDs on the board. Mine has 4x4 LEDs #define NUM_HW_PIXELS 16 // Pin number where LED data pin is attached #define DATA_PIN 0 // Pin number where mode switch button is attached #define BUTTON_PIN 2 // Power Enabled pin #define POWER_EN_PIN 1 // Max brightness (dimming the light for debugging) #define MAX_VAL 255
ããã«ããããããªãã¯ã¹ã®ãã¯ã»ã«æ°ããã³çªå·ãããã³LEDã®æ倧èŒåºŠã決ãŸããŸãïŒãããã°äžã¯ãç®ãç²ç®ã«ããªãããã«50ã«èšå®ãããšäŸ¿å©ã§ããïŒ
ç§ã®ãããªãã¯ã¹å ã®LEDã¯ããžã°ã¶ã°ãšããããªãéèªæãªæ¹æ³ã§é 眮ãããŠããŸãã ãããã£ãŠãããŸããŸãªå¹æã®ããã«ãçªå·ãä»ãçŽãå¿ èŠããããŸããã
// LED indexes for different patterns uint8_t circleLEDIndexes[] = {0, 1, 2, 3, 4, 11, 12, 13, 14, 15, 8, 7}; uint8_t beaconLEDIndexes[] = {6, 5, 10, 9}; uint8_t policeLEDIndexes[] = {7, 6, 10, 11, 4, 5, 9, 8};
LEDãå¶åŸ¡ããããã«ãç§ã¯èªè»¢è»ãçºæãããWS8211 LEDãæäœããããã®æ¢è£œã®ã©ã€ãã©ãªãçšæããŸãã ã ã©ã€ãã©ãªã€ã³ã¿ãŒãã§ãŒã¹ã¯ãããã«çœå¡ããããŠããŸãã ããã€ãã®è£å©æ©èœïŒããšãã°ãHSVããRGBãžã®å€æïŒãããã«çãŸããŸããã
æåã«ãããŒããšWS8211ã©ã€ãã©ãªãåæåããå¿ èŠããããŸãã
// Driver Ai_WS2811 ws2811; void setup() { // Set up power pinMode(POWER_EN_PIN, OUTPUT); digitalWrite(POWER_EN_PIN, HIGH); // initialize LED data pin pinMode(LED_PIN, OUTPUT); // Initialize button pin pinMode(BUTTON_PIN, INPUT); // Initialize WS8211 library static CRGB ledsBuf[NUM_HW_PIXELS]; ws2811.init(DATA_PIN, NUM_HW_PIXELS, ledsBuf); // Set the watchdog timer to 2 sec wdt_enable(WDTO_2S); }
ãŸããPOWER HOLDä¿¡å·ã1ã«èšå®ããå¿ èŠããããŸããããã¯ããã€ã¯ãã³ã³ãããŒã©ãŒãå·»ãäžããããæ£åžžã«åäœããŠããããšã瀺ãPT1502ããããžã®ä¿¡å·ã«ãªããŸãã 次ã«ãHOLDä¿¡å·ã1ã«èšå®ããããŸã§ããã€ã¯ãåè·¯ã¯ãã€ã¯ãã³ã³ãããŒã©ãŒãšLEDã«å®æçã«é»åãäŸçµŠããŸãã
次ã«ãåºåã®LEDãšå ¥åã®ãã¿ã³ãå¶åŸ¡ããããã®èãæ§æããŸãã ãã®åŸãWS8211ã©ã€ãã©ãªãåæåã§ããŸãã
ããã¯ããªãèªåŸçãªããã€ã¹ã§ããããããã€ã¯ãã³ã³ãããŒã©ãŒãç解ã§ããªãç¶æ ã«åºå·ããããããªãŒå šäœãæ¶èãããããšã¯äžå¯èœã§ãã ãããè¡ãã«ã¯ããŠã©ããããã°ã¿ã€ããŒã2ç§éèµ·åããŸãã ã¿ã€ããŒã¯ã¡ã€ã³ããã°ã©ã ã«ãŒãã§åèµ·åããŸãã
ããã§ãããã€ãã®è£å©é¢æ°ãå®çŸ©ããå¿ èŠããããŸãã WS8211ã©ã€ãã©ãªã¯ãåLEDã®è²ã®å€ãå«ããããã¡ãä¿åããŸãã ç¹å®ã®LEDã«RGBå€ãæžã蟌ãããã®åçŽãªé¢æ°ãäœæããããããããã¡ãçŽæ¥æäœããããšã¯ããŸã䟿å©ã§ã¯ãããŸããã
void setRgb(uint8_t led_idx, uint8_t r, uint8_t g, uint8_t b) { CRGB * leds = ws2811.getRGBData(); leds[led_idx].r = r; leds[led_idx].g = g; leds[led_idx].b = b; }
ããããã»ãšãã©ã®å ŽåãRGBã«ã©ãŒã¢ãã«ã§ã¯ãè²ã®ã«ãŠã³ãã¯ããŸã䟿å©ã§ã¯ãªããäžå¯èœã§ãã ããšãã°ãããããçš®é¡ã®è¹ãæãå ŽåãHSVã«ã©ãŒã¢ãã«ã䜿çšãããšäŸ¿å©ã§ãã åãã¯ã»ã«ã®è²ã¯ãè²èª¿ãšæããã®å€ã«ãã£ãŠèšå®ãããŸãã ç°¡åã«ããããã«åœ©åºŠã¯çç¥ãããŠããŸãïŒæ倧å€ã䜿çšãããŸãïŒã è²çžå€ã¯ãïŒæšæºã®0-359ã§ã¯ãªãïŒ0-255ã®ç¯å²ã«çž®å°ãããŸãã
/** * HVS to RGB conversion (simplified to the range 0-255) **/ void setHue(uint8_t led_idx, int hue, int brightness) { //this is the algorithm to convert from RGB to HSV double r = 0; double g = 0; double b = 0; double hf = hue/42.6; // Not /60 as range is _not_ 0-360 int i=(int)floor(hue/42.6); double f = hue/42.6 - i; double qv = 1 - f; double tv = f; switch (i) { case 0: r = 1; g = tv; break; case 1: r = qv; g = 1; break; case 2: g = 1; b = tv; break; case 3: g = qv; b = 1; break; case 4: r = tv; b = 1; break; case 5: r = 1; b = qv; break; } brightness = constrain(brightness, 0, MAX_VAL); setRgb(led_idx, constrain(brightness*r, 0, MAX_VAL), constrain(brightness*g, 0, MAX_VAL), constrain(brightness*b, 0, MAX_VAL) ); }
ãã®é¢æ°ã¯Ai_WS8211ã©ã€ãã©ãªããååŸããããããã«ãã¡ã€ã«ãããŠããŸãã ã©ã€ãã©ãªã®ãã®é¢æ°ã®å ã®ããŒãžã§ã³ã«ã¯ãè¹ã®è²ãããããã§è¡šç€ºãããŠããããã€ãã®ãã°ããããŸããã
ããŸããŸãªå¹æã®å®è£ ã«ç§»ããŸãããã åé¢æ°ã¯ã¡ã€ã³ã«ãŒãããåŒã³åºããã1ã€ã®ããã¬ãŒã ããæç»ããŸãã åãšãã§ã¯ãã¯åŒã³åºãéã§ç°ãªããã©ã¡ãŒã¿ãŒã§åäœãããããéçå€æ°ã«æ ŒçŽãããŸãã
ãããæãç°¡åãªå¹æã§ãããã¹ãŠã®LEDã1è²ã§å¡ãã€ã¶ãããŠãããæ»ããã«å€åããŸãã
void rainbow() { static uint8_t hue = 0; hue++; for (int led = 0; led < NUM_HW_PIXELS; led++) setHue(led, hue, MAX_VAL); ws2811.sendLedData(); delay(80); }
次ã®å¹æã¯ããèå³æ·±ã-ãããªãã¯ã¹ã®èŒªéã«æ²¿ã£ãŠè¹ã衚瀺ããè¹ã®è²ãåŸã ã«åã«ã·ããããŸãã
void slidingRainbow() { static uint8_t pos = 0; pos++; for (int led = 0; led < ARRAY_SIZE(circleLEDIndexes); led++) { int hue = (pos + led*256/ARRAY_SIZE(circleLEDIndexes)) % 256; setHue(circleLEDIndexes[led], hue, MAX_VAL); } ws2811.sendLedData(); delay(10); }
ãããŠããã®å¹æã¯ããããªãã¯ã¹å šäœãã©ã³ãã ãªè²ã§å¡ãã€ã¶ããŸããã©ã³ãã ãªè²ã¯ãæåã¯æ»ããã«ç¹ç¯ãã次ã«æ»ããã«æ¶ããŸãã
void randomColorsFadeInOut() { static uint8_t color = 0; static bool goesUp = false; static uint8_t curLevel = 0; if(curLevel == 0 && !goesUp) { color = rand() % 256; goesUp = true; } if(curLevel == MAX_VAL && goesUp) { goesUp = false; } for(int led = 0; led < NUM_HW_PIXELS; led++) setHue(led, color, curLevel); if(goesUp) curLevel++; else curLevel--; ws2811.sendLedData(); delay(10); }
次ã®ã°ã«ãŒãã®ãšãã§ã¯ãã¯ãç°ãªãç¹æ» ããŒã³ã³ãæç»ããŸãã ãããã£ãŠãããšãã°ãåäŸã¯ç£ç³ã§ãã«ããŒã¶ãŒãäœãã®ã奜ãã§ãããã§ãªã¬ã³ãžè²ã®ãã©ãã·ã£ãŒãéåžžã«åœ¹ç«ã¡ãŸãã
void orangeBeacon() { const int ORANGE_HUE = 17; static uint8_t pos = 0; pos+=3; for (int led = 0; led < ARRAY_SIZE(circleLEDIndexes); led++) { int brightness = brightnessByPos(pos, led*255/ARRAY_SIZE(circleLEDIndexes), 70); setHue(circleLEDIndexes[led], ORANGE_HUE, brightness); } ws2811.sendLedData(); delay(1); }
æè¡çã«ã¯ãå¹æã¯ãããªãã¯ã¹ã«æ²¿ã£ãŠç§»åããæãããããã®ããã«èŠããŸãã ããããèŠãç®ãçŸããããããã«ãã¡ã€ã³ãã€ã³ãããé¢ãããšãé£æ¥ããLEDã¯åŸã ã«æ¶ããŠãããŸãã ãããã£ãŠããã®åãæãããèšç®ããé¢æ°ãå¿ èŠã§ããã
int brightnessByPos(int pos, int ledPos, int delta) { int diff = abs(pos - ledPos); if(diff > 127) diff = abs(256-diff); int brightness = MAX_VAL - constrain(MAX_VAL*diff/delta, 0, MAX_VAL); return brightness; }
Posã¯ãæããã®èŒç¹ã®ç¹å®ã®æ¡ä»¶ä»ãäœçœ®ã§ãããã«ãŒãããã¯ç¯å²0ã255ã«ãããã³ã°ãããŸãã ledPosã¯ãèŒåºŠãèšç®ããå¿ èŠãããLEDïŒåãç¯å²ã«è¡šç€ºãããïŒã®äœçœ®ã§ãã äœçœ®ã®å·®ããã«ã¿ãã倧ããå ŽåãLEDã¯ç¹ç¯ãããäœçœ®ã«è¿ã¥ãã»ã©æãããªããŸãã
ãŸãã¯ãããšãã°ãèŠå¯ã®èµ€éç¹æ» ã©ã€ã
void policeBeacon() { const int RED_HUE = 0; const int BLUE_HUE = 170; static uint8_t pos = 0; pos += 2; for (int led = 0; led < ARRAY_SIZE(policeLEDIndexes); led++) { int ledPos = led*255/ARRAY_SIZE(policeLEDIndexes); int brightness = brightnessByPos(pos, ledPos, 50); setHue(policeLEDIndexes[led], RED_HUE, brightness); if(brightness == 0) { brightness = brightnessByPos((pos+100) % 256, ledPos, 50); setHue(policeLEDIndexes[led], BLUE_HUE, brightness); } } ws2811.sendLedData(); delay(1); }
è»ã«ã€ããŠè©±ããŠããã®ã§ãããã®ä¿¡å·æ©ã¯å®è£ ããã®ã«åé¡ã§ã¯ãããŸããã
ãããã¯ãããŸããŸãªäœçœ®ã«ããŸããŸãªäº€éä¿¡å·ãå«ãæ©èœã§ãã
void clearPixels() { for(int i=0; i<NUM_HW_PIXELS; i++) { setRgb(i, 0, 0, 0); } } void redTrafficLights() { for(int i=0; i<4; i++) setRgb(i, MAX_VAL, 0, 0); ws2811.sendLedData(); } void yellowTrafficLights() { for(int i=4; i<8; i++) setRgb(i, MAX_VAL, MAX_VAL, 0); ws2811.sendLedData(); } void greenTrafficLights() { for(int i=8; i<16; i++) setRgb(i, 0, MAX_VAL, 0); ws2811.sendLedData(); }
ããã埩掻ãããæãæ¥ãŸããã ä¿¡å·æ©ã¯ãäžçš®ã®ãã€ãã³ãŒãã§å®çŸ©ãããç¹å¥ãªããã°ã©ã ã«åŸã£ãŠåäœããŸãã ãã¬ãŒãã«ã¯ãã¢ãŒããšããã®ã¢ãŒãããªã³ã«ããå¿ èŠã®ããæéãèšèŒãããŠããŸãã
enum TRAFFIC_LIGHTS { NONE, RED, YELLOW, GREEN }; struct trafficLightState { uint8_t state; uint16_t duration; }; const trafficLightState trafficLightStates[] = { {NONE, 1}, // clear yellow {RED, 7000}, // red {YELLOW, 2000}, // red + yellow {NONE, 1}, // clear red+yellow {GREEN, 7000}, // green {NONE, 300}, // Blinking green {GREEN, 300}, // Blinking green {NONE, 300}, // Blinking green {GREEN, 300}, // Blinking green {NONE, 300}, // Blinking green {GREEN, 300}, // Blinking green {NONE, 1}, // clear green {YELLOW, 2000}, // yellow };
å®éã«ããããã¹ãŠåŠçããæ©èœ
void trafficLights() { static uint8_t curStateIdx = 0; static unsigned long curStateTimeStamp = 0; // Switch to a new state when time comes if(millis() - curStateTimeStamp > (unsigned long)trafficLightStates[curStateIdx].duration) { curStateIdx++; curStateIdx %= ARRAY_SIZE(trafficLightStates); curStateTimeStamp = millis(); } switch(trafficLightStates[curStateIdx].state) { case NONE: clearPixels(); ws2811.sendLedData(); break; case RED: redTrafficLights(); break; case YELLOW: yellowTrafficLights(); break; case GREEN: greenTrafficLights(); break; default: break; } // Just waiting delay(10); }
èšå®ããæéééã«éãããšã次ã®ä¿¡å·ã¢ãŒãããªã³ã«ãªããã«ãŠã³ãããŠã³ãåã³éå§ãããŸãã
ç§ã®æ³ååã§ååã ã£ãæåŸã®å¹æã¯ã¢ã¹ã¿ãªã¹ã¯ã§ãã 5åã®ã©ã³ãã LEDãã©ã³ãã ãªæããã§ç¹ç¯ããŠãããã¹ã ãŒãºã«æ¶ç¯ããŸãã 1ã€ã®æãæ¶ãããšãã©ã³ãã ãªå Žæã«ããå¥ã®æãç¹ç¯ããŸãã
void stars() { const uint8_t numleds = 5; static uint8_t ledIndexes[numleds] = {0}; static uint8_t curVal[numleds] = {0}; static uint8_t maxVal[numleds] = {0}; for(int i=0; i<numleds; i++) { if(ledIndexes[i] == 0) { uint8_t led = rand() % (NUM_HW_PIXELS+1); CRGB * leds = ws2811.getRGBData(); if(leds[led].r == 0) { ledIndexes[i] = led; maxVal[i] = rand() % (MAX_VAL-1) + 1; curVal[i] = 0; } } else { uint8_t led = ledIndexes[i]; if(curVal[i] < maxVal[i]) curVal[i]++; else if(curVal[i] == maxVal[i]) maxVal[i] = 0; else if(curVal[i] == 0 || --curVal[i] == 0) ledIndexes[i] = 0; setRgb(led-1, curVal[i], curVal[i], curVal[i]); } } ws2811.sendLedData(); delay(80); }
ããã®ã©ããã«éªæªãªãã°ãå¿ã³èŸŒãã§ããŸããã æã ãæãéãç¹ç¯ããããéã«çªç¶æ¶ãããããŸãã ããããæ£çŽãªãšãããç§ã¯ããã«å¯ŸåŠããã®ãé¢åã§ãã-ããã¯éåžžã«æ®éã«èŠããŸãã
ããããªãŒã®ç¯çŽã«ã€ããŠèããæãæ¥ãŸããã ç§ã¯ãã§ã«ãã®ãã¹ãŠã®æ¶è²»äŸ¡å€ãäžããŠããŸãã é»æºãåãããšãèããªãå ŽåãLEDã¯æ°æéã§ããããªãŒãæ¶èããŸãã ãã®æ©èœã¯ã90ç§éäœãæäœããªããšé»æºãåã圹å²ãæãããŸãã æåã¯60ç§ã§ããããå®éã®ã²ãŒã ã§ã¯ããã§ã¯ååã§ã¯ãªãã2åã¯ãã§ã«äœãšãé·ãããšãããããŸããã
void shutdownOnTimeOut(bool resetTimer = false) { static unsigned long periodStartTime = 0; if(periodStartTime == 0 || resetTimer) { periodStartTime = millis(); return; } if(millis() - periodStartTime >= 90000UL) { periodStartTime = 0; shutDown(); } }
å®éã«ã¯ã次ã®ããã«é»æºãåããŸãã
void shutDown() { clearPixels(); ws2811.sendLedData(); wdt_disable(); digitalWrite(POWER_EN_PIN, LOW); // No power after this point while(true) ; }
ãŠãŒã¶ãŒããã¿ã³ãæŒããšãã¿ã€ããŒããªã»ãããããŸãã èšå®æéãçµéãããšããã®é¢æ°ã¯HOLDä¿¡å·ããŒãã«èšå®ããŸããããã¯ãé»æºããªãã«ããPT1502ã³ãã³ãã§ãã ã¡ãªã¿ã«ããŠã©ããããã°ãåæ¢ããå¿ èŠããããŸããåæ¢ããªããšã2ç§åŸã«ã·ã¹ãã ããŠã§ã€ã¯ã¢ãããããé»æºãåã³ãªã³ã«ãªããŸãã
æåŸã«ããã¹ãŠãéå§ããã¡ã€ã³ã«ãŒã
// List of pointers to functions that serve different modes void (*Modes[])() = { rainbow, slidingRainbow, orangeBeacon, policeBeacon, trafficLights, stars, randomColorsFadeInOut }; void loop() { static uint8_t mode = eeprom_read_byte( (uint8_t*) 10 ); static bool waitingForBtnUp = false; static long btnPressTimeStamp; // Button switches mode if(digitalRead(BUTTON_PIN) == HIGH && !waitingForBtnUp) { delay(20); if(digitalRead(BUTTON_PIN) == HIGH) { mode++; mode %= ARRAY_SIZE(Modes); // num modes clearPixels(); ws2811.sendLedData(); delay(1); eeprom_write_byte( (uint8_t*) 10, mode ); waitingForBtnUp = true; btnPressTimeStamp = millis(); shutdownOnTimeOut(true); } } // Shut down on long press over 5s if(digitalRead(BUTTON_PIN) == HIGH && waitingForBtnUp && millis() - btnPressTimeStamp > 5000) shutDown(); // Detect button release if(digitalRead(BUTTON_PIN) == LOW && waitingForBtnUp) waitingForBtnUp = false; // display LEDs according to current mode Modes[mode](); // pong shutdown timer shutdownOnTimeOut(); // Yes, we still alive wdt_reset(); }
ãã¿ã³ãæŒããšãã¢ãŒããåãæ¿ãããèªåãªãã¿ã€ããŒããªã»ãããããŸãã çŸåšã®ã¢ãŒãã«å¿ããŠããã¢ãŒãããªã¹ãã®ãšãã§ã¯ãæ©èœã®1ã€ãèµ·åããŸãã åãµã€ã¯ã«ã§ããŠã©ããããã°ããªã»ãããããŸãã
ããšãã°ãåäŸãããã«ãŒããã¬ã€ããŠããŠã1.5ååŸã«éåžžç¯ããªãã«ãªã£ãå Žåã2çªç®ã®ã¿ãŒã³åŸã«æ¯åãããã«ãŒããã¬ã€ãç¶ããå¯èœæ§ãé«ããªããŸãã ãããè¡ãã«ã¯ãéžæããã¢ãŒããEEPROMã«ä¿åãããŸãïŒã»ã«çªå·10ã¯ãã«ããŒã¶ãŒããéžæãããŸãïŒã
ããããã¹ãŠã®ä»çµã¿ã瀺ããããªã§ãã
ããŒãããŒããŒ
ã»ãšãã©ãã¹ãŠã®æºåãæŽããŸããã ããããæåºããå¿ èŠããããã1ã€ã®ãã®ããããŸã-ããŒãããŒããŒã å®éã«ã¯ãæšæºã®ããŒãããŒããŒã¯ç§ãã¡ã«é©ããŠããªããšããããšã§ãã
ãŸããé»æºãå ¥ãããšã6ç§éåŸ æ©ããŸã-ãã¡ãŒã ãŠã§ã¢ãé»æºãå ¥ãå§ããå¯èœæ§ããããŸãã ãã®å¶åŸ¡ãã¡ã€ã³ãã¡ãŒã ãŠã§ã¢ã«è»¢éãããåŸã«ã®ã¿ã ããã¯éçºæ®µéã§ã¯äŸ¿å©ã§ãããå®æããããã€ã¹ã§ã¯è¿·æã«ãªããŸãã
次ã«ãæšæºã®ããŒãããŒããŒã¯PT1502ãããã«ã€ããŠäœãèªèããŠããŸãããããã¯ãHOLDã·ã°ãã«ãäžãããšäŸ¿å©ã§ãã ãã®ä¿¡å·ããªããã°ããã€ã¯ãåè·¯ã¯ããã€ã¯ãã³ã³ãããŒã©ãèµ·åããªãã£ããããŸãã¯éã«ãªãã«ããããšèããŠããŸãã ãããããªããæ°ããªç§åŸã«PT1502ã¯åè·¯å šäœãžã®é»åãé®æããŸãã
äž¡æ¹ã®åé¡ãä¿®æ£ããããšã®å©ç¹ã¯é£ãããããŸããã digispark ATTiny85ã¯å°æ žããŒãããŒããŒã䜿çšããŸã ã ãã®ããŒãããŒããŒã¯ãå¿ èŠã«å¿ããŠãã¡ã€ã«ãäœæããã®ãéåžžã«ç°¡åã§ãã æ§æãã¡ã€ã«å ã®å¯Ÿå¿ããå®çŸ©ãä¿®æ£ããã ãã§ãã
ãŸããæšæºãã¡ãŒã ãŠã§ã¢\ configuration \ t85_default configurationãèªåã®ãã£ã¬ã¯ããªã«ã³ããŒãããã§ã«ãã¹ãŠã®å€æŽãå ããŸããã ãã®ãããå ã®ããŒãããŒããŒã«ç°¡åã«ããŒã«ããã¯ã§ããŸãã
bootloaderconfig.hãã¡ã€ã«ã«ã¯ãããŒãããŒããŒã«å ¥ãæ¹æ³ã®éžæããããŸãã ç®±ããåºããŠæäŸããããã®ãããç§ãã¡ã«é©ãããã®ã¯ãããŸããããæãè¿ããªãã·ã§ã³ã¯ENTRY_JUMPERã§ãã ãã®ããŒãžã§ã³ã§ã¯ãç¹å®ã®ã¬ãã«ãç¹å®ã®ãã³ã«è¡šç€ºãããŠããå Žåã«ã®ã¿ããŒãããŒããŒã«ã¢ã¯ã»ã¹ããŸãïŒããŒãäžã§ãžã£ã³ããŒãéããããŸãïŒã
#define ENTRYMODE ENTRY_JUMPER
ãžã£ã³ããŒã¯ãããŸããããPB2ã®èã«ãã¿ã³ããããŸãã é»æºããªã³ã«ãªã£ããšãã«ãã¿ã³ã5ã7ç§éæŒãç¶ãããšãããŒãããŒããŒãèµ·åããŸãã ãã ããæŒããŠé¢ããšãã¡ã€ã³ãã¡ãŒã ãŠã§ã¢ãžã®ç§»è¡ãããã«è¡ãããŸãã
3ã€ã®é¢æ°ãå®çŸ©ããå¿ èŠããããŸã-åæåãåæå解é€ããããŠå®éã«ããŒãããŒããŒã«å ¥ãæãã©ããã®ç¢ºèªã ãªãªãžãã«ã§ã¯ããããã¯ãã¹ãŠã·ã³ãã«ã§ããã¯ãã§å®è£ ãããŠããŸãã æåã®2ã€ã ããã·ã³ãã«ã«ãªããŸã
#define HOLD_PIN PB1 #define JUMPER_PIN PB2 #define JUMPER_PORT PORTB #define JUMPER_DDR DDRB #define JUMPER_INP PINB #define bootLoaderInit() {JUMPER_DDR &= ~_BV(JUMPER_PIN); JUMPER_DDR |= _BV(HOLD_PIN); JUMPER_PORT &= ~_BV(JUMPER_PIN); JUMPER_PORT |= _BV(HOLD_PIN); _delay_ms(1);} #define bootLoaderExit() {;}
bootLoaderInitïŒïŒã¯ããã¿ã³ãã³ïŒJUMPER_PINïŒããµã¹ãã³ããŒã«å ¥ãããã«èšå®ãããªãã«ããŸãã ããã«ãããŒãäžã®ãã«ã¢ãããæ¢ã«å°é¢ã«ããããã³ã®ãã¿ã³ãæŒããšãå察ã«ãã¿ã³ããããŸãã åæã«ãããã«ããŒã«ãä¿¡å·ãèšå®ããŠåºåãããŠããããèšå®ããããšãã§ããŸã...
ãããæŒç®ã®èª¬æã«ã€ããŠã¯ãããšãã°ãããåç §ããŠãã ãããAVRã³ã³ãããŒã©ãŒã®GPIOã»ããã¢ããã¬ãžã¹ã¿ã«ã€ããŠã¯ãããšãã°ããããåç §ã§ããŸã ã
bootLoaderExitïŒïŒé¢æ°ã¯ç©ºã§ã å ¬éãããæ§æã¯ãã¡ã€ã³ãã¡ãŒã ãŠã§ã¢ãžã®åŸç¶ã®ç§»è¡ã«éåžžã«é©ããŠããŸã
bootLoaderStartConditionïŒïŒé¢æ°ã¯ãããŒãããŒããŒããã¯ã圢åŒã§å ¥åãã圹å²ãæ ã£ãŠããŸãããé©åããŠããªããããæ¬æ Œçãªæ©èœã«ãªããŸããã
#ifndef __ASSEMBLER__ // Bootloader condition is to hold the button for 5 seconds inline unsigned char bootLoaderStartCondition() { long int i; for(i=0; i<10000000; i++) if( !(JUMPER_INP & _BV(JUMPER_PIN))) return 0; return 1; } #endif
æ°ç§ä»¥å ïŒå®éã«ã¯çŽ6ã7ïŒã«é¢æ°ããã¿ã³ã®ã¹ããŒã¿ã¹ããã§ãã¯ããŸãã ãã¿ã³ã以åã«ãªãªãŒã¹ãããå ŽåãããŒãããŒããŒã«å ¥ãå¿ èŠã¯ãããŸããã æ£è ãšæ°žç¶çãªããŒãããŒããŒã«èš±å¯ãããŠããŸãã
å€æããããã«ãbootloaderconfig.hãã¡ã€ã«ã¯ã¢ã»ã³ãã©ãã¡ã€ã«ã®ã³ã³ãã€ã«ã«é¢äžããŠããããã®ãã¡ã€ã«å ã®ã³ãŒãããšã©ãŒãåŒãèµ·ãããŸãã é¢æ°ã#ifndef __ASSEMBLER__ãããã¯ã«å ¥ããå¿ èŠããããŸãã
ç§ã埮調æŽããå¥ã®ãã©ã¡ãŒã¿ãŒã¯ãUSBã«æ¥ç¶ãããŠããªãå Žåã®å¯ŸåŠæ¹æ³ãããŒãããŒããŒã«æ瀺ããŸã-1ç§åŸã«çµäºããŸãã å®éã«ã¯ãäŸµå ¥äžã«ãæ¯åããã¿ã³ãæŒãããšãå€ãã誀ã£ãŠããŒãããŒããŒã«äŸµå ¥ããããšããããŸãã ã©ãã»ã©å¥è·¡çãã¯ããããŸããããããŒãããŒããŒãUSBæ¥ç¶ãèªèããªããšã誀ã£ãŠäžéšã®ã¡ã¢ãªããŒãžãäžæžããããå¯èœæ§ããããŸãã ãããã£ãŠãæ¥ç¶ããªãå Žåãåã«ã¡ã€ã³ããã°ã©ã ã«æ»ããŸãã
/* * Define bootloader timeout value. * * The bootloader will only time out if a user program was loaded. * * AUTO_EXIT_NO_USB_MS The bootloader will exit after this delay if no USB is connected. * Set to 0 to disable * Adds ~6 bytes. * (This will wait for an USB SE0 reset from the host) * * All values are approx. in milliseconds */ #define AUTO_EXIT_NO_USB_MS 1000
ã³ã³ãã€ã«ããŸã...ãããŠãå²ãåœãŠãããããŒãããŒããŒã¹ããŒã¹ã«ã³ãŒããåãŸããªããšãããšã©ãŒã衚瀺ãããŸãã ã³ã³ãããŒã©ãŒã®ãã©ãã·ã¥ã¡ã¢ãªã¯éåžžã«å°ãããããããŒãããŒããŒã¯ã¡ã€ã³ããã°ã©ã çšã«ããå€ãã®ã¹ããŒã¹ã確ä¿ããããã«æ倧éã«å§çž®ãããŸãã ãã ããããã¯Makefile.incãã¡ã€ã«ã§æ瀺ã«åŸã£ãŠç°¡åã«ä¿®æ£ã§ããŸãã
# hexadecimal address for bootloader section to begin. To calculate the best value: # - make clean; make main.hex; ### output will list data: 2124 (or something like that) # - for the size of your device (8kb = 1024 * 8 = 8192) subtract above value 2124... = 6068 # - How many pages in is that? 6068 / 64 (tiny85 page size in bytes) = 94.8125 # - round that down to 94 - our new bootloader address is 94 * 64 = 6016, in hex = 1780 BOOTLOADER_ADDRESS = 1940
次ã«ãããŒãããŒããŒã®éå§ã¢ãã¬ã¹ã1ããŒãžïŒ64ãã€ãïŒã«æžãããããŒãããŒããŒã®ã¹ããŒã¹ãå¢ãããŸããã
ãã以å€ã®å ŽåãUSBAspããã°ã©ããŒã䜿çšããŠããŒãããŒããŒãã³ã³ãã€ã«ããã³ã¢ããããŒãããããšã¯åé¡ã§ã¯ãããŸããã§ããã
ãããã«
ãã¬ããããŒãäžã®ãããã¿ã€ãããå®æããããã€ã¹ãŸã§éåžžã«èå³æ·±ãæ¹æ³ã§ããã arduinoã¬ãã¹ã³ã®æ®éã®ãŸã°ããã®ããã«èŠããŸãããå®éãäœæ¥ã®éçšã§ãç§ã¯å€ãã®èå³æ·±ãåé¡ã解決ããªããã°ãªããŸããã§ãã-æ¶è²»ãšã®éäºãèŠçŽ ããŒã¹ã®éžæãã±ãŒã¹ã®ãã¶ã€ã³ããããŠããŒãããŒããŒãåãããã¡ãŒã ãŠã§ã¢ãæãæµ®ãã¹ãŸãã ç§ã®çµéšã誰ãã«åœ¹ç«ã€ããšãå¿ããé¡ã£ãŠããŸãã
ç°¡åã ã£ãã§ããããïŒ ãã¡ããã§ããŸãã ãã©ã³ãžã¹ã¿ã§ãã¹ãŠãã§ãããšæããŸãã æ®å¿µãªãããããŒããã¯ãã ä»ãããåŸã«ãã®èšäºãèªã¿ãŸããã ç§ã¯ä»¥åã®èšäºãèŠãã ãã-ç§ã¯åã人æ°ã®TP4056ã§ãã¹ãŠãããã ãã-ãããã¯ãã ä»ãããæ¹ãç°¡åã§ãã ãšã«ããããã®ããã€ã¹ã®PT1502å ã«ããDC-DCã³ã³ããŒã¿ãŒã¯ãå¿ èŠãããŸããã ãã ããPT1502è¶ å°ååè·¯ã®å®çšçãªç 究ã¯ãQFN20ããã±ãŒãžã§è¶ å°ååè·¯ãã¯ãã ä»ãããèœåãšåæ§ã«ãä»ã®ãããžã§ã¯ãã«ã圹ç«ã¡ãŸãã
æåŸã«ãç§ã®ãããžã§ã¯ããžã®ãªã³ã¯ã¯æ¬¡ã®ãšããã§ãã
ãã¡ãŒã ãŠã§ã¢ã³ãŒã
åè·¯ãšããŒã
ã±ãŒã¹ãšãã£ãã¥ãŒã¶ãŒã¢ãã«
å°å·çšã®ããã«äœ¿ããSTLã¢ãã«