8X8X8 RGB LED Cube Shield

From LinkSprite Playgound
Jump to: navigation, search

Introduction

8*8*8 RGB Led cube is one of the stunning RGB light cubic module designed by us,and poses the arduino compatible interface and use the SPI interface as the control interface. It has several color mode inside.

RGBLED shield 1.jpg

This shield is coming a kit as below, you need soldering the LEDs to a complete shield as the upper picture.

8x8x8 list.jpg

Features

  • Dimensions: 120×100×90mm
  • Net weight: 265g

Schematics

Usage

Below is a demo code to use 8*8*8 RGB Led cube with Arduino:

#include <SPI.h>
 
#define STATUS_PIN 9
#define CS_PIN 10
#define MOSI_PIN 12
#define MISO_PIN 11
#define SCK_PIN 13
 
void SetDefaultTask(char task,long repeatTime)
{
  bool DeviceStatus;
  unsigned short count;
 
  DeviceStatus = digitalRead(STATUS_PIN);
  digitalWrite(CS_PIN,LOW);
 
   SPI.transfer(2);
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(task);//X
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(0);//Y
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(0);//Z
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(repeatTime & 0xff);//R
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer((repeatTime>>8) & 0xff);//G
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer((repeatTime>>16) & 0xff);//B
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer((repeatTime>>24) & 0xff);//RSV
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   digitalWrite(CS_PIN,HIGH);
}
 
void SetLedCubeColor(long color)
{
  bool DeviceStatus;
  unsigned short count;
 
  DeviceStatus = digitalRead(STATUS_PIN);
  digitalWrite(CS_PIN,LOW);
 
   SPI.transfer(1);
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(0);//X
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(0);//Y
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(0);//Z
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(color & 0xff);//R
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer((color>>8) & 0xff);//G
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer((color>>16) & 0xff);//B
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer((color>>24) & 0xff);//RSV
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   digitalWrite(CS_PIN,HIGH);
}
 
void SetPonitColor(char x,char y,char z,long color)
{
  bool DeviceStatus;
  unsigned short count;
 
  DeviceStatus = digitalRead(STATUS_PIN);
  digitalWrite(CS_PIN,LOW);
 
   SPI.transfer(1);
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(x);//X
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(y);//Y
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(z);//Z
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(color & 0xff);//R
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer((color>>8) & 0xff);//G
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer((color>>16) & 0xff);//B
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer((color>>24) & 0xff);//RSV
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   digitalWrite(CS_PIN,HIGH);
}
 
void SendImageData(void)
{
  unsigned short tmpShort;
 
  bool DeviceStatus;
  unsigned short count;
 
  DeviceStatus = digitalRead(STATUS_PIN);
  digitalWrite(CS_PIN,LOW);
 
   SPI.transfer(4);
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(0);//X
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(0);//Y
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(0);//Z
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(0);//R
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(0);//G
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(0);//B
   while(digitalRead(STATUS_PIN) == DeviceStatus)
   DeviceStatus = !DeviceStatus;
   SPI.transfer(0);//RSV
   while(digitalRead(STATUS_PIN) == DeviceStatus)
 
  for(tmpShort =0;tmpShort < 512*3;tmpShort ++)
  {
    SPI.transfer((char)tmpShort);
    while(digitalRead(STATUS_PIN) == DeviceStatus)
    DeviceStatus = !DeviceStatus;
  }
  digitalWrite(CS_PIN,HIGH);
}
 
void setup() {
  // put your setup code here, to run once:
  pinMode(STATUS_PIN, INPUT); 
  pinMode(CS_PIN, OUTPUT); 
  pinMode(MOSI_PIN, OUTPUT); 
  pinMode(MISO_PIN, INPUT); 
  pinMode(SCK_PIN, OUTPUT); 
  digitalWrite(CS_PIN,HIGH);
  digitalWrite(STATUS_PIN,HIGH);
  digitalWrite(SCK_PIN,LOW);
 
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SPI_MODE1);
  SPI.setClockDivider(SPI_CLOCK_DIV16);
  SPI.begin();
  SetDefaultTask(0,15);
  SendImageData();
  delay(5000);
 
}
 
void loop() {
  // put your main code here, to run repeatedly:
  SetLedCubeColor(0x00ff0000);
  delay(5000);
  SetLedCubeColor(0x0000ff00);
  delay(5000);
  SetLedCubeColor(0x000000ff);
  delay(5000);
  SetDefaultTask(1,15);
  delay(10000);
  SetDefaultTask(2,15);
  delay(10000);
   SetDefaultTask(3,15);
  delay(10000);
}

8x8x8 with arduino.jpg

Resources