Hello, guys.
I have made LED cube with dimensions 5x5x5 with standart one color LEDs. I used 4 shift registers 74HC595 and transistor array ULN 2803 and I control cube from Arduino IDE. Yesterday I connected bluetooth module DS1302 and play with it. Ive managed to make voice controll from my Android phone and depends on words that I said, to change the functions (programs) that Arduino runs. Now Im heading to something more serious - I want to be able to program led cube from my phone and send data via bluetooth. But I can`t imagine how should I do this, cuz not every led is connected to different Arduino output, actually I used only 3 outputs. Basically I want to do like image editor, in real time or after the buttons is clicked it needs to send data to Arduino. Can you give me ideas or something to read on how should I do this ?
Thanks
Again no one ?
If you want to learn how to do it from your phone, you should first be able to do it with the Serial monitor. What are you currently using to display something on the cube? Could you post your code and an example picture or video?
int DATA = 11; //pin 14 on the 75HC595
int LATCH = 10; //pin 12 on the 75HC595
int SHIFT = 12; //pin 11 on the 75HC595
String voice;
int delayValue = 0;
int potPin = 1; //potenciometer number of pin
//How many of the shift registers - change this
#define number_of_74hc595s 4
//do not touch
#define numOfRegisterPins number_of_74hc595s * 8
boolean registers[numOfRegisterPins];
void setup(){
Serial.begin(9600);
pinMode(DATA, OUTPUT);
pinMode(LATCH, OUTPUT);
pinMode(SHIFT, OUTPUT);
}
//set all register pins to LOW
void clearRegisters(){
for(int i = numOfRegisterPins - 1; i >= 0; i--){
registers[i] = LOW;
}
}
//Only call AFTER all values are set how you would like (slow otherwise)
void writeRegisters(){
digitalWrite(LATCH, LOW);
for(int i = numOfRegisterPins - 1; i >= 0; i--){
digitalWrite(SHIFT, LOW);
int val = registers[i];
digitalWrite(DATA, val);
digitalWrite(SHIFT, HIGH);
}
digitalWrite(LATCH, HIGH);
}
//set an individual pin HIGH or LOW
void setRegisterPin(int index, int value){
registers[index] = value;
}
void oneByOne() {
clearRegisters();
setRegisterPin(4,HIGH);
for(int i=5; i<=29; i++) {
setRegisterPin(i,HIGH);
writeRegisters();
delay(60);
}
clearRegisters();
setRegisterPin(3,HIGH);
for(int i=5; i<=29; i++) {
setRegisterPin(i,HIGH);
writeRegisters();
delay(60);
}
clearRegisters();
setRegisterPin(2,HIGH);
for(int i=5; i<=29; i++) {
setRegisterPin(i,HIGH);
writeRegisters();
delay(60);
}
clearRegisters();
setRegisterPin(1,HIGH);
for(int i=5; i<=29; i++) {
setRegisterPin(i,HIGH);
writeRegisters();
delay(60);
}
clearRegisters();
setRegisterPin(0,HIGH);
for(int i=5; i<=29; i++) {
setRegisterPin(i,HIGH);
writeRegisters();
delay(60);
}
}
This is example of beggining of my program - only one function, because I have plenty of them and the code is very long.
When I used voice control I started the followin code with different dimensions ofc.
while (Serial.available())
{ //Check if there is an available byte to read
delay(10);
char c = Serial.read(); //Conduct a serial read
if (c == '#') {
break;
} //Exit the loop when the # is detected after the word
voice += c; //Shorthand for voice = voice + c
}
if (voice.length() > 0) {
Serial.println(voice);
if(voice == "*1") {
oneByOne();
}
else if(voice == "*all"){
All();
}
else if(voice == "*fireworks") {
fireWorks();
}
else if(voice == "*border") {
borderAll();
}
else if(voice == "*lines") {
runningLines();
}
else if(voice == "*up and down") {
upAndDown();
}
voice="";
}
Actually if sending can be done from PC (like web based app, or .NET based) and then the information could be send via bluetooth it will be good too. I need to find a way how to send bytes or even better char array, cuz later when I received information I`ll use this code :
/* for receiving char array and lights up led according to IT
char first[] = "100001110011";
for(int i=0; i<=12; i++) {
int value = first[i] - '0';
setRegisterPin(i,value);
writeRegisters();
delay(200);
}
*/
You can send a packet of bytes, like so: <0xAF, 0x34, 0xFF, 0x12, 0x99>. each one controls a column of LEDs. Yes you need the tags, <> or similar, just so it is easier for your code to split the data. You would need to send 5 of these, one for each 5x5 section, and once you have all of the data, you display it.
If you want, you can send all 25 byte together as one packet, you will just need a counter to keep track of when to split the data into there 5x5 parts.
You can also use a structure, to send the data but it is not easy for beginners to understand.
Thanks Ill find a way how to do this.Dont worry about understanding structure,arrays,classes, collection and so - Im pretty familiar with them, but I just dont know how to do the sending for Arduino.
Today I`ve succeed to write for example sentence in arduino IDE and then my cube will visualize it. Everything works absolutely perfect.