I am currently trying to make a DMX moving light, essentially, I am trying to control two stepper motors and neopixels through DMX and am using an Atmega168p microcontroller. First, I want to get the neopixels working, and right now, the following code works. The neopixels all turn on and then off in the setup, and then I can control them through the DMX.
#include <DMXSerial.h> // get the libary at: https://github.com/mathertel/DMXSerial by: mathertel
#include <Adafruit_NeoPixel.h>
#include <AccelStepper.h>
#include <MultiStepper.h>
// Constants for the program
#define PAN_DIR 9
#define PAN_STEP 10
#define TILT_DIR 4
#define TILT_STEP 3
#define NUM_LEDS 10
#define LED 5
#define STATUS 2
Adafruit_NeoPixel led = Adafruit_NeoPixel(NUM_LEDS, LED, NEO_GRB + NEO_KHZ800);
//AccelStepper pan = AccelStepper(1, PAN_STEP, PAN_DIR);
//AccelStepper tilt = AccelStepper(1, TILT_STEP, TILT_DIR);
//MultiStepper steppers;
int startAddress = 1;
void setup () {
DMXSerial.init(DMXReceiver);
pinMode(STATUS, OUTPUT);
delay(1000);
led.begin();
led.show();
color(255,255,255);
digitalWrite(STATUS,HIGH);
delay(1000);
color(0,0,0);
digitalWrite(STATUS,LOW);
}
void loop() {
unsigned long lastPacket = DMXSerial.noDataSince();
startAddress=1;
int dmxRed = DMXSerial.read(startAddress);
int dmxGreen = DMXSerial.read(startAddress+1);
int dmxBlue = DMXSerial.read(startAddress+2);
int dmxIntensity = DMXSerial.read(startAddress+3);
if (lastPacket < 10)
{
properties(dmxRed,dmxGreen,dmxBlue,dmxIntensity);
}
else
{
digitalWrite(STATUS,HIGH);
delay(200);
digitalWrite(STATUS,LOW);
}
}
void properties(int red, int green, int blue, int intens)
{
color(red, green, blue);
intensity(intens);
}
void color(int redVal, int greenVal, int blueVal)
{
for (int i=0; i<NUM_LEDS; i++)
{
led.setPixelColor(i,redVal,greenVal,blueVal);
}
led.show();
}
void intensity(int intens)
{
led.setBrightness(intens);
led.show();
}
However, as soon as I uncomment the below piece of code so that I can start implementing the stepper motors, it stops working. The neopixels do not turn on and then off as they are supposed to, and I also can't control the neopixels through the DMX.
AccelStepper pan = AccelStepper(1, PAN_STEP, PAN_DIR);
AccelStepper tilt = AccelStepper(1, TILT_STEP, TILT_DIR);`
When I try the same code using an Arduino Uno, however, it works fine. This makes me think that it's a problem with the microcontroller or how I wired it up to the microcontroller.
Here is my wiring schematic that I'm using
If I could get any assistance to get this working that'd be great.