CircuitPython Essentials - Adafruit Industries
CircuitPython Essentials
Created by Kattni Rembor
Last updated on 2022-02-14 12:29:38 PM EST
?Adafruit Industries
Page 1 of 115
Table of Contents
CircuitPython Essentials
5
CircuitPython Pins and Modules
5
?
?
?
?
?
?
6
6
7
9
10
10
CircuitPython Pins
import board
I2C, SPI, and UART
What Are All the Available Names?
Microcontroller Pin Names
CircuitPython Built-In Modules
CircuitPython Built-Ins
11
?
?
?
?
?
?
?
Thing That Are Built In and Work
Flow Control
Math
Tuples, Lists, Arrays, and Dictionaries
Classes, Objects and Functions
Lambdas
Random Numbers
11
11
11
12
12
12
12
CircuitPython Digital In & Out
12
? Find the pins!
? Read the Docs
14
17
CircuitPython Analog In
17
?
?
?
?
?
?
18
18
18
19
19
23
Creating the analog input
get_voltage Helper
Main Loop
Changing It Up
Wire it up
Reading Analog Pin Values
CircuitPython Analog Out
?
?
?
?
Creating an analog output
Setting the analog output
Main Loop
Find the pin
CircuitPython Audio Out
? Play a Tone
? Play a Wave File
? Wire It Up
24
24
24
25
25
29
29
31
33
CircuitPython MP3 Audio
38
CircuitPython PWM
39
?
?
?
?
?
?
PWM with Fixed Frequency
Create a PWM Output
Main Loop
PWM Output with Variable Frequency
Wire it up
Where's My PWM?
?Adafruit Industries
39
41
41
41
42
48
Page 2 of 115
CircuitPython Servo
? Servo Wiring
? Standard Servo Code
? Continuous Servo Code
CircuitPython Cap Touch
? Create the Touch Input
? Main Loop
? Find the Pin(s)
CircuitPython Internal RGB LED
?
?
?
?
?
Create the LED
Brightness
Main Loop
Making Rainbows (Because Who Doesn't Love 'Em!)
Circuit Playground Express Rainbow
CircuitPython NeoPixel
?
?
?
?
?
?
?
Wiring It Up
The Code
Create the LED
NeoPixel Helpers
Main Loop
NeoPixel RGBW
Read the Docs
CircuitPython DotStar
?
?
?
?
?
?
?
Wire It Up
The Code
Create the LED
DotStar Helpers
Main Loop
Is it SPI?
Read the Docs
CircuitPython UART Serial
?
?
?
?
The Code
Wire It Up
Where's my UART?
Trinket M0: Create UART before I2C
CircuitPython I2C
?
?
?
?
Wire It Up
Find Your Sensor
I2C Sensor Data
Where's my I2C?
CircuitPython HID Keyboard and Mouse
?
?
?
?
?
?
?
CircuitPython Keyboard Emulator
Create the Objects and Variables
The Main Loop
Non-US Keyboard Layouts
CircuitPython Mouse Emulator
Create the Objects and Variables
CircuitPython HID Mouse Helpers
?Adafruit Industries
49
49
51
52
53
53
54
55
58
59
59
60
61
62
63
63
64
65
66
66
67
68
68
69
70
72
73
73
74
74
75
76
77
80
81
82
82
85
86
88
89
89
91
91
92
92
94
94
Page 3 of 115
? Main Loop
CircuitPython Storage
? Logging the Temperature
95
95
98
CircuitPython CPU Temp
100
CircuitPython Expectations
101
?
?
?
?
?
?
?
101
102
102
103
103
104
104
Always Run the Latest Version of CircuitPython and Libraries
I have to continue using CircuitPython 3.x or 2.x, where can I find compatible libraries?
Switching Between CircuitPython and Arduino
The Difference Between Express And Non-Express Boards
Non-Express Boards: Gemma, Trinket, and QT Py
Differences Between CircuitPython and MicroPython
Differences Between CircuitPython and Python
CircuitPython Resetting
?
?
?
?
Soft Reset
Hard Reset
Reset Into Specific Mode
More Info
105
105
106
106
107
CircuitPython Libraries and Drivers
107
CircuitPython Libraries
107
?Adafruit Industries
Page 4 of 115
CircuitPython Essentials
You've gone through the Welcome to CircuitPython guide (). You've already gotten everything setup, and you've gotten CircuitPython
running. Great! Now what? CircuitPython Essentials!
There are a number of core modules built into CircuitPython and commonly used
libraries available. This guide will introduce you to these and show you an example of
how to use each one.
Each section will present you with a piece of code designed to work with different
boards, and explain how to use the code with each board. These examples work with
any board designed for CircuitPython, including Circuit Playground Express, Trinket
M0, Gemma M0, QT Py, ItsyBitsy M0 Express, ItsyBitsy M4 Express, Feather M0
Express, Feather M4 Express, Metro M4 Express, Metro M0 Express, Trellis M4
Express, and Grand Central M4 Express.
Some examples require external components, such as switches or sensors. You'll find
wiring diagrams where applicable to show you how to wire up the necessary
components to work with each example.
Let's get started learning the CircuitPython Essentials!
CircuitPython Pins and Modules
CircuitPython is designed to run on microcontrollers and allows you to interface with
all kinds of sensors, inputs and other hardware peripherals. There are tons of guides
showing how to wire up a circuit, and use CircuitPython to, for example, read data
from a sensor, or detect a button press. Most CircuitPython code includes hardware
setup which requires various modules, such as board or digitalio . You import
these modules and then use them in your code. How does CircuitPython know to look
?Adafruit Industries
Page 5 of 115
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- chapter 2 assemblers thu
- programming the microcontroller
- lecture 7 finite fields part 4
- cis192 python programming
- output signals of incremental encoders
- recognizing corrupt and introduction malformed pdf files
- circuitpython essentials adafruit industries
- python intelhex library documentation
- python 3 cheat sheet smu