Hallo Iedereen,
ik heb even een vraag, ik wil met een arduino uno en een DMX512 board 4 led spots aansturen. ze staan allemaal op kanaal 1.
wat we graag zouden willen is dat de lampen starten met de kleur rood en wanneer een ingang actief word (pin12) dat de lampen faden naar blauw en hierop blijven staan totdat pin 12 niet meer actief is (wanneer pin 12 niet meer actief is dan de lampen weer terug naar rood)
ik had een programma gevonden die al redelijk deed wat we wilden. nu naar een paar maanden bezig te zijn krijg ik het nog steeds niet voor elkaar om wat we willen te bereiken.
onderaan staat de code zover we die nu hebben.
kan iemand hier mee helpen a.u.b?
nog even een korte opsomming hoe we het graag willen:
- de DMX led spots branden continu rood
- als pin 12 hoog word en blijft moeten de lampen faden naar blauw en blijven blauw zolang pin 12 hoog is.
- wanneer pin 12 laag word moeten de lampen weer terug naar rood.
het programma:
// - - - - -
// DmxSerial - A hardware supported interface to DMX.
// DmxSerialSend.ino: Sample DMX application for sending 3 DMX values:
// address 1 (red) -> also available on PWM Port 9
// address 2 (green) -> also available on PWM Port 6
// address 3 (blue) -> also available on PWM Port 5
//
// Copyright (c) 2011 by Matthias Hertel, http://www.mathertel.de
// This work is licensed under a BSD style license. See http://www.mathertel.de/License.aspx
//
// Documentation and samples are available at http://www.mathertel.de/Arduino
// 25.07.2011 creation of the DmxSerial library.
// 10.09.2011 fully control the serial hardware register
// without using the Arduino Serial (HardwareSerial) class to avoid ISR implementation conflicts.
// 01.12.2011 include file and extension changed to work with the Arduino 1.0 environment
// - - - - -
#include <DMXSerial.h>
const int buttonPin = 12;
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
// Constants for demo program
;const int RedPin = 9; // PWM output pin for Red Light.
const int BluePin = 5; // PWM output pin for Blue Light.
// The color fading pattern
int RedList[] = {255, 10, 0, 0, };
int BlueList[] = {0, 0, 255, 255,};
int RedLevel, BlueLevel;
int RedNow = 0;
int BlueNow = 0;
int state = 0;
void setup() {
DMXSerial.init(DMXController);
// initialize the button pin as a input:
pinMode(buttonPin, INPUT);
pinMode(RedPin, OUTPUT); // sets the digital pin as output
pinMode(BluePin, OUTPUT);
} // setup
// loop through the rainbow colors
void loop() {
RedLevel = RedList[state];
BlueLevel = BlueList[state];
if ((RedLevel == RedNow) && (BlueLevel == BlueNow)) {
state += 1;
if (state == 6)
state = 0;
} else {
if (RedNow < RedLevel) RedNow++;
if (RedNow > RedLevel) RedNow--;
DMXSerial.write(1, RedNow);
analogWrite(RedPin, RedNow);
if (BlueNow < BlueLevel) BlueNow++;
if (BlueNow > BlueLevel) BlueNow--;
DMXSerial.write(3, BlueNow);
analogWrite(BluePin, BlueNow);
} // if
delay(30); // wait a little bit
// read the pushbutton input pin:
buttonState = digitalRead(buttonPin);
// compare the buttonState to its previous state
if (buttonState != lastButtonState) ;
// if the state has changed, increment the counter
if (buttonState == HIGH) ;
// if the current state is HIGH then the button
// wend from off to on:
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;} // loop
alvast Heel erg bedankt,
M.v.g
Erik Koevoets
Ik heb geen DMX dus ik kan het niet testen.
Maar je kunt het zo eens proberen:
// - - - - -
// DmxSerial - A hardware supported interface to DMX.
// DmxSerialSend.ino: Sample DMX application for sending 3 DMX values:
// address 1 (red) -> also available on PWM Port 9
// address 2 (green) -> also available on PWM Port 6
// address 3 (blue) -> also available on PWM Port 5
//
// Copyright (c) 2011 by Matthias Hertel, http://www.mathertel.de
// This work is licensed under a BSD style license. See http://www.mathertel.de/License.aspx
//
// Documentation and samples are available at http://www.mathertel.de/Arduino
// 25.07.2011 creation of the DmxSerial library.
// 10.09.2011 fully control the serial hardware register
// without using the Arduino Serial (HardwareSerial) class to avoid ISR implementation conflicts.
// 01.12.2011 include file and extension changed to work with the Arduino 1.0 environment
// - - - - -
#include <DMXSerial.h>
const int buttonPin = 12;
// Constants for demo program
const int RedPin = 9; // PWM output pin for Red Light.
const int BluePin = 5; // PWM output pin for Blue Light.
int RedLevel = 255;
int BlueLevel = 0;
void setup()
{
DMXSerial.init(DMXController);
// initialize the button pin as a input:
pinMode(buttonPin, INPUT);
pinMode(RedPin, OUTPUT); // sets the digital pin as output
pinMode(BluePin, OUTPUT);
} // setup
// loop through the rainbow colors
void loop()
{
// Here we use a short delay to get controlled timing
// - 10 milliseconds per loop = 100 loops per second
// - We need 255 loops to fade all the way from 0 to 255
// Takes approx 2.5 seconds.
delay(10); // wait a little bit
if(digitalRead(buttonPin))
{ // Button is active, So we should fade to blue
if (RedLevel > 0)
{ RedLevel -= 1;
}
if (BlueLevel < 255)
{ BlueLevel += 1;
}
}
else
{ // Button Not active active, So we should fade back to Red
if (RedLevel < 255)
{ RedLevel += 1;
}
if (BlueLevel > 0)
{ BlueLevel -= 1;
}
}
DMXSerial.write(1, RedLevel);
analogWrite(RedPin, RedLevel);
DMXSerial.write(3, BlueLevel);
analogWrite(BluePin, BlueLevel);
}rew
four NANDS do make a NOR . Kijk ook eens in onze shop: http://www.bitwizard.nl/shop/
Die button pin, moet die niet gewoon INPUT_PULLUP worden ipv alleen INPUT?
Ik zou een enkele variabele nemen die rood-blauw fadelevel aangeeft;
if (digitalRead(buttonPin))
if (fade < 255) fade++;
else
if (fade > 0) fade--;
vervolgens kan je de hoeveelheid rood en blauw uitrekenen:
RedLevel = fade;
BlueLevel = 255-fade;
en die naar de DMX schrijven.
DMXSerial.write(1, RedLevel);
DMXSerial.write(3, BlueLevel);
Als... tenminste dat DMX gebeuren werkt zoals ik denk dat het werkt.
Ik zelf zou de extra variabelen redlevel weglaten:
DMXSerial.write(1, fade);
DMXSerial.write(3, 255-fade);
omdat het dan korter wordt. Maar als je graag de tussenstap ziet, zoals ik vermoed, dan doe je dat.
Staan de spots wel in kale RGB mode ? De meeste kunnen ook RGBI, HSB en andere dingen.
Welke sanity checks heb je gedaan ?
@aarts
de lampen zijn simpele rgb led spots.en werken op 6 kanalen als ik het goed zeg,
kanaal:
1=rood
2=groen
3=blauw
en de andere zijn voor strobo en muziek functie aanzetten.
@DeKees
allereerst heel erg bedankt voor de moeite, dat waardeer ik echt.
(met uw wijzigingen)
is het alleen zo dat wanneer de arduino gekoppeld word aan de spots dan starten ze met blauw en rood gemengd en binnen enkele seconden faden de rode leds automatisch weg zonder dat er iets veranderd aan pin 12.
M.v.g
Erik Koevoets
Als pin 12 laag is, dan moet de rode leds aan gaan, en de blauwe uit.
Pin 12 moet wel altijd aangestuurd worden, als pin 12 niet is aangesloten dan kan die zomaar vanzelf veranderen.
rew
four NANDS do make a NOR . Kijk ook eens in onze shop: http://www.bitwizard.nl/shop/
Op 2 november 2016 08:58:49 schreef rew:
Die button pin, moet die niet gewoon INPUT_PULLUP worden ipv alleen INPUT?