Adafruit Trinket M0
CircuitPython or Arduino IDE on this tiny little microcontroller board
- Overview
- Guided Tour
- Pinouts
- Windows Driver Installation
- What is CircuitPython?
- CircuitPython
- CircuitPython Essentials
- CircuitPython Pins and Modules
- CircuitPython Built-Ins
- CircuitPython Digital In & Out
- CircuitPython Analog In
- CircuitPython Analog Out
- CircuitPython PWM
- CircuitPython Servo
- CircuitPython Cap Touch
- CircuitPython Internal RGB LED
- CircuitPython NeoPixel
- CircuitPython DotStar
- CircuitPython UART Serial
- CircuitPython I2C
- CircuitPython HID Keyboard and Mouse
- CircuitPython CPU Temp
- CircuitPython Storage
- CircuitPython Expectations
- MakeCode
- Arduino IDE Setup
- UF2 Bootloader Details
- Downloads
CircuitPython Built-Ins
CircuitPython comes 'with the kitchen sink' -a lot of the things you know and love about classic Python 3 (sometimes called CPython) already work. There are a few things that don't but we'll try to keep this list updated as we add more capabilities!
Flow Control
All the usualif,elif,else,for,while work just as expected.
Math
import math will give you a range of handy mathematical functions.
>>> dir(math)['__name__', 'e', 'pi', 'sqrt', 'pow', 'exp', 'log', 'cos', 'sin', 'tan', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'copysign', 'fabs', 'floor', 'fmod', 'frexp', 'ldexp', 'modf', 'isfinite', 'isinf', 'isnan', 'trunc', 'radians', 'degrees']
CircuitPython supports 30-bit wide floating point values so you can useint andfloat whenever you expect.
Tuples, Lists, Arrays, and Dictionaries
You can organize data in(), [], and{} including strings, objects, floats, etc.
Classes, Objects and Functions
We use objects and functions extensively in our libraries so check out one of our many examples like thisMCP9808 library for class examples.
Lambdas
Yep! You can create function-functions withlambda just the way you like em:
>>> g = lambda x: x**2>>> g(8)64
Random Numbers
To obtain random numbers:
import random
random.random() will give a floating point number from0 to1.0.
random.randint(min,max) will give you an integer number betweenmin andmax.
Page last edited March 08, 2024
Text editor powered bytinymce.










