JCook
New member
Code:// Wemos D1 Mini E1.31 - 6 channel dumb RGB led sketch. #include <ESP8266WiFi.h> #include <E131.h> // Copyright (c) 2015 Shelby Merrick http://www.forkineye.com // ***** USER SETUP STUFF ***** const char ssid[] = "<YOUR_SSID>"; // replace with your SSID. const char passphrase[] = "<YOUR_PASSWORD>"; // replace with your PASSWORD. const int universe = 1; // this sets the universe number you are using. // this sets the channel number used by the output. const int channel_1_red = 1; // the channel number to link to output 1 red. const int channel_1_green = 2; // the channel number to link to output 1 green. const int channel_1_blue = 3; // the channel number to link to output 1 blue. const int channel_2_red = 4; // the channel number to link to output 2 red. const int channel_2_green = 5; // the channel number to link to output 2 green. const int channel_2_blue = 6; // the channel number to link to output 2 blue. // this sets the pin numbers to use as outputs. const int output_1_red = 4; // the pin to use as output 1 red (D2). const int output_1_green = 5; // the pin to use as output 1 green (D1). const int output_1_blue = 12; // the pin to use as output 1 blue (D6). const int output_2_red = 13; // the pin to use as output 1 red (D7). const int output_2_green = 14; // the pin to use as output 1 green (D5). const int output_2_blue = 15; // the pin to use as output 1 blue (D8). E131 e131; void setup() { Serial.begin(115200); // set the pins chosen above as outputs. pinMode(output_1_red, OUTPUT); pinMode(output_1_green, OUTPUT); pinMode(output_1_blue, OUTPUT); pinMode(output_2_red, OUTPUT); pinMode(output_2_green, OUTPUT); pinMode(output_2_blue, OUTPUT); // set the pins chosen above to low / off. analogWrite(output_1_red, 0); analogWrite(output_1_green, 0); analogWrite(output_1_blue, 0); analogWrite(output_2_red, 0); analogWrite(output_2_green, 0); analogWrite(output_2_blue, 0); /* Choose one to begin listening for E1.31 data */ //e131.begin(ssid, passphrase); /* via Unicast on the default port */ e131.beginMulticast(ssid, passphrase, universe); /* via Multicast for Universe 1 */ } void loop() { /* Parse a packet */ uint16_t num_channels = e131.parsePacket(); /* Process channel data if we have it */ if (num_channels) { Serial.println("we have data"); Serial.println(e131.data[channel_1_red -1]); Serial.println(e131.data[channel_1_green -1]); Serial.println(e131.data[channel_1_blue -1]); Serial.println(e131.data[channel_2_red -1]); Serial.println(e131.data[channel_2_green -1]); Serial.println(e131.data[channel_2_blue -1]); // set the outputs to the data value. analogWrite(output_1_red, e131.data[channel_1_red -1] ); analogWrite(output_1_green, e131.data[channel_1_green -1] ); analogWrite(output_1_blue, e131.data[channel_1_blue -1] ); analogWrite(output_2_red, e131.data[channel_2_red -1] ); analogWrite(output_2_green, e131.data[channel_2_green -1] ); analogWrite(output_2_blue, e131.data[channel_2_blue -1] ); } }
Barnabybear, thanks for pointing me to this post.
Looks like I could just change the setup of the outputs ti like this
Code:
// The EL channels are on pins 2 through 9
// Initialize the pins as outputs
pinMode(2, OUTPUT); // channel A
pinMode(3, OUTPUT); // channel B
pinMode(4, OUTPUT); // channel C
pinMode(5, OUTPUT); // channel D
pinMode(6, OUTPUT); // channel E
pinMode(7, OUTPUT); // channel F
pinMode(8, OUTPUT); // channel G
pinMode(9, OUTPUT); // channel H
and instead of
analogWrite(output_1_red, e131.data[channel_1_red -1] );
i would just use
where "x" is the pin number of the sparkfun shield.digitalWrite(x, HIGH); // turn the EL channel on