Play with simplex noise in CircuitPython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# noise_square_code.py -- playing with simplex noise in CircuitPython | |
# 9 Feb 2023 - @todbot / Tod Kurt | |
# https://github.com/todbot/CircuitPython_Noise | |
# Uses Lolin ESP32-S2 Mini and 8x8 LED shield | |
# https://circuitpython.org/board/lolin_s2_mini/ | |
# | |
import time | |
import board | |
import neopixel | |
import rainbowio | |
import noise | |
leds = neopixel.NeoPixel(board.IO16, 64, brightness=0.1, pixel_order=neopixel.RGB, auto_write=False) | |
leds.fill(0xff00ff) # say hello | |
noise_scale = 0.1 | |
noise_x = 0 | |
noise_y = 0 | |
while True: | |
for i in range(8): # for each pixel row | |
for j in range(8): # for each pixel column | |
# get a noise value in 2D noise space | |
n = noise.noise( noise_x + noise_scale*i, noise_y + noise_scale*j ) | |
c = int((n+1) * 255) # scale it from -1-1 -> 0-255 | |
leds[j*8+i] = rainbowio.colorwheel(c) # convert to hue | |
leds.show() | |
noise_y += 0.01 # slide down in noise space | |
time.sleep(0.01) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another example from the repo: https://github.com/todbot/CircuitPython_Noise
which makes a really nice terrain-like output to the terminal
simplex_noise_terminal_demo.mp4