SlideShare a Scribd company logo
高師大跨領域藝術研究所
Coding with
CircuitPython@CPB
主講者:曾令燊
大綱
準備材料
佈線圖
CircuitPython簡介、安裝、實作
Q & A
2
準備材料
 Adafruit Circuit Playground Bluefruit Microcontroller Board
 Adafruit SGP30 Air Quality Sensor Breakout-VOC、eCO2
 PLANTOWER PMSA003 Laser PM2.5 Air Quality Sensor (含G7專用轉接板與連接
線--8pin 1.25mm 轉 2.54mm)
 Lithium Ion Polymer Battery - 3.7V 2000mAh(JST connector) or MB102
Breadboard Power Supply Module 3.3V/5V
 Breadboard
 Dupont Line
 Alligator-clip
 USB cable
3
佈線圖4
CircuitPython簡介
 CircuitPython is a programming language designed to simplify experimenting
and learning to program on low-cost microcontroller boards.
 CircuitPython is based on Python
 Advantage:
 Running quickly
 Easily update your code
 Serial console and REPL
5
CircuitPython安裝
 Follow the step from https://learn.adafruit.com/adafruit-circuit-playground-
bluefruit/circuitpython
 Download the latest UF2 file -- CircuitPython 6.0.0-beta.2
 Double-click the small RESET button in the middle of the CPB
 Drag the adafruit_circuitpython_xxx-6.0.0-xxx.uf2 file to CPLAYBTBOOT
 Download the latest library bundle file -- Bundle Version 6.x
 Copy the following folders and files from the bundle lib folder to the lib folder on
your CIRCUITPY drive
6
Installing Mu Editor
 Download Mu from https://codewith.mu
 Click [Download] -- Windows 64-bit
 Using Mu
7
CircuitPython實作
 Blinking the D13 LED -- https://learn.adafruit.com/adafruit-circuit-playground-
bluefruit/creating-and-editing-code
 Copy Code
 Paste the code into Mu editor
 Save as code.py on your CIRCUITPY drive
 Connecting to the Serial Console – print("Hello, world!")
 The REPL
 Press any key to enter the REPL
 Use Ctrl+D to reload
 Press Ctrl+C to interrupt
 CircuitPython Playground: https://learn.adafruit.com/adafruit-circuit-playground-
bluefruit/circuitpython-playground
8
CircuitPython Essentials
 https://learn.adafruit.com/circuitpython-essentials/circuitpython-essentials
 工欲善其事,必先利其器…一步一腳印…
9
10
CircuitPython(SGP30+PMSA003+Audio)
實作-1
""" Example for using the SGP30 and PM25 with CircuitPython
and the Adafruit library """
import digitalio
import busio
import adafruit_sgp30
import board
import adafruit_pm25
from tool import show_SGP, show_SGP_baseline # for SGP30
from tool import show_PM25 # for PMSA003
from tool import color_chase_1 # for NeoPixel
from tool import play_file # for AudioOut
# 設定 LED 顏色
RED = (255, 0, 0)
GREEN = (0, 255, 0)
OFF = (0, 0, 0)
i2c_bus = busio.I2C(board.SCL, board.SDA, frequency=100000)
# Create library object on I2C port
sgp30 = adafruit_sgp30.Adafruit_SGP30(i2c_bus)
print("SGP30 serial #", [hex(i) for i in sgp30.serial])
sgp30.iaq_init()
# sgp30.set_iaq_baseline(co2eq_base, tvoc_base)
# elapsed_sec = 0
reset_pin = None
uart = busio.UART(board.TX, board.RX, baudrate=9600)
pm25 = adafruit_pm25.PM25_UART(uart, reset_pin)
# Enable the speaker
spkrenable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
spkrenable.direction = digitalio.Direction.OUTPUT
spkrenable.value = True
# Make the 2 input buttons
11
CircuitPython(SGP30+PMSA003)實作-2
# Tools
import time
import board
import neopixel
dup = 37 # hyphen
# include audio libraries
try:
from audiocore import WaveFile
except ImportError:
from audioio import WaveFile
try:
from audioio import AudioOut
except ImportError:
try:
from audiopwmio import PWMAudioOut as AudioOut
except ImportError:
pass # not always supported by every board!
pixels = neopixel.NeoPixel(
board.NEOPIXEL,
10,
brightness=0.2,
auto_write=False
)
# LED 全亮
def color_chase_all(color, wait):
for i in range(10):
pixels[i] = color
time.sleep(wait)
pixels.show()
12
CircuitPython(SGP30+PMSA003)實作-3
 善用工具:
 簡化程式:將重複的程式碼移至 tool.py 並製作成 function 供主程式 code.py 呼叫,
