Funhouse won't control items on A0 and A1 at same time

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
diggee17
 
Posts: 45
Joined: Mon Feb 12, 2018 7:18 pm

Funhouse won't control items on A0 and A1 at same time

Post by diggee17 »

I'm recreating an Adafruit funhouse project that I found in a Make magazine from last year. It is supposed to control a micro server on pin A0 and a 30 LED strip on A2. It can control the LED strip best alone. It struggles to control the servo alone but It will NOT control both the servo and the strip together at all. As shown in the code I’m including, I have changed the number of pixels to 10 but that hasn’t helped.

I don’t have a Stemma Micro Servo. So I’m using a regular micro servo connected to A0 via a a female-female wire connected to a stemma male connector that I received in the Funhouse Adabox. Is this the problem is this too long of a connection?

I’m attaching picture of physical setup.
picture of funhouse with items attached
picture of funhouse with items attached
IMG_0475.jpg (231.17 KiB) Viewed 1616 times
Code below:

Code: Select all

import time
import board
import pwmio
import neopixel
from adafruit_motor import servo
from adafruit_funhouse import FunHouse
from adafruit_datetime import datetime, timedelta

funhouse = FunHouse()
pixel_pin = board.A2
num_pixels = 10
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.05, auto_write=False)
pwm = pwmio.PWMOut(board.A0, duty_cycle=2 ** 15, frequency=50)
my_servo = servo.Servo(pwm)

def color_chase(color, wait):
    for i in range(num_pixels):
        pixels[i] = color
        time.sleep(wait)
        pixels.show()
    time.sleep(0.1)

RED = (255, 0, 0, 0)
YELLOW = (255, 150, 0, 0)
GREEN = (0, 255, 0, 0)
CYAN = (0, 255, 255, 0)
BLUE = (0, 0, 255, 0)
PURPLE = (180, 0, 255, 0)
WHITE = (255, 255, 255)
OFF = (0, 0, 0)

while True:
    if funhouse.peripherals.pir_sensor:
        my_servo.angle = 90
        time.sleep(1)
        color_chase(RED, 0.05)
        color_chase(YELLOW, 0.05)
        color_chase(GREEN, 0.05)
        color_chase(CYAN, 0.05)
        color_chase(BLUE, 0.05)
        color_chase(PURPLE, 0.05)
        color_chase(WHITE, 0.05)
        my_servo.angle = 0
        time.sleep(5)
    else:
        color_chase(OFF, 0.05)
        time.sleep(5)
Thanks.

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Funhouse won't control items on A0 and A1 at same time

Post by dastels »

First of all, what do you mean when you say it struggles to control the servo? What happens when you try to do both the servo and NeoPixels?

Dave

User avatar
diggee17
 
Posts: 45
Joined: Mon Feb 12, 2018 7:18 pm

Re: Funhouse won't control items on A0 and A1 at same time

Post by diggee17 »

thanks for your reply. The servo is supposed to move when you wave your hand in front of the PIR sensor. Also the neopixels should light up. I can get one action to happen but not both. Sorry if I wasn't clear.

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Funhouse won't control items on A0 and A1 at same time

Post by dastels »

I understand what you want to happen. But what exactly does happen? I'm still not clear on what "struggles to control the servo" means.

Maybe a video would help?

Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “AdaBox! Show us what you made!”