SlideShare a Scribd company logo
1 of 15
高師大跨領域藝術研究所
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) trainsJohan Janssen
 
Smart oven 智慧烤箱
Smart oven 智慧烤箱Smart oven 智慧烤箱
Smart oven 智慧烤箱艾鍗科技
 
物聯網連結智慧生活-環境監控與智慧家電的開發與應用
物聯網連結智慧生活-環境監控與智慧家電的開發與應用物聯網連結智慧生活-環境監控與智慧家電的開發與應用
物聯網連結智慧生活-環境監控與智慧家電的開發與應用永忠 曹
 
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 cheatsheetNaoto MATSUMOTO
 
Mobile Development For Arduino 201 - ConnectTech
Mobile Development For Arduino 201 - ConnectTechMobile Development For Arduino 201 - ConnectTech
Mobile Development For Arduino 201 - ConnectTechstable|kernel
 
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 StorageKota Tsuyuzaki
 
ETRX3 ZigBee Module: ETRX3
ETRX3 ZigBee Module: ETRX3ETRX3 ZigBee Module: ETRX3
ETRX3 ZigBee Module: ETRX3Premier 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
 
Vlsi es-lab-manual
Vlsi es-lab-manualVlsi es-lab-manual
Vlsi es-lab-manualtwinkleratna
 
Ae01 system overview
Ae01 system overviewAe01 system overview
Ae01 system overviewconfidencial
 
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 M5StackMasawo 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 pcDuinoJingfeng Liu
 
Introducing the Arduino
Introducing the ArduinoIntroducing the Arduino
Introducing the ArduinoCharles 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_printDavid Reyes
 
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 MaterialsBruno Capuano
 
Pengenalan Perangkat Nokia 7210 SASSx.pptx
Pengenalan Perangkat Nokia 7210 SASSx.pptxPengenalan Perangkat Nokia 7210 SASSx.pptx
Pengenalan Perangkat Nokia 7210 SASSx.pptxLintasLti
 
Raspberry-Pi GPIO
Raspberry-Pi GPIORaspberry-Pi GPIO
Raspberry-Pi GPIOSajib Sen
 
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

MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...Call Girls in Nagpur High Profile
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 

Recently uploaded (20)

MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 

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