Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Shift Register Library on: January 09, 2013, 08:13:56 pm
Hi Nick

I went to your site and seen some of the code for the shift registers, and thought you might be able to help me.

What is SPI in your code.

I built a 4x4x4 led cube and am trying to creat a code to test each one of the leds from an X,Y,Z access.
Then eventually randomize the pattern.

If you want I could send the code I found and converted.

Sparkie
2  Using Arduino / LEDs and Multiplexing / Re: xmas light driver, not sure what i did wrong on: January 06, 2013, 05:14:50 pm
Hi mrgizmo
Seems that you need to ground the inputs. As your anodes are connected to +5v.
if you are going to use an Arduino you could try the blinkie sketch on one input to see if it works.
But remember you have to sink the inputs, or ground.

Hope this helps.
Sparkie
3  Using Arduino / LEDs and Multiplexing / Re: LED cube,shift registers and fun. on: January 06, 2013, 04:06:28 pm
Hi Tom

The message you speak of is one I tol ok from the internet. the explanation was quite extensive so I didn't get it all in my cut and past ;-)

The more I look at all the codes, the more my head spins. I think it'll take some time before I really catch on.
I bought a book on C++ How To Program by Deitel & Deitel and I'm reading it from the start.

Do I understand the the program has a header and a body??
And how long is the body of the program, or is it everything after the header??

Thanks again for your input.
Sparkie
4  Using Arduino / LEDs and Multiplexing / Re: LED cube,shift registers and fun. on: January 06, 2013, 11:08:11 am
Hi Hippynerd

I found what I think is an answer to your reply #42

It explanes about that for statement:
for(int i=0; i<256; i++)

Aparently it sets up a chunk of memory in the stacks or heap...



http://www.societyofrobots.com/member_tutorials/book/export/html/202


Some microcontroller compilers do allow you to dynamically allocate memory – but with this one enormous proviso:- The memory is automatically freed when the method that allocated it in the first place exits. How does that work? Well its then very similar to the stack. It will just use the heap pointer to allocate new memory and then move it back to its original position when the method exits. Therefore: you can never have any fragmentation in the heap. However: its usage is fairly limited.

<!--[if !supportEmptyParas]--> <!--[endif]-->
 
Consider this code:-
 
--------------------------------------------------------------------------------

void myMethod(){
 
    char buffer[256];
 
    for(int I=0; I<256;I++){
 
            buffer=I;
 
    }
 
}
 
--------------------------------------------------------------------------------

This will allocate space for ‘buffer’ by moving the stack pointer down by 256 bytes.
 
<!--[if !supportEmptyParas]--> <!--[endif]-->
 
Whereas this code:-
 
<!--[if !supportEmptyParas]-->
 
--------------------------------------------------------------------------------

void myMethod(){
 
   char buffer* = malloc(256);
 
    for(int I=0; I<256;I++){
 
            buffer->=I;
 
    }
 
}
 
--------------------------------------------------------------------------------

will allocate space for ‘buffer’ by moving the heap pointer up by 256 bytes. So they are almost identical.

<!--[if !supportEmptyParas]--> <!--[endif]-->
 
But you must be careful not to do the following:-
 
--------------------------------------------------------------------------------

char buffer*;
 
void myMethod(){
 
   buffer = malloc(256);
 
    for(int I=0; I<256;I++){
 
            buffer->=I;
 
    }
 
}
 
--------------------------------------------------------------------------------

since ‘buffer’ is assigned a value in the method – but, unlike a ‘proper’ C compiler - once the method exits then ‘buffer’ is referring to a lump of memory that is now being used by other things. So changing some of its values will corrupt something else. Bad!
 
<!--[if !supportEmptyParas]--> <!--[endif]-->
 
So dynamic memory allocation should generally be avoided and we will not discuss it any further!!
 
<!--[if !supportEmptyParas]--> <!--[endif]-->
5  Using Arduino / LEDs and Multiplexing / Re: 4x4x4 LED cube build on: January 04, 2013, 06:48:46 pm
Hi Turtlesoup

