-------------------------------------code example

The downloads on this page are .zip files, but missing their extensions. After downloading them, add ".zip" to their name and unzip them.

/*In the following explanation we use digital Pin 11 on Arduino to send
the data to the Max485 Driver Block and futher more to the DMX slaves.
You could get problems with the timing while not useing
pin11 or pin3 for sending the dmx signal*/

At first we have to connect the Arduino-DMX Outputs to the Transceiver DMX-Inputs and each Transceiver Output to one 220 Ohm Resistor, a LED and then to Ground.

If you have a look in the loop of this example you will find at first the break, the Start-Byte, 8 times ShiftDmxOut for the first 8 Channel and then a “for” loop to send a Intensity of 0% for the rest 504 Channels.

In this example the 1st Channel and the 8th Channel are set to 100 %.

Task 1: Set Channel 1, 8 to 0% and Channel 3 to 50% (50% of 255 = 50 * 2,5 = 125)

Task 2: Set the Start-Address of the Transceiver to 51 and set Channel 55 to 75%

		To set Channel 55 to 75% we have to write 75% in the 55 Byte of the packet.
		The best will be to use a “for” loop to send 54 Bytes (with the value 0)
		Then write the 55 Byte with the right Value.
		And again a “for” loop to set the rest of the 512 Channels to 0.




This example is just a nice looking one. You will see that you are able to use an Integer to set the Value (Intensity) for the Channels. This easy function is using the Integer Updown to know if he should fade up or down right now. Swing is an Integer for the Intensity, which is fading up and down between 0 and 156.




This example is using a Piezo speaker as a “knock” Sensor, to trigger a defined action. We are using the Piezo like a typical AnlogRead Sensor with a 1M Ohm Resistor as a pull-up.

				

The “knock” Sensor is triggering the ValueNok Integer. IF we “knock”, the Integer for the Channel Intensity (NokTrig) will be set to 255 and fading slowly down.




For this example we are using the same set up like for the normal nok_sensor. But we use an array (chanValue) to set the value for the first 8th Channels. In this array you will find different Set’s of Intensity (cues). We are swapping from cue to cue by “knocking”.
If we “knock” we set cue +1. When we sending the DMX we read the value of cue and multiply it with 8 and read these positions out of the array.
For example: if cue is 2 we reading poiton 16 to 24 out of the array. So:

  • Channel 1 will get a Value of 255,
  • Channel 2 will get a Value of0,
  • Channel 3 will get a Value of 255,
  • Channel 4 will get a Value of0,
  • Channel 5 will get a Value of 255,
  • Channel 6 will get a Value of0,
  • Channel 7 will get a Value of 255,
  • Channel 8 will get a Value of0,

Task 1: Do the Knight Rider by “knocking”. That means by the first knock the first Channel lights up, by
the second knock the second LED lights up and so on.

To be able to do this you have to change and add the cues in the array, and you also have to change the value when cue will be reset to 0 again, right now cue will be set to 0 when it becomes 6 (if (cue == 6) { cue = 0;})

Task 2: Do the Knight Rider with fading LED’s.



---

A simple fade in and out very similar to example 2, but adapted to Arduino 008.

There are some more code examples available at tinker.it

Share