add basic AS7343 example

pull/961/head
Hel Gibbons 2024-06-14 15:29:14 +01:00
rodzic f18f1ba259
commit 209c3d1c04
1 zmienionych plików z 28 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,28 @@
# Prints data from the AS7343 sensor to the console
# Open up the plotter window in Thonny to see the values change in real-time!
from breakout_as7343 import BreakoutAS7343
from pimoroni_i2c import PimoroniI2C
import time
# use (sda=20, scl=21) if you have a Pico Explorer Base or other board that uses the alt I2C pins
i2c = PimoroniI2C(sda=4, scl=5)
as7343 = BreakoutAS7343(i2c)
as7343.set_channels(18)
as7343.set_gain(1024)
as7343.set_measurement_time(33) # Roughly 30fps at 16ms/measurement
as7343.set_integration_time(27800)
as7343.set_illumination_current(4)
as7343.set_illumination_led(True)
while True:
reading = as7343.read()
print(
"FZ: {0}, FY: {1}, FXL: {2}, NIR: {3}, F2: {4}, F3: {5}, F4: {6}, F6: {7}, F1: {8}, F5: {9}, F7: {10}, F8: {11}".format(
*reading
)
)
time.sleep(0.01)