Tiny Sketcher works just fine and demonstrates the basic idea of how the sketcher works. However, that tiny screen and those tiny knobs can be a little tricky to work with. And the only way to start a new sketch is to restart the program.
The Bigger Sketcher improves on Tiny Sketcher by using a larger screen, larger pot knobs, and adds a button that will erase the screen and start over.
In addition the the ItyBisty M4, the Bigger Sketcher uses these parts.




The connection uses SPI, which is covered in the guide for the OLED, so be sure to read that first.
And here's the code for the Bigger Sketcher.
import board, busio import adafruit_ssd1306 from simpleio import map_range from analogio import AnalogIn from digitalio import DigitalInOut, Direction, Pull # Create SPI bus spi = busio.SPI(board.SCK, board.MOSI) # Create the display WIDTH = 128 HEIGHT = 64 DC = DigitalInOut(board.D7) CS = DigitalInOut(board.D9) RST = DigitalInOut(board.D10) display = adafruit_ssd1306.SSD1306_SPI(WIDTH, HEIGHT, spi, DC, RST, CS) display.fill(0) display.show() # Create the knobs READS = 5 x_knob = AnalogIn(board.A0) y_knob = AnalogIn(board.A1) # Create the clear button clear_button = DigitalInOut(board.D12) clear_button.direction = Direction.INPUT clear_button.pull = Pull.UP def read_knobs(reads): avg_x = avg_y = 0 for _ in range(reads): avg_x += x_knob.value avg_y += y_knob.value avg_x /= reads avg_y /= reads x = map_range(avg_x, 0, 65535, 0, WIDTH - 1) y = map_range(avg_y, 0, 65535, 0, HEIGHT - 1) return int(x), int(y) while True: while clear_button.value: x, y = read_knobs(READS) display.pixel(x, y, 1) display.show() display.fill(0) display.show()
As before, this code is largely setup. One big difference from Tiny Sketcher is how the knob values are determined. In order to smooth out possible noise in the analog readings, several readings are made and averaged together. This is all taken care of in the new function read_knobs()
.
The other change is the addition of the button used to clear the display. This is handled with a simple modification of the previous loop.
while True: while clear_button.value: x, y = read_knobs(READS) display.pixel(x, y, 1) display.show() display.fill(0) display.show()
There is still the outer loop that runs forever - while True:
. But now the pixel drawing is done in a new nested loop - while clear_button.value:
. The way the button is wired, it will read True
when it is not pressed. So this loop will keep running as long as the button is left alone. This is when you are drawing. Anytime you want to clear the current display, just hit the button. clear_button.value
will return False
, and the drawing loop will exit. The display is cleared by the last two lines, but then it starts all over again and you are back to drawing.