Hi guys, this is my first time posting on this forum, and it's about my first arduino project. I made an LED sign with seven letters. The LEDs on each letter are wired in parallel and powered by some transistors, which in term are activated by the arduino. Simple stuff even for a newbie like me.
Everything worked out just as expected when I used the Arduino board. However, when I took the chip out of the board and attempted to use it by itself, it wouldn't run all the code. The original code featured several flashing patterns for the leds.
I had the exact same code on the arduino board and it worked just fine, but when using the atmega328 by itself, it would just loop through the first part of the code over and over, without even starting to run the other flashing patterns and would eventually (after an indefinite number of loops) freeze leaving the last letter on HIGH (right at the end of the code). I eventually dumped the rest of the code and stuck to the first part, thinking it would do for now, but still it freezes at the end after a while.
Just a couple of extra details:
I powered the chip with +5 volts on pin 7, ground on pin 8, 16MHZ crystal between pins 9 and 10, and then used pins 6 to 13 to power the transistors.
I did not put 20 pf capacitors between crystal pins and ground.
Code below:
void setup() {
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(6, HIGH);
delay(200);
digitalWrite(7, HIGH);
delay(200);
digitalWrite(8, HIGH);
delay(200);
digitalWrite(9, HIGH);
delay(200);
digitalWrite(10, HIGH);
delay(200);
digitalWrite(11, HIGH);
delay(200);
digitalWrite(12, HIGH);
delay(200);
digitalWrite(6, LOW);
delay(200);
digitalWrite(7, LOW);
delay(200);
digitalWrite(8, LOW);
delay(200);
digitalWrite(9, LOW);
delay(200);
digitalWrite(10, LOW);
delay(200);
digitalWrite(11, LOW);
delay(200);
digitalWrite(12, LOW);
delay(200);
}
What do you think? What could be causing such a weird behaviour of the atmega328? I know it's probably something basic, but it would take me a year to figure it out by myself I hope you can help me