Created
November 21, 2024 19:00
-
-
Save jedgarpark/fa09a0e18a625bd332e5fa55139bbd45 to your computer and use it in GitHub Desktop.
DMX_receive_neopixel.ino
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 <Conceptinetics.h> | |
#include <Adafruit_NeoPixel.h> | |
#define PIN 12 | |
#define NUMPIXELS 16 | |
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); | |
// | |
// The slave device will use a block of 10 channels counting from | |
// its start address. | |
// | |
// If the start address is for example 56, then the channels kept | |
// by the dmx_slave object is channel 56-66 | |
// | |
#define DMX_SLAVE_CHANNELS 10 | |
// | |
// Pin number to change read or write mode on the shield | |
// Uncomment the following line if you choose to control | |
// read and write via a pin | |
// | |
// On the CTC-DRA-13-1 shield this will always be pin 2, | |
// if you are using other shields you should look it up | |
// yourself | |
// | |
///// #define RXEN_PIN 2 | |
// Configure a DMX slave controller | |
DMX_Slave dmx_slave ( DMX_SLAVE_CHANNELS ); | |
// If you are using an IO pin to control the shields RXEN | |
// the use the following line instead | |
///// DMX_Slave dmx_slave ( DMX_SLAVE_CHANNELS , RXEN_PIN ); | |
const int ledPin = 13; | |
// the setup routine runs once when you press reset: | |
void setup() { | |
// Enable DMX slave interface and start recording | |
// DMX data | |
dmx_slave.enable (); | |
// Set start address to 1, this is also the default setting | |
// You can change this address at any time during the program | |
dmx_slave.setStartAddress (1); | |
// Set led pin as output pin | |
pinMode ( ledPin, OUTPUT ); | |
pixels.begin(); | |
pixels.fill(150,0,0); | |
pixels.show(); | |
delay(500); | |
// pixels.clear(); | |
} | |
// the loop routine runs over and over again forever: | |
void loop() | |
{ | |
// | |
// EXAMPLE DESCRIPTION | |
// | |
// If the first channel comes above 50% the led will switch on | |
// and below 50% the led will be turned off | |
// NOTE: | |
// getChannelValue is relative to the configured startaddress | |
if ( dmx_slave.getChannelValue (1) > 127 ) { | |
digitalWrite ( ledPin, HIGH ); | |
pixels.fill(0, 150, 0); | |
pixels.show(); | |
delay(100); | |
} | |
else { | |
digitalWrite ( ledPin, LOW ); | |
pixels.fill(0,0,150); | |
pixels.show(); | |
delay(100); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment