Last active
September 9, 2019 17:29
-
-
Save blippy/dd93dc64640f31dd9616af8e35cc602a to your computer and use it in GitHub Desktop.
Crude oscilloscope
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
%serialconnect to --port=/dev/ttyUSB1 # for Jupyter | |
import machine, ssd1306 | |
i2c = machine.I2C(-1, scl=machine.Pin(22), sda=machine.Pin(21)) | |
oled = ssd1306.SSD1306_I2C(128, 64, i2c) | |
oled.fill(0) | |
oled.text('MicroPython on', 0, 0) | |
oled.text('attached SSD1306', 0, 20) | |
oled.text('OLED display', 0, 30) | |
oled.show() | |
from machine import Pin, ADC | |
from time import sleep | |
pot = ADC(Pin(34)) | |
pot.atten(ADC.ATTN_11DB) #Full range: 3.3v | |
def naff(): | |
while True: | |
pot_value = pot.read() | |
print(pot_value) | |
sleep(0.1) | |
print(pot.read()) | |
oled.fill(0) | |
y = pot.read() | |
print(y) | |
y = 63-int((y* 63)/4095) | |
print(y) | |
oled.pixel(0,y, 1) | |
oled.show() | |
ys = [63] *128 | |
oled.fill(0) | |
while True: | |
#oled.fill(0) | |
y = pot.read() | |
#print(y) | |
y = 63-int((y* 63)/4095) | |
#print(y) | |
ys[127] = y | |
for x in range(0, 127): | |
oled.pixel(x,ys[x],0) | |
ys[x] = ys[x+1] | |
oled.pixel(x,ys[x], 1) | |
oled.show() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uses ESP32-WROOM + ssd1306 OLED + potentionmeter