First, get homebrew if you don't already have it.
Then, in your terminal, get things set up:
cd ~/Downloads
mkdir tiktok_stuff
cd tiktok_stuff
from machine import Pin | |
from neopixel import NeoPixel | |
import time | |
pixels = NeoPixel(Pin(0), 12, bpp=4) | |
WHITE = (0,0,0,255) | |
RED = (255,0,0,0) | |
GREEN = (0,255,0,0) | |
BLUE = (0,0,255,0) |
import asyncio | |
import time | |
import board | |
import neopixel | |
from rainbowio import colorwheel | |
import adafruit_lsm303_accel | |
import adafruit_lis2mdl |
First, get homebrew if you don't already have it.
Then, in your terminal, get things set up:
cd ~/Downloads
mkdir tiktok_stuff
cd tiktok_stuff
If you have a CircuitPython development board that has Bluetooth LE (Bluetooth Low Energy, or BLE) compatibility, fairly easy to get it connected a phone or PC over a virtual UART (for simple, text-based communications.
In addition to a CircuitPython-compatible development board that supports Bluetooth LE, you'll need to have CircuitPython installed. The build of CP for your board needs to include the _bleio
library; you can check to see if you're board is supported here.
You will most likely want to install a few support libraries for working with BLE (the first one is required, the second is optional but highly recommended). You can install these with circup or get them from the CircuitPython library bundle
Adafruit Blinka is a CircuitPython compatability layer for standard Python (CPython) on desktops, laptops, and single board computers. Installing Blinka is a great way to access the hardware drivers and other helpers available in CircuitPython. For example, CP has a very nice interface to Bluetooth LE that can make setting up your laptop as a central device much easier!
See Adafruit's installation guide for more details on setting up Blinka. You might also want to tale a look at the guides below for methods for setting up Blinka with computers for hardware hacking:
Notes on writing a CircuitPython driver for the LSM6DSV16X IMU.
For starts, I went to the Adafruit CircuitPython driver for LSM6DS-class chips. It covers several models with similar setups, so it seemed liked a good place to start.
Once I figured out that the Sparkfun dev board that I'm using was set up for the alternate I2C address (0x6b instead of 0x6a) and that I needed to use the chip ID specific to the LSM6DSV16X (0x70), I was able to connect with the LSM6DS library, using a new implemenation file (which really only setup the new CHIP_ID
):
I use Micropython sometimes. It's a great port of Python to microcontrollers, and the basis of CircuitPython. Unlike CircuitPython, MicroPython doesn't typically provide a mounted drive via native USB, which means that you need some tooling to best interact with the board. For example, I am using MP on some ESP8266 dev boards, because CP support there isn't great (no UF2 bootloader, no native USB).
esptool.py
- Needed for flashing the boardmpremote
- a handy toolkit for working with MP boards, including console access, package management, and file managementampy
- a handy tool for copying files to and from a MicroPython board. This is somewhat redundant if you use mpremote
import board | |
import time | |
import adafruit_bme680 | |
import adafruit_veml7700 | |
import neopixel | |
from adafruit_led_animation.animation.rainbow import Rainbow | |
from adafruit_led_animation.color import RED | |
from ulab import numpy as np | |
i2c = board.I2C() |
I was trying to get some CP code to talk to Processing over a serial port interface. Of course, the CP REPL is normally available on whatever serial port the board mounts by default. This is a little complicated, because although you can use something like print
from the REPL (or code.py
) to print a value to the console, sys.stdin
and sys.stdout
are text-based streams, which may not be what you want. And you'll get REPL noise to boot. Not ideal.
This is where usb_cdc
comes in. It's a handy library for managing the USB CDC (serial) on most CircuitPython boards. First, usb_cdc
can be used to control how many serial ports CP will provide at startup. You can modify boot.py
to make this work:
import usb_cdc
usb_cdc.enable(console=True, data=False)
""" | |
Simple CircuitPython control of an RGB strip via Mosfetti or plain MOSFETS. | |
Copyright (c) 2023 George White <[email protected]> | |
Written for the Adafruit Metro M0, but will work with any board with | |
4 PWM-capable pins. | |
""" | |
import board | |
from pwmio import PWMOut |