Where to go from here?

Ok, I’ve been going through this project for ages and ages, getting discouraged and stopping, then getting reinvigorated and starting again, but fearing going too far because I don’t know exactly what to do, and then stopping again. But here I am, ready to give it another shot.

Here we have an ATMEGa 328, along with all the connections I have to each pin (a minor schematic, if you will)


| | (future analogue input)
RGB1 (G)| | Button1
RGB1 (R)| | Button2
RGB1 (B)| | ButtonMain
RGB2 (G)| | Button3
RGB2 (R)| | Button5
5 volts regulated| | Ground
Ground| |
RGB2 (B)| | 5 Volts regulated
RGB3 (G)| |RGB5 (G)
RGB3 (R)| |RGB5 (R)
RGB3 (B)| |RGB5 (B)
RGB4 (G)| |Button4
RGB4 (R)| |RGB4 (B)

All the RGBS are commen negative, and all have a resistor running to ground. The buttons each have a resistor running to ground too. For power, I have two 3 volt batteries, then a switch, then the regulator (L7805), and then the lines go to either side of the chip.

With this setup, there is a total of 21 digital I/O, and in the future there will be 1 analogue input. I have bootloaded the Arduino environment onto the chip, set to use the internal clock of the Atmega 328. (using this http://arduino.cc/en/Tutorial/ArduinoToBreadboard).

I then reset the pins 9 and 10 to be used as digital I/O 20 and 21, (following this: http://arduino.cc/forum/index.php/topic,71572.0.html) and that seemed to work. But now the chip is acting a little funky.

So, that was the intro on what I’m working on. Right now I have inspiration to work on it again, but am worried of advancing and doing something wrong. HOWEVER. I believe that all the electronics are good, and that all my problems are chip-related/programming related. So, does the above board look correct? Would I be able to do what I want if I had that board made? I know the answer would be “Build it and find out”. I have been doing that, bit by bit. I have one board made, with 2 lights and 3 buttons (the main button and two corresponding buttons to the lights), and was testing programming with it. But the chip seems to be acting funky, and not responding to programming correctly (I can go into more details, but funky programming/chip behaviour is not my question right now. I will provide more details if you ask for them though.) Going through the board with a multimeter, I know that all the connections are correct, and should be working.

So do you think that it would be a good idea to go ahead and build 4 boards (or just one), and then worry about fixing the chip/programming bugs later? Or continue going step by step, making sure the programming and electronics work together.

Electrically it seems plausible. How about posting your code (use the # button above) and let's see if the funkyness can be worked out, or if maybe you just a better rhythm & soul section to go with it. You could use the internal pullup resistors for the buttons, skip the external resistors, press a button to connect to ground & read a low to take action.

I dont think its nessicarily the code thats buggy... Im pretty sure its the chips. I made the code work perfectly with 3 lights and 4 buttons on an arduino and breadboard, then I just copy pasted the code a few more times to make it work for 5 lights. So the code should be good.

However, I think there is a problem with the chips, and uploading code to them. I had 12 chips total to start with. 2-3 I buggered when I was learning how to bootload, then 1 worked, then all the rest didnt. I hadn't done anything to them, they were right out of the package.

But I've not been worrying about those for now, just working with the 1 that works. However, it seems to be not working right now... I was uploading practice code to see if my connections were good, and I just wanted the lights to flash red, green, blue when the button state was 0 (so they would flash right when it turned on, the buttons didnt have to be set up) and that worked (I noticed that something was wrong with pin 9, think I changed the settings for that wrong), and then as I've been adding more lights and the buttons to see if they will work, the code isn't updating. I set up the breadboard, get the chip plugged in, upload the program, the lights on the arduino flash, just like they usually do when uploading, and then it says "Done uploading". But no matter what I change in the code, the same lights just keep blinking.

Will post code in next post, too long for this one

Scratch that.... the code is too long :P says it exceeds 9500 characters. Any other way I can share it?

Either post across a couple messages, or put it on the internet where we can access it.

Goolge documents!

https://docs.google.com/document/d/1_EFfXhHB7esOJSqdEBiMjhRMoDN8MBGtL2ZDaHR4Z7o/edit?hl=en_US

Anyways, this is the bit Ive been messing with to test the lights as I solder them in:

if (buttonPushCountermain == 0) { allgreen(); delay(100); allgreenoff(); delay(100); allred(); delay(100); allredoff(); delay(100); allblue(); delay(100); allblueoff; delay(100);}

From the schematic you showed, there is no decoupling on the power lines. I use a 0.1 microfarad, and a 10 microfarad tantalum very near the power pins. Also you do not show the reset line being pulled up and decoupled. How are you resetting the device to program it? Also two 3 volt batteries (what type? can they supply adequate current?) gives 6 volts - only just enough to power your regulator. A long and thin power wire from the batteries to the regulator could be dropping more voltage than you expect. Is your 5V really at 5V, even with the LEDs on? An inadequate power supply would get more unreliable as you added more LEDS. Have you got the recommended decoupling capacitors on your regulator?

No capacitors on the power line.

As for programming, I program it on a seperate circuit (link in my first post) and then just transfer it over to the real circuit

Hi,

  1. You definitely need at least a 100nF capacitor between Vcc and ground, close to the mcu.

  2. Check that the voltage regulator you are using is a low-dropout regulator. If it is not, it will almost certainly need more than 6v in to provide 5v out.

  3. The voltage regulator may have additional requirements for capacitors between its input and ground and/or output and ground - see the datasheet for that regulator.

  4. Using a single resistor from the common cathode of each RGB LED to ground is fine if you only want to turn on one of the 3 leds in the package at a time. Otherwise, you should have separate resistors in series with each anode lead instead.

  5. I presume your buttons are connected between the pin and +5v. If you had them connected between the pin and ground instead, then you would not need any resistors for the buttons, because you could enable the internal pullup resistors in the mcu instead. Of course, they would then read LOW when pressed and HIGH when not pressed, instead of the other way round.