GMTROM/Archiv/ADS_Pi_einfach.py

16 lines
347 B
Python
Raw Permalink Normal View History

2023-06-13 09:12:10 +02:00
import Adafruit_ADS1x15
adc = Adafruit_ADS1x15.ADS1115(address=0x48, busnum=1)
binary_string = ''
random_number = 0
for i in range(1024):
raw_value = adc.read_adc(0, gain=1)
lsb =(raw_value & 0x01) << i
#binary_string= bin(lsb)[2:].zfill(32) + binary_string
random_number |= lsb
print("Random Number:", random_number)