類似積木的使用方式
13
你(妳)成功了嗎?!
14
Q & A
15

More Related Content

What's hot

JavaOne: Using NetBeans RCP to control your Lego [con1702]
JavaOne: Using NetBeans RCP to control your Lego [con1702]JavaOne: Using NetBeans RCP to control your Lego [con1702]
JavaOne: Using NetBeans RCP to control your Lego [con1702]
Johan Janssen
 
JavaOne: Using actors for the iInternet of (Lego) Trains [con1709]
JavaOne: Using actors for the iInternet of (Lego) Trains [con1709]JavaOne: Using actors for the iInternet of (Lego) Trains [con1709]
JavaOne: Using actors for the iInternet of (Lego) Trains [con1709]
Johan Janssen
 
EuregJUG: Using actors for the internet of (lego) trains
EuregJUG: Using actors for the internet of (lego) trainsEuregJUG: Using actors for the internet of (lego) trains
EuregJUG: Using actors for the internet of (lego) trains
Johan Janssen
 
Smart oven 智慧烤箱
Smart oven 智慧烤箱Smart oven 智慧烤箱
Smart oven 智慧烤箱
艾鍗科技
 
Introduction to tms320c6745 dsp
Introduction to tms320c6745 dspIntroduction to tms320c6745 dsp
Introduction to tms320c6745 dsp
Pantech ProLabs India Pvt Ltd
 
物聯網連結智慧生活-環境監控與智慧家電的開發與應用
物聯網連結智慧生活-環境監控與智慧家電的開發與應用物聯網連結智慧生活-環境監控與智慧家電的開發與應用
物聯網連結智慧生活-環境監控與智慧家電的開發與應用
永忠 曹
 
IoT of heart rate watchdog
IoT of heart rate watchdogIoT of heart rate watchdog
IoT of heart rate watchdog
艾鍗科技
 
ADS-B, AIS, APRS cheatsheet
ADS-B, AIS, APRS cheatsheetADS-B, AIS, APRS cheatsheet
ADS-B, AIS, APRS cheatsheet
Naoto MATSUMOTO
 
Mobile Development For Arduino 201 - ConnectTech
Mobile Development For Arduino 201 - ConnectTechMobile Development For Arduino 201 - ConnectTech
Mobile Development For Arduino 201 - ConnectTech
stable|kernel
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
Shubhrika Sehgal
 
AM437x Product on Module
AM437x Product on ModuleAM437x Product on Module
AM437x Product on Module
Mistral Solutions
 
