Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
import time from machine import ADC, Pin from neopixel import NeoPixel adc0 = ADC(Pin(10)) np = NeoPixel(Pin(15), 10) np.fill((0,0,0)) np.write() class IIRLowPassShift: def __init__(self, shift: int, initial: int=0): self.shift = shift self.y = initial def update(self): x = adc0.read_u16() self.y = self.y + ((x - self.y) >> self.shift) return self.y low_pass = IIRLowPassShift(2) while True: value = low_pass.update() / 65536 * 10 -1 value, fraction = divmod(value, 1) for i in range(10): if value >= i: np[i] = (255, 0, 0) elif fraction: np[i] = (int(fraction * 255), 0, 0) fraction = 0 else: np[i] = (0, 0, 0) np.write() time.sleep_ms(50)
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)