Hey guys new to programing and circuits. I have been able to program an atmega (or so I think) just trying to problem solve if my circuit is built right.
(As in the picture)
pin 4 (digital pin 2) to data wire of the led strip through 330ohm resistor.
p5 (D3) to button 1 (b1).
P6 (D4) to b2.
P7 (VCC) connects to power of leds.
P8 (GND) connects to ground of leds.
P9 and P10 connected to 16mhz crystal with 22p capacitors connecting each side to ground.
P11 (D5) connected to B3.
Also all buttons are connected to ground and theres a 10uf capacitor between power and ground.
Good advice: Buy an Arduino board. A basic 5V Arduino board is best for a ledstrip. An Arduino Uno, a classic Arduino Nano, or a clone such as the Pro Micro.
You still have enough problems to solve, such as the power for the ledstrip.
Suppose that you want to make an ATmega8 work. Which version do you have ? A ATmega8A or ATmega8L or the plain ATmega8 ?
Then our first question is always: Can you show a schematic ?
You have to connect all the GND pins to GND and all the (A)VCC pins to 5V.
And where are the decoupling capacitors ?
Suppose that you have a working ATmega8 and a programmer to put code in it.
Then I suggest to make a led blink.
When the led blinks, hang it on the wall as a trophy and buy an Arduino board for the ledstrip.
Hey xfpd i do have the rest of the code i thought it might be how the circuit was set up as i've used the same code on my nano to produce the desired patterns. Here is more of the code:
#include <FastLED.h>
#include <OneButton.h>
#define LED_PIN 2
#define BTN_PIN 3
#define BTN2_PIN 4
#define BTN3_PIN 5
#define NUM_LEDS 72
CRGB leds[NUM_LEDS];
uint8_t patternCounter = 0;
uint8_t patternCounter2 = 0;
uint8_t patternCounter3 = 0;
OneButton btn = OneButton(BTN_PIN, true, true);
OneButton btn2 = OneButton(BTN2_PIN, true, true);
OneButton btn3 = OneButton(BTN3_PIN, true, true);
int a = 4;
int b = 30;
int c = 40;
int d = 40;
int e = 40;
int x = 0;
int y = 0;
int z = 100;
void setup() {
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
btn.attachClick(nextPattern);
btn2.attachClick(nextPattern2);
btn3.attachClick(nextPattern3);
}
void loop() {
switch (patternCounter) {
case 0:
wh();
break;
case 1:
rgbf();
break;
case 2:
rgbs();
break;
case 3:
re();
break;
case 4:
org();
break;
case 5:
ye();
break;
case 6:
ge();
break;
case 7:
aq();
break;
case 8:
bl();
break;
case 9:
pu();
break;
case 10:
pi();
break;
}
switch (patternCounter2) {
case 0:
p70();
break;
case 1:
p100();
break;
case 2:
p40();
break;
}
switch (patternCounter3) {
case 0:
shinedi();
break;
case 1:
shinedi2();
break;
case 2:
shinehor();
break;
case 3:
shinever();
break;
case 4:
alls();
break;
case 5:
shinedif();
break;
case 6:
shinedi2f();
break;
case 7:
shinehorf();
break;
case 8:
shineverf();
break;
case 9:
allf();
break;
}
fadeToBlackBy(leds, NUM_LEDS, a); // Smaller value = longer tail
int m = (b + millis()/c) % NUM_LEDS; // How fast it goes.
leds[m] = CHSV(x, y, z);
int n = - (millis()/c) % NUM_LEDS; // How fast it goes.
leds[n] = leds[m];
FastLED.show();
btn.tick();
btn2.tick();
btn3.tick();
}
My question isn't about the code, the function calls are further down and not relevant. It works, i know since i developed it on a nano and it worked to product patterns on an led strip. I'm trying to use an atmega8 to replace the nano so i can have a cost effective way of doing this to multiple separate led strips around the house. I'm trying to see if the circuit described in my original post would work. Thanks
Hey koepel,
Already have a nano thats how i developed my code and tested it, the code definitely works for a nano to led strip. Im trying to have a cost effective way to have more of these custom led strips. Led strip is also connected to a 5v supply, i didn't think it would matter which atmega8 i had since they all have the same pinout (but if it does its just the atmega8). I'll add a link to another post with a picture. I'm quite new to this and haven't figured out how to do schematics yet. All ground are connected and all power pins are connected to power. The 10uf capacitor is between the power and ground
That circuit is not enough. The GND and (A)VCC on the other side must be connected as well. Some tutorials connect AREF, but leave AREF open. You must add 100nF decoupling capacitors.
I did a test for 72 leds in a ledstrip and using the Serial output. It uses 511 bytes:
That means (in theory) it might run on a ATmega8. But it is very scary