<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.diychristmas.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Arduino_and_pixels_V1</id>
	<title>Arduino and pixels V1 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.diychristmas.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Arduino_and_pixels_V1"/>
	<link rel="alternate" type="text/html" href="https://www.diychristmas.org/wiki/index.php?title=Arduino_and_pixels_V1&amp;action=history"/>
	<updated>2026-04-18T19:57:14Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.11</generator>
	<entry>
		<id>https://www.diychristmas.org/wiki/index.php?title=Arduino_and_pixels_V1&amp;diff=3175&amp;oldid=prev</id>
		<title>MikeKrebs: Created page with &quot;This is untested code. Awaiting feedback. Serial may not support this many pixels at 115200.  &lt;nowiki&gt; // Basic Vixen &quot;generic&quot; serial  //  - Setup a generic serial controller...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.diychristmas.org/wiki/index.php?title=Arduino_and_pixels_V1&amp;diff=3175&amp;oldid=prev"/>
		<updated>2020-10-19T03:00:49Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;This is untested code. Awaiting feedback. Serial may not support this many pixels at 115200.  &amp;lt;nowiki&amp;gt; // Basic Vixen &amp;quot;generic&amp;quot; serial  //  - Setup a generic serial controller...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is untested code. Awaiting feedback. Serial may not support this many pixels at 115200.&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
// Basic Vixen &amp;quot;generic&amp;quot; serial &lt;br /&gt;
//  - Setup a generic serial controller to use this sketch&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;FastLED.h&amp;gt; //include the FastLED library in the Arduino project&lt;br /&gt;
#define LED_PIN1 2 //for first arc strip of 100 LEDs, pin 2 on the MEGA&lt;br /&gt;
#define LED_PIN2 3 //for second arc strip of 100 LEDs, pin 3 on the MEGA&lt;br /&gt;
#define LED_PIN3 4 //for third arc strip of 100 LEDs, pin 4 on the MEGA&lt;br /&gt;
#define LED_PIN4 5 //for fourth arc strip of 100 LEDs, pin 5 on the MEGA&lt;br /&gt;
#define LED_PIN5 6 //for fifth arc strip of 100 LEDs, pin 6 on the MEGA&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Vixen information&lt;br /&gt;
// speed for the com port for talking with player&lt;br /&gt;
const long BAUD_RATE = 115200L;&lt;br /&gt;
#define NUM_LEDS 100&lt;br /&gt;
// Generic Serial controller config - must be present, must match controller setup&lt;br /&gt;
const int CONTROLLER_HEADER[3] = {33, 34, 35}; // This is character !&amp;quot;# (hard to replicate in sequencer)&lt;br /&gt;
&lt;br /&gt;
#define GRB_ORDER GRB //pixel strips is set to use GRB color codes&lt;br /&gt;
&lt;br /&gt;
// these are program variables we need to use in multiple places&lt;br /&gt;
const int SIZE_OF_HEADER = sizeof(CONTROLLER_HEADER) / sizeof(int); // no need to change&lt;br /&gt;
&lt;br /&gt;
#define LED_TYPE WS2811 //type of LED&lt;br /&gt;
&lt;br /&gt;
//create arrays to hold the FastLED CRBG code for each of the 50 pixels in the:&lt;br /&gt;
CRGB leds1[NUM_LEDS]; //first arc.&lt;br /&gt;
CRGB leds2[NUM_LEDS]; //second arc.&lt;br /&gt;
CRGB leds3[NUM_LEDS]; //third arc.&lt;br /&gt;
CRGB leds4[NUM_LEDS]; //fourth arc.&lt;br /&gt;
CRGB leds5[NUM_LEDS]; //fifth arc.&lt;br /&gt;
&lt;br /&gt;
int g; //a variable for loop section&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  delay(1000);&lt;br /&gt;
  Serial.begin(BAUD_RATE);&lt;br /&gt;
  pinMode(LED_PIN1, OUTPUT); //set pins to output. PIN1 is pin 2 on the Arduino board.&lt;br /&gt;
  pinMode(LED_PIN2, OUTPUT);&lt;br /&gt;
  pinMode(LED_PIN3, OUTPUT);&lt;br /&gt;
  pinMode(LED_PIN4, OUTPUT);&lt;br /&gt;
  pinMode(LED_PIN5, OUTPUT);&lt;br /&gt;
