You may want to read the previous post on this topic before starting this post. Last time I connected a single WS2801 controlled RGB LED to an Arduino. This time I will connect two. I know it is not rocket science, but one small step at a time.
The two LEDs are connected in series as shown below. The power rails run through. The serial in on one comes out the other side on serial out. This is then passed to the serial in on the second LED. Likewise for the clock.
You will need the Adafruit WS2801 library from Github. The code is fairly simple (see below). It shows red for 1 second on LED 1 whilst showing green on LED 2, then green on LED 1 and Blue on LED 2 and so on.
#include <Adafruit_WS2801.h>
#include <Wire.h>
#include "SPI.h"
int dataPin = 2; // Yellow wire on Adafruit Pixels
int clockPin = 3; // Green wire on Adafruit Pixels
//Note the first parameter defines the number of LEDs that are connected in series
Adafruit_WS2801 strip = Adafruit_WS2801(2, dataPin, clockPin);
void setup() {
strip.begin();
// Update LED contents, to start they are all 'off'
strip.show();
}
void loop() {
strip.setPixelColor(0,Color(255,0,0)); //Set color for LED 1 to Red
strip.setPixelColor(1,Color(0,255,0)); //Set color for LED 2 to Green
strip.show(); //Update LEDs to show the color
delay(1000);
strip.setPixelColor(0,Color(0,255,0)); //Set color for LED 1 to Green
strip.setPixelColor(1,Color(0,0,255)); //Set color for LED 2 to Blue
strip.show(); //Update LEDs to show the color
delay(1000);
strip.setPixelColor(0,Color(0,0,255)); //Set color for LED 1 to Blue
strip.setPixelColor(1,Color(255,0,0)); //Set color for LED 2 to Red
strip.show(); //Update LEDs to show the color
delay(1000);
}
// Create a 24 bit color value from R,G,B
uint32_t Color(byte r, byte g, byte b)
{
uint32_t c;
c = r;
c <<= 8;
c |= g;
c <<= 8;
c |= b;
return c;
}
Code for the project is available on Github. So this is enough hardware to create the basic goggles for the mind machine which should create something like the Ganzfeld effect. So I need to read up on the Ganzfeld again before attempting to program it in and create a pair of goggles. Next post will switch back to the heart monitor and look at the TSL2561 light sensor.