Go to the Thread Hippyneard spoke about. at the bottom is the schematic and code for the 4x4x4 cube I built

Look in this other thread about 4x4x4 cubes, This post has a real nice circuit for running the cube. Its a more proper design.
http://arduino.cc/forum/index.php/topic,123495.msg1052188.html#msg1052188

6  Using Arduino / LEDs and Multiplexing / Re: LED cube,shift registers and fun. on: January 03, 2013, 06:16:16 am
Good Morning Tom

What you said makes sence to me. The code I offered in this Fourm was taken from someone elses code. I'd have to check my files to find out who, but I don't think it's important in this case. Oh I found the website:

http://oomlout.com/a/products/ardx/circ-05/
Check out the site and copy the code to study.

The code I got, I changed a few lines to make the 74hc595 turn on the four (4) transistors needed for this 4x4x4 Cube.

Have you look at the code??
Everyones input will be helpfull to me for a better understanding of C and C++.

I'm hoping to use Hippynerds Data to set different patterns, but havent got that far yet. I just keep reading my and others code to see whats been done, Program wise, for the Cube.

As mentioned before, I only have progremmed in Basic many many years ago, and didn't have a need to learn C or C++ until I bought an Arduino Uno two years ago.

But again Tom, Thanks for your input and hope to hear from you again.
7  Using Arduino / LEDs and Multiplexing / Re: LED cube,shift registers and fun. on: January 02, 2013, 03:55:53 pm
Im not sure eather.
it may be different in C++
for(int i = 0; i < 256; i++){
I think it is saying that the int=0 and that i is less than 256 and then adds 1????
At least thats how I see it, if it had a <<256 it would mean to shift left 256 bits, which wouldn't make sence.
I think the line you are refering to is:

void loop()   //runs over and over again
{

int delayTime = 100; //the number of milliseconds delay between led updates
for(int i = 0; i < 256; i++){
updateLEDs (i);
delay (delayTime);
 }
}
I think it is saying that the int i is the place holder for ledState, the integer ledState waits for the update
from the line you mentioned....I Think....???
it took me a while to read it over and over again to semiunderstand it.

But you say it works on your 74hc595 setup??

let me know.

TTFN
Sparkie
8  Using Arduino / LEDs and Multiplexing / Re: LED cube,shift registers and fun. on: January 02, 2013, 08:44:24 am
Hi Again

Have you had a chance to look at my code??
I have some questions i'd like to ask.

TTFN
Sparkie

FYI
Sparkie comes from my days as a radio operator in the Army. We were called sparks back then.
9  Using Arduino / LEDs and Multiplexing / Re: LED cube,shift registers and fun. on: January 01, 2013, 03:41:04 pm

Hi Again Hippynerd

Seen your Instructable..Not Bad..
If I master the 4x4x4 cube I might try the 8x8x8 RGB Cube Next.

this is where I got the original code from

http://oomlout.com/a/products/ardx/circ-05/
I found this site helpful with some of the layouts for testing the LED's using the 74hc595 shift reg.

After I made the cube and mounted the components, I tested each LED by putting 5v to the base resister and one of the IC socket pins (1-7 and pin 15). this was done before the IC's were plugged in. Bread boarding the LED's and the 74hc595 first, and using a program that took input from the keyboard numbers 1-8, I could press the #1 key and the #1 LED would Light.
From there I used the perfaboard to mount the components with Point to Point wireing. The next board I will etch and put the Arduino Chip on board or use a Pic.

So you used to own a Commie 64 Eh..kinda shows your age ;-) I think my first kit computer was the Timax St Clair with 1k of memmory and a bubble keyboard.

Hope this post helps someone
TTFN
Sparkie
10  Using Arduino / LEDs and Multiplexing / Re: LED cube,shift registers and fun. on: January 01, 2013, 09:58:33 am

Hippynerd

Pin 10 on the 74hc595 is the master reset, and needs to be active Low.
Also if you notice on the schemo, on the bottom left is the pinout for the IC's Power Pins 8(GND) and 16(VCC) and has Two .1uF caps needed for both IC's.
As I stated before, I powered VCC with an external 5V Power Supply, + to VCC, and - to Ground and also Ground to the Arduino as well for signal return.
By Offboard powering, the Led's are Brighter, and I don't pull too much from the Arduino.

I also have about a thousand Questions about C++ programming, but I have to settle for a few for now.
(1)
How would I set up a data file of different patterens, and make the program point to it.
(2)
How would I set it to Randomly make it's own patterns?

I'm Attaching the Datasheet for the 74hc595 for viewing

Thanks
11  Using Arduino / LEDs and Multiplexing / Re: LED cube,shift registers and fun. on: January 01, 2013, 07:33:51 am
Happy New Year to all

Hi Hippynerd

Thank You for your reply.
I found that schematic somewhere on the internet, just can't remember where though.
I built that circuit on a perfiboard with point to point wiring. The Arduino Uno is off board for now as I not sure weather I want to use the Arduino Atmel328 or use a PIC chip. I have room on the board for one or the other, but I'll have to do more research.
Being a NUBE in C++ programming it's a problem understanding what I'm doing.
I've done some Basic programming back in the Vic20 days, but haven't done anything in C or C++.
As for the Program I'm using Now, (Which I Attached in my last message) I found it again somewhere on the internet. It didn't have any way of controlling the Columns, so I added the four lines to bring the Transisters High to Sink the Columns.
Looking at the schematic, notice on the top left are two sets of input pins that get the signals from the offboard Arduino Uno. I had trouble setting the pins, forgetting that the pins are labled 0-7 on the Arduino, but on the schematic, they are marked 1-7, I had put the Data-Clock and Latch in the wrong Place.
I'm Going to try to upload the code in this message....HOPE IT Works...;-)
And Hope You and others can guide me with C++.
Thanks.
Code:
/*    Arduino Experimentation Kit Example Code             |
 *    CIRC-05 .: 8 More LEDs :. (74HC595 Shift Register)   |
 *    We have already controlled 8 LEDs however this does it in a slightly
 *    different manner. Rather than using 8 pins we will use just three
 *    and an additional chip.
 */
// This is My Version of the Pin Connections
//Pin Definitions
//The 74HC595 uses a serial communication
//link which has three pins Data-Clock and Latch
// Pins 5-6-7-8 are the Columns
int data = 2;
int clock = 3;
int latch = 4;

int Col1 = 5; // Transistor1 Base
int Col2 = 6; // Transistor2 Base
int Col3 = 7; // Transistor3 Base
int Col4 = 8; // Transistor4 Base

//Used for single LED manipulation
int ledState = 0;
const int ON = HIGH;
const int OFF = LOW;
             
/*setup() - this function runs once when you turn your Arduino on
 * We set the three control pins to outputs
 */
void setup()
{
  pinMode(data, OUTPUT);
  pinMode(clock, OUTPUT); 
  pinMode(latch, OUTPUT); 
 
  pinMode(Col1, OUTPUT);
  pinMode(Col2, OUTPUT);
  pinMode(Col3, OUTPUT);
  pinMode(Col4, OUTPUT);
 
}
/*
 * loop() - this function will start after setup finishes and then repeat
 * we set which LEDs we want on then call a routine which sends the states to the

74HC595
 */
void loop()                     // run over and over again
{
  int delayTime = 100; //the number of milliseconds to delay between LED updates
  for(int i = 0; i < 256; i++){
   updateLEDs(i);
   delay(delayTime);
  }
}

/*
 * updateLEDs() - sends the LED states set in ledStates to the 74HC595
 * sequence
 */
void updateLEDs(int value){
  digitalWrite(latch, LOW);     //Pulls the chips latch low
  shiftOut(data, clock, MSBFIRST, value); //Shifts out the 8 bits to the shift

register
  digitalWrite(latch, HIGH);   //Pulls the latch high displaying the data
 
  digitalWrite(Col1, HIGH);   //Pulls the Col1 high and turn on transistor-1
  digitalWrite(Col2, HIGH);   //Pulls the Col1 high and turn on transistor-2
  digitalWrite(Col3, HIGH);   //Pulls the Col1 high and turn on transistor-3
  digitalWrite(Col4, HIGH);   //Pulls the Col1 high and turn on transistor-4
}

/* updateLEDsLong() - sends the LED states set in ledStates to the 74HC595
 * sequence. Same as updateLEDs except the shifting out is done in software
 * so you can see what is happening.
 */
void updateLEDsLong(int value){
  digitalWrite(latch, LOW);    //Pulls the chips latch low
  for(int i = 0; i < 8; i++){  //Will repeat 8 times (once for each bit)
  int bit = value & B10000000; //We use a "bitmask" to select only the eighth
                               //bit in our number (the one we are addressing this

time through
  value = value << 1;          //we move our number up one bit value so next time

bit 7 will be
                               //bit 8 and we will do our math on it
  if(bit == 128){digitalWrite(data, HIGH);} //if bit 8 is set then set our data

pin high
  else{digitalWrite(data, LOW);}            //if bit 8 is unset then set the data

pin low
  digitalWrite(clock, HIGH);                //the next three lines pulse the clock

pin
  delay(1);
  digitalWrite(clock, LOW);
  }
  digitalWrite(latch, HIGH);  //pulls the latch high shifting our data into being

displayed
}
//These are used in the bitwise math that we use to change individual LEDs
//For more details http://en.wikipedia.org/wiki/Bitwise_operation
int bits[] = {B00000001, B00000010, B00000100, B00001000, B00010000, B00100000,

B01000000, B10000000};
int masks[] = {B11111110, B11111101, B11111011, B11110111, B11101111, B11011111,

B10111111, B01111111};
/*
 * changeLED(int led, int state) - changes an individual LED
 * LEDs are 0 to 7 and state is either 0 - OFF or 1 - ON
 */
 void changeLED(int led, int state){
   ledState = ledState & masks[led];  //clears ledState of the bit we are

addressing
   if(state == ON){ledState = ledState | bits[led];} //if the bit is on we will

add it to ledState
   updateLEDs(ledState);              //send the new LED state to the shift

register
 }
12  Using Arduino / LEDs and Multiplexing / Re: LED cube,shift registers and fun. on: December 31, 2012, 07:30:00 pm
Seasons Greeting All

Sparkie4080 Here
New to this fourm.
Hi Hippynerd
Spotted your comments on the 4x4x4 led cube, and was glad to follow your code input, just what I was looking for.
I am hopefully attaching my schematic and code for my 4x4x4 led cube. I built mine on a 4.25x6.5 purfaboard and point to point wiring. the cube works well with the off board uno, but brighter with a 5Volt 2Amp wall wort.
I had a bit of trouble finding a working code for this unit. the one I found didn't have the collum part so I added it as:
int data=2; //pin 2 on the arduino board
int data=3; //pin 3 on the arduino board
int data=4; //pin 4 on the arduino board
int Col1=5; //pin 5 on the arduino board
int Col2=6; //pin 6 on the arduino board
int Col2=7; //pin 7 on the arduino board
int Col2=8; //pin 8 on the arduino board

Im going to try your code and see if it works on my cube.

Let me know if the attached files made it
Thanks
Sparkie4080
13  Community / Local Groups / Re: Arduinoids in Ontario Canada on: May 03, 2011, 10:47:54 pm
Greetings All

I guess I'm an Old Newbee.
Just bought my first Arduino Uno last week, and I hope to get it up and running as soon as I plow through The ton of info i've read so far.
I've been a computer nut since the Timex Sinclair and Commodore Pet. The only programming I did back then was a bit of machine language and Basic. I never thought I'd have the need to learn about other languages, so I never bothered.
Now it looks like I have to get my head into C and C++ to program the Arduino.

Hopefully with the help from you guys.

TTFN
Hope to chat with you all later.

sparkie4080
Pages: [1]