Circuitpython : #2 hellow world Tutorial

python

Items

ItsyBitsy M0 Express
Arch linux

For Arch linux

Install auto mount USB drive

key

Open mounted CIRCUITPY

is CIRCUITPY

/.Trashes
/.fseventsd
/.metadata_never_index
/README.txt
/System Volume Information
/Windows 7 Drivers
/boot_out.txt
/laugh.wav
/lib
/main.py
/rimshot.wav

mkdir code.py

mkdir CIRCUITPY/code.py

for arch /run/media/username/CIRCUITPY/
username = your username

Arch linux how to install micro editor

sudo micro CIRCUITPY/code.py

import time
import board

# For Trinket M0, Gemma M0, ItsyBitsy M0 Express, and ItsyBitsy M4 Express
import adafruit_dotstar
led = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
# For Feather M0 Express, Metro M0 Express, Metro M4 Express, Circuit Playground Express, QT Py M0
#import neopixel
#led = neopixel.NeoPixel(board.NEOPIXEL, 1)

led.brightness = 0.1

while True:
    led[0] = (255, 0, 0)
    time.sleep(0.5)
    led[0] = (0, 255, 0)
    time.sleep(0.5)
    led[0] = (0, 0, 255)
    time.sleep(0.5)

Insert code.py inside CIRCUITPY → Reboot automatically and the code will be executed

LED rainbow

sudo micro CIRCUITPY/code.py

import time
import board

import adafruit_dotstar
led = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)

def colorwheel(pos):
    # Input a value 0 to 255 to get a color value.
    # The colours are a transition r - g - b - back to r.
    if pos < 0 or pos > 255:
        return 0, 0, 0
    if pos < 85:
        return int(255 - pos * 3), int(pos * 3), 0
    if pos < 170:
        pos -= 85
        return 0, int(255 - pos * 3), int(pos * 3)
    pos -= 170
    return int(pos * 3), 0, int(255 - (pos * 3))


led.brightness = 0.3

i = 0
while True:
    i = (i + 1) % 256  # run from 0 to 255
    led.fill(colorwheel(i))
    time.sleep(0.01)

Insert code.py inside CIRCUITPY → Reboot automatically and the code will be executed

reference

thank you

Thank you for watching until the end. I'm glad if you can use it as a reference.

Thank you for Helping

Give money to us for Amazon gift

We will continue to update useful information. I am delighted to jump to your help. Thank you very much.