import LCD import time from machine import Pin import random # Display analog inputs 0 and 1 (X and Y) on the LCD as an oscilloscope Orange = LCD.RGB(250,200,0) Navy= LCD.RGB(0,0,30) Grey = LCD.RGB(100,100,100) Yellow = LCD.RGB(250,250,0) Cyan = LCD.RGB(0,250,250) LCD.Init() LCD.Clear(Navy) for i in range(0,11): LCD.Line(0,i*30,479,i*30,Grey) LCD.Line(i*48,0,i*48,300,Grey) led = Pin(17, Pin.OUT) a2d0 = machine.ADC(0) a2d1 = machine.ADC(1) DataX = []; DataY = []; # Main Routine led.value(1) DataX = [0] DataY = [0] print('Starting with an empty data set') for i in range(0,480): DataX.append(0); DataY.append(0); x0 = int(a2d0.read_u16()/218) y0 = int(a2d1.read_u16()/218) i = 0 while(1): i = (i+1) % 480 x = DataX[i] y = DataY[i] LCD.Pixel2(i, 160-x, 0) LCD.Pixel2(i, 160-y, 0) x = int(a2d0.read_u16()/218) - x0 y = int(a2d1.read_u16()/218) - y0 DataX[i] = x DataY[i] = y LCD.Pixel2(i, 160-x, Yellow) LCD.Pixel2(i, 160-y, Cyan) time.sleep(0.01) for i in range(0,480): x = DataX[i] y = DataY[i] LCD.Pixel2(i, 160-x, Background) LCD.Pixel2(i, 160-y, Background) time.sleep(1) led.value(0)