hi all,
I’m still very new to Arduino so i am hoping you can help me.
i’ve been trying to make a dmx controlled light. and it works with dimming the led’s, only i am trying to implement a master and a strobe. and i cant figure out how.
hopefully you can help me
i am using the arduino nano.
this is the code i’m using
#include <DMXSerial.h>
const int RedPin = 3;
const int GreenPin = 5;
const int BluePin = 6;
const int Input1 = 10;
const int Input2 = 11;
const int Input3 = 12;
const int Input4 = 13;
const int Input5 = A0;
const int Input6 = A1;
const int Input7 = A2;
const int Input8 = A3;
const int Input9 = A4;
const int Input10 = A5;
int Dip1 = 0;
int Dip2 = 0;
int Dip3 = 0;
int Dip4 = 0;
int Dip5 = 0;
int Dip6 = 0;
int Dip7 = 0;
int Dip8 = 0;
int Dip9 = 0;
int Dip10 = 0;
int startAddress = 1;
void setup () {
DMXSerial.init(DMXReceiver);
pinMode(RedPin, OUTPUT);
pinMode(GreenPin, OUTPUT);
pinMode(BluePin, OUTPUT);
pinMode(Input1, INPUT);
pinMode(Input2, INPUT);
pinMode(Input3, INPUT);
pinMode(Input4, INPUT);
pinMode(Input5, INPUT);
pinMode(Input6, INPUT);
pinMode(Input7, INPUT);
pinMode(Input8, INPUT);
pinMode(Input9, INPUT);
pinMode(Input10, INPUT);
}
void loop () {
if (digitalRead(Input1) == HIGH) {
Dip1 = 1;
}
if (digitalRead(Input1) == LOW) {
Dip1 = 0;
}
if (digitalRead(Input2) == HIGH) {
Dip2 = 2;
}
if (digitalRead(Input2) == LOW) {
Dip2 = 0;
}
if (digitalRead(Input3) == HIGH) {
Dip3 = 4;
}
if (digitalRead(Input3) == LOW) {
Dip3 = 0;
}
if (digitalRead(Input4) == HIGH) {
Dip4 = 8;
}
if (digitalRead(Input4) == LOW) {
Dip4 = 0;
}
if (digitalRead(Input5) == HIGH) {
Dip5 = 16;
}
if (digitalRead(Input5) == LOW) {
Dip5 = 0;
}
if (digitalRead(Input6) == HIGH) {
Dip6 = 32;
}
if (digitalRead(Input6) == LOW) {
Dip6 = 0;
}
if (digitalRead(Input7) == HIGH) {
Dip7 = 64;
}
if (digitalRead(Input7) == LOW) {
Dip7 = 0;
}
if (digitalRead(Input8) == HIGH) {
Dip8 = 128;
}
if (digitalRead(Input8) == LOW) {
Dip8 = 0;
}
if (digitalRead(Input9) == HIGH) {
Dip9 = 256;
}
if (digitalRead(Input9) == LOW) {
Dip9 = 0;
}
if (digitalRead(Input10) == HIGH) {
Dip10 = 512;
}
if (digitalRead(Input10) == LOW) {
Dip10 = 0;
}
startAddress = Dip1 + Dip2 + Dip3 + Dip4 + Dip5 + Dip6 + Dip7 + Dip8 + Dip9 + Dip10;
if (startAddress == 0) {
startAddress = 1;
}
if (startAddress > 512) {
startAddress = 512;
}
int MasterChannel = DMXSerial.read(startAddress);
int RedChannel = DMXSerial.read(startAddress + 1);
int GreenChannel = DMXSerial.read(startAddress + 2);
int BlueChannel = DMXSerial.read(startAddress + 3);
int StrobeChannel = DMXSerial.read(startAddress + 4);
analogWrite(RedPin, RedChannel);
analogWrite(BluePin, BlueChannel);
analogWrite(GreenPin, GreenChannel);
}
Thanks in advance.