Youtube video: https://youtube.com/shorts/HdBHPH0XLHE Four LEDs are randomly lit; value (in reverse order) is shown on the "Bits:" line on the 1.5" 128x64 OLED in Font 2; four DS18B20 temperature sensors are read and the temperatures are written to the OLED. Pins 0, 1, and 4 are not used in this demo, but are brought out.
Code for youtube demo:
Code: [Local Link Removed for Guests]
dim p(4)=8,7,6,5
dim t(4)=21,20,10,9
dim tmp$(4)
dim lbl$(4)="A","B","C","D"
SERIAL2.MODE 115200,1,0 ' tx, rx
i2c.setup 3,2
OLED.INIT 1,1
OLED.FONT 2 '1=10pixels (10x13),2-16 (16x19),3=24 (24x28)
oled.cls
pause 10000
oled.print 0,0,"Bits: "
for i=0 to 3
pin.mode p(i),output
pin(p(i))=0
next
pause 1000
for i=0 to 3
pin(p(i))=1
pause 500
next
pause 1000
for i=0 to 3
pin(p(i))=0
oled.print i*16+60,0,"0"
next
pause 1000
' oled.font 1
for i=0 to 3
tmp$(i)="0" '=str$(val(tempr$(t(i),1)),"%4.1f")
next
j=0
do
i=rnd(4)
k=rnd(2)
pin(p(i))=k
oled.color 0
oled.rect i*16+60,0,16,19,1 ' blank the character position
pause 10
oled.color 1
oled.print i*16+60,0,chr$(asc("0")+k)
temp$=str$(val(tempr$(t(j),1)),"%4.1f")
if temp$<>"-127.0" and tmp$(j)<>temp$ then
y=int(j/2)*19+19
x=(j mod 2)*64+4*(j mod 2) ' x is 0 or 68
oled.color 0
oled.rect x,y,64,19,1 ' blank the string position
pause 10
oled.color 1
oled.print x,y,lbl$(j)+" "+temp$
print2 str$(j)+" "+temp$+" "+tmp$(j)
tmp$(j)=temp$
endif
j=(j+1) mod 4 ' temp sensors 0-3
pause 1000
loop