Updating code to CP 8

Updating two project code files from guide feedback
This commit is contained in:
Liz 2024-01-08 07:47:36 -05:00
parent cdb71d4ffd
commit 6292092bc6
2 changed files with 5 additions and 7 deletions

View file

@ -8,7 +8,7 @@ import adafruit_scd4x
import sdcardio import sdcardio
import busio import busio
import storage import storage
import adafruit_pcf8523 from adafruit_pcf8523.pcf8523 import PCF8523
# setup for I2C # setup for I2C
i2c = board.I2C() # uses board.SCL and board.SDA i2c = board.I2C() # uses board.SCL and board.SDA
@ -16,7 +16,7 @@ i2c = board.I2C() # uses board.SCL and board.SDA
# setup for SCD40 # setup for SCD40
scd4x = adafruit_scd4x.SCD4X(i2c) scd4x = adafruit_scd4x.SCD4X(i2c)
# setup for RTC # setup for RTC
rtc = adafruit_pcf8523.PCF8523(i2c) rtc = PCF8523(i2c)
# start measuring co2 with SCD40 # start measuring co2 with SCD40
scd4x.start_periodic_measurement() scd4x.start_periodic_measurement()
# list of days to print to the text file on boot # list of days to print to the text file on boot

View file

@ -4,27 +4,25 @@
import time import time
import adafruit_motor.servo from adafruit_motor import servo
import board import board
import pwmio import pwmio
from analogio import AnalogIn from analogio import AnalogIn
from digitalio import DigitalInOut, Direction, Pull from digitalio import DigitalInOut, Direction, Pull
pwm = pwmio.PWMOut(board.D5, frequency=50) pwm = pwmio.PWMOut(board.D5, frequency=50)
servo = adafruit_motor.servo.Servo(pwm)
switch = DigitalInOut(board.D7) switch = DigitalInOut(board.D7)
switch.direction = Direction.INPUT switch.direction = Direction.INPUT
switch.pull = Pull.UP switch.pull = Pull.UP
pot = AnalogIn(board.A0) pot = AnalogIn(board.A0)
continuous = adafruit_motor.servo.ContinuousServo(pwm) continuous = servo.ContinuousServo(pwm)
def val(pin): def val(pin):
# divides voltage (65535) to get a value between 0 and 1 # divides voltage (65535) to get a value between 0 and 1
return pin.value / 65535 return pin.value / 65535
while True: while True:
if switch.value: if switch.value: