Lab_interaccio/2021/DMX_chimenea/DMX_chimenea.ino
2025-02-25 21:29:42 +01:00

77 lines
1.7 KiB
C++

#include <DmxSimple.h>
int fader1, fader2;
int inc = 1;
int brightness = 0;
int rojo = 1;
int verde = 2;
int azul = 3;
int blanco = 4;
int ambar = 5;
int humo1 = 6;
int humo2 = 8;
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. */
Serial.begin(9600);
DmxSimple.usePin(3);
/* 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(16);
}
void loop()
{
/* Simple loop to ramp up brightness */
fader1 = 1 + analogRead(A4)/4; // rango maximo de 255
fader2 = analogRead(A3)/4; // rango maximo de 255
//Serial.print(fader1);
//Serial.print(" ");
//Serial.print(fader2);
//Serial.println();
brightness = brightness + inc;
DmxSimple.write(1, brightness);
DmxSimple.write(2, brightness/2);
DmxSimple.write(3, 0);
DmxSimple.write(4, 255-brightness);
DmxSimple.write(5, 255-brightness);
// DmxSimple.write(1, brightness);
// DmxSimple.write(2, brightness/4);
// DmxSimple.write(3, 0);
// DmxSimple.write(4, 255);
// DmxSimple.write(5, 0);
DmxSimple.write(6, fader2);
DmxSimple.write(8, fader2);
if(brightness >= 250)
inc = -1;
if(brightness <= 5)
inc = 1;
//Serial.print("brightness: ");
//Serial.print(brightness);
//Serial.print(" incremento: ");
//Serial.print(inc);
//Serial.println();
delay(fader1);
}