Hi everybody
We're just getting started with Arduino and we are already lost
Here's what we wanne do:
We have 3 sensors that represent the colors red, green and blue. Those 3 inputs are either on or off. Depending on which sensors are activated we want to send 7 different DMX-Signals. We decided to use a switch/case function, but we don't know how to define the numbers for the "switch (number)" Here is what we got so far (including further information):
#include <DmxSimple.h>
int redPin = 7; // red sensor Pin7
int greenPin = 8; // green sensor Pin8
int bluePin = 9; // blue sensor Pin9
int LEDPin = 13; // LED Pin13
void setup()
{
/* The most common pin for DMX output is pin 3, which DmxSimple
** uses by default. If you need to change that, do it here. */
DmxSimple.usePin(3);
pinMode(redPin, INPUT);
digitalWrite(redPin, HIGH);
pinMode(greenPin, INPUT);
digitalWrite(greenPin, HIGH);
pinMode(bluePin, INPUT);
digitalWrite(bluePin, HIGH);
pinMode(LEDPin, OUTPUT);
/* DMX devices typically need to receive a complete set of channels
** even if you only need to adjust the first channel. You can
** easily change the number of channels sent here. If you don't
** do this, DmxSimple will set the maximum channel number to the
** highest channel you DmxSimple.write() to. */
DmxSimple.maxChannel(4);
}
// We want to define that if the red sensor is activated we get a value of +1 on pin7, for the green sensor a value of +2 on pin8 … etc. The other four colors will be defined by calculating the values of the sensors.
Sensors:
Red: +1
Green: +2
Blue: +4
Counting results:
Yellow: +1+2 = +3
Magenta: +1+4 = +5
Cyan: +2+4 = +6
white: +1+2+4 = +7
Not sure about the following either:
void loop()
{
int 1 = digitalRead(redPin);
int 2 = digitalRead(greenPin);
int 3 = digitalRead(redPin+greenPin);
int 4 = digitalRead(bluePin);
int 5 = digitalRead(redPin+bluePin);
int 6 = digitalRead(greenPin+bluePin);
int 7 = digitalRead(redPin+greenPin+bluePin);
switch (Number)
{
case 1: //red sensor is activated
DmxSimple.write(11, 255); //Channel 11 -> LED turns red
delay(20);
break;
case 2: //green sensor is activated
DmxSimple.write(12, 255); //Channel 12 -> LED turns green
delay(20);
break;
case 3: //red and green sensor are activated
DmxSimple.write(13, 255); //Channel 13 -> LED turns yellow
delay(20);
break;
case 4: //blue sensor is activated
DmxSimple.write(14, 255); //Channel 14 -> LED turns blue
delay(20);
break;
case 5: //red and blue sensor are activated
DmxSimple.write(15, 255); //Channel 15 -> LED turns magenta
delay(20);
break;
case 6: //green and blue sensor are activated
DmxSimple.write(16, 255); //Channel 16 -> LED turns cyan
delay(20);
break;
case 7: //red, green and blue sensor are activated
DmxSimple.write(17, 255); //Channel 17 -> LED turns white
delay(20);
break;
default:
DmxSimple.write(1, 0);
digitalWrite(LEDPin, HIGH);
}
}
Hope you get an idea of what we want to do and thanks so much for your support!!!
Have a great day,
Insa