A High Performance Heterogeneous FPGA-based Accelerator with PyCoRAM (Runner ...
A High Performance Heterogeneous FPGA-based Accelerator with PyCoRAM (Runner ...A High Performance Heterogeneous FPGA-based Accelerator with PyCoRAM (Runner ...
A High Performance Heterogeneous FPGA-based Accelerator with PyCoRAM (Runner ...
Shinya Takamaeda-Y
 
必見!絶対におすすめの通信業界セッション 5 つ ~秋の GTC 2020~
必見!絶対におすすめの通信業界セッション 5 つ ~秋の GTC 2020~必見!絶対におすすめの通信業界セッション 5 つ ~秋の GTC 2020~
必見!絶対におすすめの通信業界セッション 5 つ ~秋の GTC 2020~
NVIDIA Japan
 
Case Study: Large Scale Deployment for Machine Learning with Highspeed Storage
Case Study: Large Scale Deployment for Machine Learning with Highspeed StorageCase Study: Large Scale Deployment for Machine Learning with Highspeed Storage
Case Study: Large Scale Deployment for Machine Learning with Highspeed Storage
Kota Tsuyuzaki
 
ETRX3 ZigBee Module: ETRX3
ETRX3 ZigBee Module: ETRX3ETRX3 ZigBee Module: ETRX3
ETRX3 ZigBee Module: ETRX3
Premier Farnell
 
PyCoRAM: Yet Another Implementation of CoRAM Memory Architecture for Modern F...
PyCoRAM: Yet Another Implementation of CoRAM Memory Architecture for Modern F...PyCoRAM: Yet Another Implementation of CoRAM Memory Architecture for Modern F...
PyCoRAM: Yet Another Implementation of CoRAM Memory Architecture for Modern F...
Shinya Takamaeda-Y
 

What's hot (20)

JavaOne: Using NetBeans RCP to control your Lego [con1702]
JavaOne: Using NetBeans RCP to control your Lego [con1702]JavaOne: Using NetBeans RCP to control your Lego [con1702]
JavaOne: Using NetBeans RCP to control your Lego [con1702]
 
JavaOne: Using actors for the iInternet of (Lego) Trains [con1709]
JavaOne: Using actors for the iInternet of (Lego) Trains [con1709]JavaOne: Using actors for the iInternet of (Lego) Trains [con1709]
JavaOne: Using actors for the iInternet of (Lego) Trains [con1709]
 
EuregJUG: Using actors for the internet of (lego) trains
EuregJUG: Using actors for the internet of (lego) trainsEuregJUG: Using actors for the internet of (lego) trains
EuregJUG: Using actors for the internet of (lego) trains
 
SBCCI08
SBCCI08SBCCI08
SBCCI08
 
3D-DRESD ASIDA
3D-DRESD ASIDA3D-DRESD ASIDA
3D-DRESD ASIDA
 
Smart oven 智慧烤箱
Smart oven 智慧烤箱Smart oven 智慧烤箱
Smart oven 智慧烤箱
 
Pc 104 series 1 application showcase
Pc 104 series 1 application showcasePc 104 series 1 application showcase
Pc 104 series 1 application showcase
 
Introduction to tms320c6745 dsp
Introduction to tms320c6745 dspIntroduction to tms320c6745 dsp
Introduction to tms320c6745 dsp
 
物聯網連結智慧生活-環境監控與智慧家電的開發與應用
物聯網連結智慧生活-環境監控與智慧家電的開發與應用物聯網連結智慧生活-環境監控與智慧家電的開發與應用
物聯網連結智慧生活-環境監控與智慧家電的開發與應用
 
IoT of heart rate watchdog
IoT of heart rate watchdogIoT of heart rate watchdog
IoT of heart rate watchdog
 
ADS-B, AIS, APRS cheatsheet
ADS-B, AIS, APRS cheatsheetADS-B, AIS, APRS cheatsheet
ADS-B, AIS, APRS cheatsheet
 
Mobile Development For Arduino 201 - ConnectTech
Mobile Development For Arduino 201 - ConnectTechMobile Development For Arduino 201 - ConnectTech
Mobile Development For Arduino 201 - ConnectTech
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
AM437x Product on Module
AM437x Product on ModuleAM437x Product on Module
AM437x Product on Module
 
A High Performance Heterogeneous FPGA-based Accelerator with PyCoRAM (Runner ...
A High Performance Heterogeneous FPGA-based Accelerator with PyCoRAM (Runner ...A High Performance Heterogeneous FPGA-based Accelerator with PyCoRAM (Runner ...
A High Performance Heterogeneous FPGA-based Accelerator with PyCoRAM (Runner ...
 
必見!絶対におすすめの通信業界セッション 5 つ ~秋の GTC 2020~
必見!絶対におすすめの通信業界セッション 5 つ ~秋の GTC 2020~必見!絶対におすすめの通信業界セッション 5 つ ~秋の GTC 2020~
必見!絶対におすすめの通信業界セッション 5 つ ~秋の GTC 2020~
 
Case Study: Large Scale Deployment for Machine Learning with Highspeed Storage
Case Study: Large Scale Deployment for Machine Learning with Highspeed StorageCase Study: Large Scale Deployment for Machine Learning with Highspeed Storage
Case Study: Large Scale Deployment for Machine Learning with Highspeed Storage
 
ETRX3 ZigBee Module: ETRX3
ETRX3 ZigBee Module: ETRX3ETRX3 ZigBee Module: ETRX3
ETRX3 ZigBee Module: ETRX3
 
PyCoRAM: Yet Another Implementation of CoRAM Memory Architecture for Modern F...
PyCoRAM: Yet Another Implementation of CoRAM Memory Architecture for Modern F...PyCoRAM: Yet Another Implementation of CoRAM Memory Architecture for Modern F...
PyCoRAM: Yet Another Implementation of CoRAM Memory Architecture for Modern F...
 
9.atmel
9.atmel9.atmel
9.atmel
 

Similar to Coding with CircuitPython@CPB

Raspberry Pi I/O控制與感測器讀取
Raspberry Pi I/O控制與感測器讀取Raspberry Pi I/O控制與感測器讀取
Raspberry Pi I/O控制與感測器讀取
艾鍗科技
 
Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !
Dobrica Pavlinušić
 
Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013Tom Paulus
 
z61ae.pdf
z61ae.pdfz61ae.pdf
z61ae.pdf
Anubys365
 
Vlsi es-lab-manual
Vlsi es-lab-manualVlsi es-lab-manual
Vlsi es-lab-manual
twinkleratna
 
Ae01 system overview
Ae01 system overviewAe01 system overview
Ae01 system overview
confidencial
 
I made some more expansion board for M5Stack
I made some more expansion  board for M5StackI made some more expansion  board for M5Stack
I made some more expansion board for M5Stack
Masawo Yamazaki
 
Stand Alone Programmers -Crystals and Oscillators - componentship.com
Stand Alone Programmers -Crystals and Oscillators - componentship.comStand Alone Programmers -Crystals and Oscillators - componentship.com
Stand Alone Programmers -Crystals and Oscillators - componentship.com
燕 欧
 
Innovation with pcDuino
Innovation with pcDuinoInnovation with pcDuino
Innovation with pcDuino
Jingfeng Liu
 
Introducing the Arduino
Introducing the ArduinoIntroducing the Arduino
Introducing the Arduino
Charles A B Jr
 
0393 1 qs_emea_eng_print
0393 1 qs_emea_eng_print0393 1 qs_emea_eng_print
0393 1 qs_emea_eng_print
David Reyes
 
dotFes 2008 TOKYO
dotFes 2008 TOKYOdotFes 2008 TOKYO
dotFes 2008 TOKYO
Shigeru Kobayashi
 
2014 09 12 Dia Programador Session Materials
2014 09 12 Dia Programador Session Materials2014 09 12 Dia Programador Session Materials
2014 09 12 Dia Programador Session Materials
Bruno Capuano
 
Pengenalan Perangkat Nokia 7210 SASSx.pptx
Pengenalan Perangkat Nokia 7210 SASSx.pptxPengenalan Perangkat Nokia 7210 SASSx.pptx
Pengenalan Perangkat Nokia 7210 SASSx.pptx
LintasLti
 
Pilot Raspeberry pi 3g user manual
Pilot Raspeberry pi 3g user manualPilot Raspeberry pi 3g user manual
Pilot Raspeberry pi 3g user manual
Linkwave Technologies Ltd
 
Raspberry-Pi GPIO
Raspberry-Pi GPIORaspberry-Pi GPIO
Raspberry-Pi GPIO
Sajib Sen
 
PPT+.pdf
PPT+.pdfPPT+.pdf
20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Jorisimec.archive
 

Similar to Coding with CircuitPython@CPB (20)

Raspberry Pi I/O控制與感測器讀取
Raspberry Pi I/O控制與感測器讀取Raspberry Pi I/O控制與感測器讀取
Raspberry Pi I/O控制與感測器讀取
 
Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !
 
Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013
 
z61ae.pdf
z61ae.pdfz61ae.pdf
z61ae.pdf
 
Vlsi es-lab-manual
Vlsi es-lab-manualVlsi es-lab-manual
Vlsi es-lab-manual
 
Ae01 system overview
Ae01 system overviewAe01 system overview
Ae01 system overview
 
I made some more expansion board for M5Stack
I made some more expansion  board for M5StackI made some more expansion  board for M5Stack
I made some more expansion board for M5Stack
 
Stand Alone Programmers -Crystals and Oscillators - componentship.com
Stand Alone Programmers -Crystals and Oscillators - componentship.comStand Alone Programmers -Crystals and Oscillators - componentship.com
Stand Alone Programmers -Crystals and Oscillators - componentship.com
 
Innovation with pcDuino
Innovation with pcDuinoInnovation with pcDuino
Innovation with pcDuino
 
Introducing the Arduino
Introducing the ArduinoIntroducing the Arduino
Introducing the Arduino
 
PIC Axe049(print34)
PIC Axe049(print34)PIC Axe049(print34)
PIC Axe049(print34)
 
0393 1 qs_emea_eng_print
0393 1 qs_emea_eng_print0393 1 qs_emea_eng_print
0393 1 qs_emea_eng_print
 
dotFes 2008 TOKYO
dotFes 2008 TOKYOdotFes 2008 TOKYO
dotFes 2008 TOKYO
 
2014 09 12 Dia Programador Session Materials
2014 09 12 Dia Programador Session Materials2014 09 12 Dia Programador Session Materials
2014 09 12 Dia Programador Session Materials
 
Pengenalan Perangkat Nokia 7210 SASSx.pptx
Pengenalan Perangkat Nokia 7210 SASSx.pptxPengenalan Perangkat Nokia 7210 SASSx.pptx
Pengenalan Perangkat Nokia 7210 SASSx.pptx
 
Pilot Raspeberry pi 3g user manual
Pilot Raspeberry pi 3g user manualPilot Raspeberry pi 3g user manual
Pilot Raspeberry pi 3g user manual
 
Raspberry-Pi GPIO
Raspberry-Pi GPIORaspberry-Pi GPIO
Raspberry-Pi GPIO
 
YCAM Workshop Part 1
YCAM Workshop Part 1YCAM Workshop Part 1
YCAM Workshop Part 1
 
PPT+.pdf
PPT+.pdfPPT+.pdf
PPT+.pdf
 
20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris
 

Recently uploaded

addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
abh.arya
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
MuhammadTufail242431
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
PrashantGoswami42
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
Kamal Acharya
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 

Recently uploaded (20)

addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 

Coding with CircuitPython@CPB

  • 3. 準備材料  Adafruit Circuit Playground Bluefruit Microcontroller Board  Adafruit SGP30 Air Quality Sensor Breakout-VOC、eCO2  PLANTOWER PMSA003 Laser PM2.5 Air Quality Sensor (含G7專用轉接板與連接 線--8pin 1.25mm 轉 2.54mm)  Lithium Ion Polymer Battery - 3.7V 2000mAh(JST connector) or MB102 Breadboard Power Supply Module 3.3V/5V  Breadboard  Dupont Line  Alligator-clip  USB cable 3
  • 5. CircuitPython簡介  CircuitPython is a programming language designed to simplify experimenting and learning to program on low-cost microcontroller boards.  CircuitPython is based on Python  Advantage:  Running quickly  Easily update your code  Serial console and REPL 5
  • 6. CircuitPython安裝  Follow the step from https://learn.adafruit.com/adafruit-circuit-playground- bluefruit/circuitpython  Download the latest UF2 file -- CircuitPython 6.0.0-beta.2  Double-click the small RESET button in the middle of the CPB  Drag the adafruit_circuitpython_xxx-6.0.0-xxx.uf2 file to CPLAYBTBOOT  Download the latest library bundle file -- Bundle Version 6.x  Copy the following folders and files from the bundle lib folder to the lib folder on your CIRCUITPY drive 6
  • 7. Installing Mu Editor  Download Mu from https://codewith.mu  Click [Download] -- Windows 64-bit  Using Mu 7
  • 8. CircuitPython實作  Blinking the D13 LED -- https://learn.adafruit.com/adafruit-circuit-playground- bluefruit/creating-and-editing-code  Copy Code  Paste the code into Mu editor  Save as code.py on your CIRCUITPY drive  Connecting to the Serial Console – print("Hello, world!")  The REPL  Press any key to enter the REPL  Use Ctrl+D to reload  Press Ctrl+C to interrupt  CircuitPython Playground: https://learn.adafruit.com/adafruit-circuit-playground- bluefruit/circuitpython-playground 8
  • 10. 10
  • 11. CircuitPython(SGP30+PMSA003+Audio) 實作-1 """ Example for using the SGP30 and PM25 with CircuitPython and the Adafruit library """ import digitalio import busio import adafruit_sgp30 import board import adafruit_pm25 from tool import show_SGP, show_SGP_baseline # for SGP30 from tool import show_PM25 # for PMSA003 from tool import color_chase_1 # for NeoPixel from tool import play_file # for AudioOut # 設定 LED 顏色 RED = (255, 0, 0) GREEN = (0, 255, 0) OFF = (0, 0, 0) i2c_bus = busio.I2C(board.SCL, board.SDA, frequency=100000) # Create library object on I2C port sgp30 = adafruit_sgp30.Adafruit_SGP30(i2c_bus) print("SGP30 serial #", [hex(i) for i in sgp30.serial]) sgp30.iaq_init() # sgp30.set_iaq_baseline(co2eq_base, tvoc_base) # elapsed_sec = 0 reset_pin = None uart = busio.UART(board.TX, board.RX, baudrate=9600) pm25 = adafruit_pm25.PM25_UART(uart, reset_pin) # Enable the speaker spkrenable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) spkrenable.direction = digitalio.Direction.OUTPUT spkrenable.value = True # Make the 2 input buttons 11
  • 12. CircuitPython(SGP30+PMSA003)實作-2 # Tools import time import board import neopixel dup = 37 # hyphen # include audio libraries try: from audiocore import WaveFile except ImportError: from audioio import WaveFile try: from audioio import AudioOut except ImportError: try: from audiopwmio import PWMAudioOut as AudioOut except ImportError: pass # not always supported by every board! pixels = neopixel.NeoPixel( board.NEOPIXEL, 10, brightness=0.2, auto_write=False ) # LED 全亮 def color_chase_all(color, wait): for i in range(10): pixels[i] = color time.sleep(wait) pixels.show() 12
  • 13. CircuitPython(SGP30+PMSA003)實作-3  善用工具:  簡化程式:將重複的程式碼移至 tool.py 並製作成 function 供主程式 code.py 呼叫, 類似積木的使用方式 13