Skip to content

Instantly share code, notes, and snippets.

@blippy
Last active September 9, 2019 17:29
Show Gist options
  • Save blippy/dd93dc64640f31dd9616af8e35cc602a to your computer and use it in GitHub Desktop.
Save blippy/dd93dc64640f31dd9616af8e35cc602a to your computer and use it in GitHub Desktop.
Crude oscilloscope
%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()
@blippy
Copy link
Author

blippy commented Sep 9, 2019

Uses ESP32-WROOM + ssd1306 OLED + potentionmeter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment