Funhouse won't control micro servo and neopixel strip at sam

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

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 micro servo and neopixel strip at sam

Post by diggee17 »

'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 neopixel strip on A2. It can control the neopixel 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 lowered the number of neopixels 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:
Physical setup
Physical setup
IMG_0475.jpg (231.17 KiB) Viewed 467 times
The code
code.py
(1.17 KiB) Downloaded 5 times

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)
Any suggestions will be appreciated.

User avatar
adafruit_support_bill
 
Posts: 88136
Joined: Sat Feb 07, 2009 10:11 am

Re: Funhouse won't control micro servo and neopixel strip at

Post by adafruit_support_bill »

Please do not double post! viewtopic.php?f=59&t=183903#p892991

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

Return to “Adafruit CircuitPython”