Neopixel ring and servo on a flora

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
THiSiSVANiTY
 
Posts: 2
Joined: Sat May 09, 2015 1:43 am

Neopixel ring and servo on a flora

Post by THiSiSVANiTY »

Hi guys,

I am trying to control a 16 LED neopixel ring alongside a 5v servo on an arduino flora with 4xAAA batteries (because I know the pixel ring and servo need 5v to work). I have previously made my servo and the neoring separately from each other on the flora and I know I need to use this code (https://learn.adafruit.com/trinket-gemm ... ntrol/code) however when I turn the batteries on the servo does not work and the LED's flash momentarily then turn off.
Can anyone provide advice for what I am doing wrong?

Thanks!
Maggie

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: Neopixel ring and servo on a flora

Post by Franklin97355 »

Could you post the code you are having trouble with?

User avatar
THiSiSVANiTY
 
Posts: 2
Joined: Sat May 09, 2015 1:43 am

Re: Neopixel ring and servo on a flora

Post by THiSiSVANiTY »

Code: Select all

#if defined(__AVR_ATtiny85__)
 #error "This code is for ATmega boards, see other example for ATtiny."
#endif
#include <Adafruit_NeoPixel.h>
#include <Adafruit_TiCoServo.h>

// NeoPixel parameters. These are configurable, but the pin number must
// be different than the servo(s).
#define N_LEDS       60
#define LED_PIN       6

#define SERVO_PIN    9
#define SERVO_MIN 1000 // 1 ms pulse
#define SERVO_MAX 2000 // 2 ms pulse

Adafruit_NeoPixel  strip = Adafruit_NeoPixel(N_LEDS, LED_PIN);
Adafruit_TiCoServo servo;

void setup(void) {
  servo.attach(SERVO_PIN, SERVO_MIN, SERVO_MAX);
  strip.begin();
}

void loop(void) {
  int a, x;
  a = analogRead(0);                            // 0 to 1023
  x = map(a, 0, 1023, SERVO_MIN, SERVO_MAX);    // Scale to servo range
  servo.write(x);                               // Move servo
  x = map(a, 0, 1023, 0, strip.numPixels());    // Scale to strip length
  strip.clear();
  while(x--) strip.setPixelColor(x, 255, 0, 0); // Set pixels
  strip.show();                                 // Update strip
}
Last edited by Franklin97355 on Sat May 23, 2015 10:16 am, edited 1 time in total.
Reason: Please use [code] tags when posting code or the </> button and paste code between tags.

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: Neopixel ring and servo on a flora

Post by Franklin97355 »

Could you post clear, detailed pictures of both sides of your board showing any soldering you have done and the connections to it?

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

Return to “Arduino”