[vc_row][vc_column width=”1/1″][vc_tour][vc_tab title=”Introduce” tab_id=”1394153453-1-97″][vc_column_text]
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.
[/vc_column_text][/vc_tab][vc_tab title=”Wiring Diagram” tab_id=”1394153453-2-26″][vc_column_text]
This module could directly plug into arduino,notice not let the
USB on arduino touch the bottom of module PCB.[/vc_column_text][/vc_tab][vc_tab title=”Demo code” tab_id=”1394211316776-2-6″][vc_column_text]
#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); }
[/vc_column_text][/vc_tab][vc_tab title=”Module command introduce” tab_id=”1394211317916-3-9″][vc_column_text]Module support four kinds of commands, the command format is [cmd] [x] [y] [z] [r] [g] [b] [rsv]
And the cmd is the command, x, y, z, represent the three axis coordinate values, r, g, b
represent the three color of red, blue, green value of corresponding coordinate , rsv is reserved char.
Command 0 * 01: set the whole light cubic into a certain color, x, y, z is in vain.
Command 0 * 02: set the demo mode, x represent mode, y, z is in vain, r, g, b, rsv represent cycle index.
Command 0* 03: set a certain point color, x, y, z represent three coordinate, r, g, b represent the channel of red blue green.
Command 0* 04: send the data from coordinate(0, 0, 0), x, y, z, r, g, b, rsv is in vain.
Following the sending data is the point color data.
[/vc_column_text][/vc_tab][vc_tab title=”Test result” tab_id=”1394211319269-4-7″][vc_column_text][/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]
Leave a Reply
You must be logged in to post a comment.