from machine import Pin, I2C, ADC
from ssd1306 import SSD1306_I2C
#from utime import sleep
import utime
#pin-definition oled-display
i2c=I2C(0,sda=Pin(0), scl=Pin(1), freq=400000)
oled = SSD1306_I2C(128, 64, i2c)
#pin-definition steuerung multiplexer
s0 = Pin(2, Pin.OUT)
s1 = Pin(3, Pin.OUT)
s2 = Pin(4, Pin.OUT)
s3 = Pin(5, Pin.OUT)
adc = ADC(26) #definiton wo ausgang sig_mux eingeht
#definition multiplexer kanal steuerung #channel no.
def rp_c0(): #read/ print c0
s0.value(0)
s1.value(0)
s2.value(0)
s3.value(0)
c0 = adc.read_u16()
print("Wert C0 = ", c0)
def rp_c1():
s0.value(1)
s1.value(0)
s2.value(0)
s3.value(0)
c1 = adc.read_u16()
print("Wert C1 = ", c1)
def rp_c2():
s0.value(0)
s1.value(1)
s2.value(0)
s3.value(0)
c2 = adc.read_u16()
print("Wert C2 = ", c2)
def rp_c3():
s0.value(1)
s1.value(1)
s2.value(0)
s3.value(0)
c3 = adc.read_u16()
print("Wert C3 = ", c3)
#mux = [
# [0,0,0,0], #0
# [1,0,0,0], #1
# [0,1,0,0], #2
# [1,1,0,0], #3
# [0,0,1,0], #4
# [1,0,1,0], #5
# [0,1,1,0], #6
# [1,1,1,0], #7
# [0,0,0,1], #8
# [1,0,0,1], #9
# [0,1,0,1], #10
# [1,1,0,1], #11
# [0,0,1,1], #12
# [1,0,1,1], #13
# [0,1,1,1], #14
# [1,1,1,1], #15
#
#pinCx = list(range(0,15))
#def var_analog(cx):
#s0.value(mux[cx][0])
#s1.value(mux[cx][1])
#s2.value(mux[cx][2])
#s3.value(mux[cx][3])
#reading = adc.read_u16()
#return reading
while True:
rp_c0()
utime.sleep_ms(400)
rp_c1()
utime.sleep_ms(400)
rp_c2()
utime.sleep_ms(400)
rp_c3()
utime.sleep_ms(400)
#c0 = var_analog(0)
#c1 = var_analog(1)
#c2 = var_analog(2)
#c3 = var_analog(3)
#c4 = var_analog(4)
#c5 = var_analog(5)
#c6 = var_analog(6)
#c7 = var_analog(7)
#c8 = var_analog(8)
#print("Wert C0 = ", c0)
#,c1,c2,c3,c4,c5,c6,c7,c8)
#utime.sleep_ms(200)
Loading
cd74hc4067
cd74hc4067