'this file should already be included in the local file system
' otherwise
' copy this script in the editor page, save and run it
pin.mode 2, output
pin.mode 15, output
pin(2) = 0 : pin(15) = 1
pos = 100: dir = 5
PWM.SETUP 22, 1, pos, 50, 12
tft.init 0
gui.init 20, black
txt = GUI.Textline(10,50,190,50, "Position:", 3)
analog = GUI.Textline(10,100,190,50, "ADC:", 3)
gui.autorefresh 50
maxscroll.setup 4, 21
maxscroll.print "Annex & WOKWI"
I2C.SETUP 26, 25
OLED.INIT 1 ' init the OLED upside-down
OLED.CLS ' clear the screen
OLED.REFRESH 0
OLED.FONT 2
OLED.COLOR 1
TM1637.SETUP 13, 12, 100
LCD.INIT &h27, 16, 2
pin.mode 5, input,pullup
interrupt 5, pushedME
for z = 1 to 1000
pin(2) = 1 - pin(2)
pin(15) = 1 - pin(15)
pause 200
PWM.OUT 1, pos
pos = pos + dir
if (pos < 100) or (pos > 500) then dir = -dir
gui.settext txt,"Position " + str$(pos)
MAXSCROLL.SCROLL 5
OLED.CLS
OLED.PRINT 5,10, "Position " + str$(pos)
OLED.REFRESH 0
tm1637.print str$(pos)
LCD.print 1,1, "Position " + str$(pos)
gui.settext analog,"ADC " + str$(adc(35))
next z
pushedME:
pause 50 ' avoid rebounds
if (pin(5) = 0) then
LCD.print 1,2, "Button PRESSED "
else
LCD.print 1,2, "Button RELEASED"
end if
return
print "Pushed button"
return