&lt;br /&gt;
  ////Set up the pixel strips to run using FastLED&lt;br /&gt;
  FastLED.addLeds&amp;lt;LED_TYPE, LED_PIN1, GRB_ORDER&amp;gt;(leds1, NUM_LEDS).setCorrection(TypicalLEDStrip); //for the first arc&lt;br /&gt;
  FastLED.addLeds&amp;lt;LED_TYPE, LED_PIN2, GRB_ORDER&amp;gt;(leds2, NUM_LEDS).setCorrection(TypicalLEDStrip); //for the second arc&lt;br /&gt;
  FastLED.addLeds&amp;lt;LED_TYPE, LED_PIN3, GRB_ORDER&amp;gt;(leds3, NUM_LEDS).setCorrection(TypicalLEDStrip); //for the third arc&lt;br /&gt;
  FastLED.addLeds&amp;lt;LED_TYPE, LED_PIN4, GRB_ORDER&amp;gt;(leds4, NUM_LEDS).setCorrection(TypicalLEDStrip); //for the fourth arc&lt;br /&gt;
  FastLED.addLeds&amp;lt;LED_TYPE, LED_PIN5, GRB_ORDER&amp;gt;(leds5, NUM_LEDS).setCorrection(TypicalLEDStrip); //for the fifth arc&lt;br /&gt;
  powerOnSelfTest(); // watch your lights to make sure they are all going on in order&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
  if (Serial.available() &amp;gt; 0) {&lt;br /&gt;
    waitForControllerHeader(CONTROLLER_HEADER);&lt;br /&gt;
    readSequenceData();&lt;br /&gt;
    FastLED.show(); //then we tell FastLED to show the pixels!&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void readSequenceData()&lt;br /&gt;
{&lt;br /&gt;
  // We assume that since we found the header, we can just read the rest of the bytes&lt;br /&gt;
  for (g = 0; g &amp;lt; NUM_LEDS; g++) {&lt;br /&gt;
    Serial.readBytes( ( char*)(&amp;amp;leds1[g]), 3);&lt;br /&gt;
  }&lt;br /&gt;
  for (g = 0; g &amp;lt; NUM_LEDS; g++) {    //then we read the next 300 bytes for the second arc of LEDs&lt;br /&gt;
    Serial.readBytes( ( char*)(&amp;amp;leds2[g]), 3);&lt;br /&gt;
  }&lt;br /&gt;
  for (g = 0; g &amp;lt; NUM_LEDS; g++) {    //then we read the next 300 bytes for the third arc of LEDs&lt;br /&gt;
    Serial.readBytes( ( char*)(&amp;amp;leds3[g]), 3);&lt;br /&gt;
  }&lt;br /&gt;
  for (g = 0; g &amp;lt; NUM_LEDS; g++) {    //then we read the next 300 bytes for the fourth arc of LEDs&lt;br /&gt;
    Serial.readBytes( ( char*)(&amp;amp;leds4[g]), 3);&lt;br /&gt;
  }&lt;br /&gt;
  for (g = 0; g &amp;lt; NUM_LEDS; g++) {    //then we read the next 300 bytes for the fifth arc of LEDs&lt;br /&gt;
    Serial.readBytes( ( char*)(&amp;amp;leds5[g]), 3);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void waitForControllerHeader(int header[])&lt;br /&gt;
{&lt;br /&gt;
  for (int i = 0; i &amp;lt; SIZE_OF_HEADER; i++) {&lt;br /&gt;
    // wait for serial available&lt;br /&gt;
    while (!Serial.available()) {}&lt;br /&gt;
    // Check the byte until it matches the CONTROLLER_HEADER byte&lt;br /&gt;
    int inByte = Serial.read();&lt;br /&gt;
    if (inByte != CONTROLLER_HEADER[i]) {&lt;br /&gt;
      i = -1; // wrong data set to &amp;quot;zero&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // found the header!&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// powerOnSelfTest - does a couple of checks to make sure everything turns on and off&lt;br /&gt;
//  - watch your lights, they should go on in order&lt;br /&gt;
void powerOnSelfTest()&lt;br /&gt;
{&lt;br /&gt;
  // Let&amp;#039;s test if all the pixels work.&lt;br /&gt;
  // This will be too fast for real discernment but they should all be on at end of this&lt;br /&gt;
  FastLED.clear();&lt;br /&gt;
  for (int channelIndex = 0; channelIndex &amp;lt; NUM_LEDS; channelIndex++) {&lt;br /&gt;
    leds1[channelIndex] = CRGB::Red;&lt;br /&gt;
    FastLED.show();&lt;br /&gt;
  }&lt;br /&gt;
  delay(500);&lt;br /&gt;
  for (int channelIndex = 0; channelIndex &amp;lt; NUM_LEDS; channelIndex++) {&lt;br /&gt;
    leds2[channelIndex] = CRGB::Red;&lt;br /&gt;
    FastLED.show();&lt;br /&gt;
  }&lt;br /&gt;
  delay(500);&lt;br /&gt;
  for (int channelIndex = 0; channelIndex &amp;lt; NUM_LEDS; channelIndex++) {&lt;br /&gt;
    leds3[channelIndex] = CRGB::Red;&lt;br /&gt;
    FastLED.show();&lt;br /&gt;
  }&lt;br /&gt;
  delay(500);&lt;br /&gt;
  for (int channelIndex = 0; channelIndex &amp;lt; NUM_LEDS; channelIndex++) {&lt;br /&gt;
    leds4[channelIndex] = CRGB::Red;&lt;br /&gt;
    FastLED.show();&lt;br /&gt;
  }&lt;br /&gt;
  delay(500);&lt;br /&gt;
  for (int channelIndex = 0; channelIndex &amp;lt; NUM_LEDS; channelIndex++) {&lt;br /&gt;
    leds5[channelIndex] = CRGB::Red;&lt;br /&gt;
    FastLED.show();&lt;br /&gt;
  }&lt;br /&gt;
  delay(2000); // slight pause to check all on&lt;br /&gt;
  FastLED.clear();&lt;br /&gt;
  FastLED.show();&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>MikeKrebs</name></author>
	</entry>
</feed>