Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int dimmerporcent =0;
- int dimmer=0;
- int strobo=0;
- int r=0;
- int g=0;
- int b=0;
- int pan =0;
- int pan1 =0;
- boolean paninvert=0;
- boolean tiltinvert=0;
- int tilt =0;
- int tilt1 =0;
- int vel=0;
- boolean menu=0;
- boolean menudmx=1;
- boolean menupan=0;
- boolean menutilt=0;
- int dmx =1;
- #include <DMXSerial.h>
- #include <Wire.h>
- #include <EEPROM.h>
- #include <LCD.h>
- #include <LiquidCrystal_I2C.h>
- LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7); // 0x27 is the I2C bus address for an unmodified backpack
- void setup () {
- dmx = EEPROM.read(0);
- paninvert=EEPROM.read(1);
- tiltinvert=EEPROM.read(2);
- DMXSerial.init(DMXReceiver);
- Wire.begin();
- lcd.begin (16,2); // LCD 16 x 2
- lcd.setBacklightPin(3,POSITIVE);
- lcd.setBacklight(HIGH);
- pinMode(5,OUTPUT);//r
- pinMode(6,OUTPUT);//g
- pinMode(9,OUTPUT);//b
- pinMode(A0,INPUT); //botões painel original da moving
- //pinMode(3,OUTPUT);//linha 1
- //pinMode(4,OUTPUT);//linha 2
- //pinMode(12,INPUT);//coluna 1
- //pinMode(13,INPUT);//coluna 2
- lcd.clear();
- lcd.home (); // volta para 0,0
- lcd.setCursor (0,0); //preimeiro e a coluna e segundo e a linha
- lcd.print("Everton Moving");
- }
- void loop() {
- unsigned long lastPacket = DMXSerial.noDataSince();
- if (lastPacket < 5000) {
- pan1=(DMXSerial.read(dmx));
- tilt1=(DMXSerial.read(dmx+1));
- r=(DMXSerial.read(dmx+2));
- g= (DMXSerial.read(dmx+3));
- b= (DMXSerial.read(dmx+4));
- dimmer=(DMXSerial.read(dmx+5));
- strobo=(DMXSerial.read(dmx+6));
- vel=(DMXSerial.read(dmx+7));
- }
- if (paninvert==1){ pan=map(pan1,0,255,255,0); } else{ pan=pan1; }
- if (tiltinvert==1){ tilt=map(tilt1,0,255,255,0); } else{ tilt=tilt1; }
- if (menu==0){
- Wire.beginTransmission(8);
- Wire.write(pan);
- Wire.write(tilt);
- Wire.write(vel);
- Wire.endTransmission();
- dimmerporcent = map(dimmer,0,255,0,100);
- int stroboporcent = map(strobo,0,255,400,10);
- int r_final = r * dimmerporcent / 100;
- int g_final = g * dimmerporcent / 100;
- int b_final = b * dimmerporcent / 100;
- if( strobo > 1 ){
- analogWrite(5,0);
- analogWrite(6,0);
- analogWrite(9,0);
- delay(stroboporcent);
- analogWrite(5,r_final);
- analogWrite(6,g_final);
- analogWrite(9,b_final);
- delay (stroboporcent);
- }else{
- analogWrite(5,r_final);
- analogWrite(6,g_final);
- analogWrite(9,b_final);
- }
- }
- //if (menu==1){}
- //if (menu==0){lcd.clear(); lcd.home (); lcd.setCursor (0,0); lcd.print("Everton Moving");}
- //for(int i =3; i < 5 ; i++){
- //digitalWrite(3,LOW);
- //digitalWrite(4,LOW);
- //digitalWrite(i,HIGH);
- int botao = analogRead(A0);
- //menu
- if (botao>214 & botao<218 ){menu=!menu; analogWrite(5,0); analogWrite(6,0); analogWrite(9,0); delay(200);
- if (menu==0){lcd.clear(); lcd.home (); lcd.setCursor (0,0); lcd.print("Everton Moving");menudmx=1; menupan=0;menutilt=0;}
- if (menu==1){lcd.clear(); lcd.home (); lcd.setCursor (0,0); lcd.print("Canal DMX");lcd.home (); lcd.setCursor (11,0); lcd.print(dmx);}
- }
- //alterna menu
- if (botao>853 & botao<857 & menu==1){
- delay(200);
- if(menudmx==1){
- menupan=1;
- menudmx=0;
- menutilt=0;}else{if(menupan==1){
- menudmx=0;
- menupan=0;
- menutilt=1;}else{
- if(menutilt==1){
- menudmx=1;
- menupan=0;
- menutilt=0;}
- } }
- if (menudmx==1){
- lcd.clear(); lcd.home (); lcd.setCursor (0,0); lcd.print("Canal DMX");lcd.home (); lcd.setCursor (11,0); lcd.print(dmx);
- }
- if (menupan==1){
- lcd.clear(); lcd.home (); lcd.setCursor (0,0); lcd.print("PAN");lcd.home (); lcd.setCursor (11,0); lcd.print(paninvert);
- }
- if (menutilt==1){
- lcd.clear(); lcd.home (); lcd.setCursor (0,0); lcd.print("TILT");lcd.home (); lcd.setCursor (11,0); lcd.print(tiltinvert);
- }
- }
- //botão pra cima
- if (botao>432 & botao<436 & menu==1){
- delay(150);
- if (menudmx==1& menu==1){
- dmx=dmx+1;EEPROM.write(0,dmx);
- if(dmx==513){dmx=1;}
- lcd.clear(); lcd.home (); lcd.setCursor (0,0); lcd.print("Canal DMX");lcd.home (); lcd.setCursor (11,0); lcd.print(dmx);
- }
- if (menupan==1& menu==1){
- paninvert=1;
- EEPROM.write(1,paninvert);
- lcd.clear(); lcd.home (); lcd.setCursor (0,0); lcd.print("PAN");lcd.home (); lcd.setCursor (11,0); lcd.print(paninvert);
- }
- if (menutilt==1& menu==1){
- tiltinvert=1;
- EEPROM.write(2,tiltinvert);
- lcd.clear(); lcd.home (); lcd.setCursor (0,0); lcd.print("TILT");lcd.home (); lcd.setCursor (11,0); lcd.print(tiltinvert);
- }
- }
- //botão pra baixo
- if (botao>648 & botao<652 & menu==1){
- delay(150);
- if (menudmx==1& menu==1){
- dmx=dmx-1;EEPROM.write(0,dmx);
- if(dmx==0){dmx=512;}
- lcd.clear(); lcd.home (); lcd.setCursor (0,0); lcd.print("Canal DMX");lcd.home (); lcd.setCursor (11,0); lcd.print(dmx);
- }
- if (menupan==1& menu==1){
- paninvert=0;
- EEPROM.write(1,paninvert);
- lcd.clear(); lcd.home (); lcd.setCursor (0,0); lcd.print("PAN");lcd.home (); lcd.setCursor (11,0); lcd.print(paninvert);
- }
- if (menutilt==1& menu==1){
- tiltinvert=0;
- EEPROM.write(2,tiltinvert);
- lcd.clear(); lcd.home (); lcd.setCursor (0,0); lcd.print("TILT");lcd.home (); lcd.setCursor (11,0); lcd.print(tiltinvert);
- }
- }
- //}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement