kopia lustrzana https://github.com/pimoroni/pimoroni-pico
MP example tweaks
rodzic
a0f12c679f
commit
fe32ac8ce7
|
@ -25,9 +25,6 @@ TIME_BETWEEN = 0.001 # The time between each current measurement
|
|||
# Free up hardware resources ahead of creating a new ServoCluster
|
||||
gc.collect()
|
||||
|
||||
# Create the user button
|
||||
user_sw = Button(servo2040.USER_SW)
|
||||
|
||||
# Create a servo cluster for pins 0 to 7, using PIO 0 and State Machine 0
|
||||
START_PIN = servo2040.SERVO_1
|
||||
END_PIN = servo2040.SERVO_8
|
||||
|
@ -44,6 +41,9 @@ mux = AnalogMux(servo2040.ADC_ADDR_0, servo2040.ADC_ADDR_1, servo2040.ADC_ADDR_2
|
|||
# Create the LED bar, using PIO 1 and State Machine 0
|
||||
led_bar = WS2812(servo2040.NUM_LEDS, 1, 0, servo2040.LED_DATA)
|
||||
|
||||
# Create the user button
|
||||
user_sw = Button(servo2040.USER_SW)
|
||||
|
||||
# Start updating the LED bar
|
||||
led_bar.start()
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ Demonstrates how to create multiple Servo objects and control them together.
|
|||
|
||||
# Create a list of servos for pins 0 to 3. Up to 16 servos can be created
|
||||
START_PIN = servo2040.SERVO_1
|
||||
END_PIN = servo2040.SERVO_3
|
||||
END_PIN = servo2040.SERVO_4
|
||||
servos = [Servo(i) for i in range(START_PIN, END_PIN + 1)]
|
||||
|
||||
# Enable all servos (this puts them at the middle)
|
||||
|
|
|
@ -10,9 +10,6 @@ and 2 internal sensors of Servo 2040.
|
|||
Press "Boot" to exit the program.
|
||||
"""
|
||||
|
||||
# Create the user button
|
||||
user_sw = Button(servo2040.USER_SW)
|
||||
|
||||
# Set up the shared analog inputs
|
||||
sen_adc = Analog(servo2040.SHARED_ADC)
|
||||
vol_adc = Analog(servo2040.SHARED_ADC, servo2040.VOLTAGE_GAIN)
|
||||
|
@ -28,6 +25,9 @@ sensor_addrs = list(range(servo2040.SENSOR_1_ADDR, servo2040.SENSOR_6_ADDR + 1))
|
|||
for addr in sensor_addrs:
|
||||
mux.configure_pull(addr, Pin.PULL_DOWN)
|
||||
|
||||
# Create the user button
|
||||
user_sw = Button(servo2040.USER_SW)
|
||||
|
||||
|
||||
# Read sensors until the user button is pressed
|
||||
while user_sw.raw() is not True:
|
||||
|
|
|
@ -18,9 +18,6 @@ If you encounter issues, try resetting your board.
|
|||
BRIGHTNESS = 0.4 # The brightness of the LEDs
|
||||
UPDATES = 50 # How many times to update LEDs and Servos per second
|
||||
|
||||
# Create the user button
|
||||
user_sw = Button(servo2040.USER_SW)
|
||||
|
||||
# Set up the shared analog inputs
|
||||
sen_adc = Analog(servo2040.SHARED_ADC)
|
||||
|
||||
|
@ -36,6 +33,9 @@ for addr in sensor_addrs:
|
|||
# Create the LED bar, using PIO 1 and State Machine 0
|
||||
led_bar = WS2812(servo2040.NUM_LEDS, 1, 0, servo2040.LED_DATA)
|
||||
|
||||
# Create the user button
|
||||
user_sw = Button(servo2040.USER_SW)
|
||||
|
||||
# Start updating the LED bar
|
||||
led_bar.start()
|
||||
|
||||
|
|
|
@ -17,9 +17,6 @@ UPDATES_PER_MOVE = TIME_FOR_EACH_MOVE * UPDATES
|
|||
SERVO_EXTENT = 80 # How far from zero to move the servo
|
||||
USE_COSINE = True # Whether or not to use a cosine path between values
|
||||
|
||||
# Create the user button
|
||||
user_sw = Button(servo2040.USER_SW)
|
||||
|
||||
# Create a servo on pin 0
|
||||
s = Servo(servo2040.SERVO_1)
|
||||
|
||||
|
@ -27,6 +24,10 @@ s = Servo(servo2040.SERVO_1)
|
|||
start_value = s.mid_value()
|
||||
end_value = random.uniform(-SERVO_EXTENT, SERVO_EXTENT)
|
||||
|
||||
# Create the user button
|
||||
user_sw = Button(servo2040.USER_SW)
|
||||
|
||||
|
||||
update = 0
|
||||
|
||||
# Continually move the servo until the user button is pressed
|
||||
|
|
Ładowanie…
Reference in New Issue