Created
March 27, 2013 13:29
-
-
Save rc1/5254142 to your computer and use it in GitHub Desktop.
Quick sketch to speed up the SK Pang Arduino DMX Shield serial in communication protocol.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <DmxSimple.h> | |
| // 57600 baud rate | |
| // unsigned char channel | unsigned char value | for 27 times then | read | | |
| // read | read | for 27 times then | unsigned char success | | |
| // 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. | |
| int maxChannels = 64; | |
| 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(2); | |
| DmxSimple.maxChannel(maxChannels); | |
| Serial.begin(115200); | |
| Serial.print('ready to go'); | |
| } | |
| void loop() { | |
| int c; | |
| int v; | |
| for (int i = 0; i < 27; ++i) { | |
| while(!Serial.available()); | |
| c = Serial.read(); | |
| while(!Serial.available()); | |
| v = Serial.read(); | |
| DmxSimple.write(c, v); | |
| } | |
| Serial.println(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment