crickitify
This commit is contained in:
parent
0caecfca5b
commit
fef35d4017
1 changed files with 9 additions and 18 deletions
|
|
@ -1,28 +1,19 @@
|
||||||
import time
|
import time
|
||||||
from busio import I2C
|
from adafruit_crickit import crickit
|
||||||
from adafruit_seesaw.seesaw import Seesaw
|
|
||||||
from adafruit_seesaw.pwmout import PWMOut
|
|
||||||
from adafruit_motor import motor
|
|
||||||
import board
|
|
||||||
|
|
||||||
# Create seesaw object
|
# Create one motor on seesaw motor port #1
|
||||||
i2c = I2C(board.SCL, board.SDA)
|
motor = crickit.dc_motor_1
|
||||||
seesaw = Seesaw(i2c)
|
motor.throttle = 0.5 # half speed forward
|
||||||
|
|
||||||
# Create one motor on seesaw PWM pins 22 & 23
|
# Create drive (PWM) object for the lights on Drive 1
|
||||||
motor_a = motor.DCMotor(PWMOut(seesaw, 22), PWMOut(seesaw, 23))
|
lights = crickit.drive_1
|
||||||
motor_a.throttle = 0.5 # half speed forward
|
lights.frequency = 1000 # Our default frequency is 1KHz
|
||||||
|
|
||||||
# Create drive (PWM) object
|
|
||||||
my_drive = PWMOut(seesaw, 13) # Drive 1 is on s.s. pin 13
|
|
||||||
my_drive.frequency = 1000 # Our default frequency is 1KHz
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
lights.fraction = 0.5 # half on
|
||||||
my_drive.duty_cycle = 32768 # half on
|
|
||||||
time.sleep(0.8)
|
time.sleep(0.8)
|
||||||
|
|
||||||
my_drive.duty_cycle = 16384 # dim
|
lights.fraction = 0.2 # dim
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
# and repeat!
|
# and repeat!
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue