I am trying to get the ATtiny85 to control my WS2811 12v light strip and having a problem doing so.
I've been messing around with this for the last couple days.
I bread boarded the ATtiny85 and have 12V power going to the LED's thru a 12v DC power supply. I have 5v power to the chip thru the L7805cv I am using a 220 resistor on the Data line to the LED strip. I programmed the chip to 16mhz (tried 8MHZ as well) and it is lighting but not the correct color as defined in the program below. I think the light strip must have a memory because it lights to the color that was lit thru the Arduino. I have this running perfectly with a photoresistor and motion detector on the Uno. But once I included the ATtiny85 it was not responding properly so I figured I'd start from square one, just getting the LED strip lighting properly.
So I changed the color in the program on purpose just to see if the chip was functioning properly and of course it is not working as I suspected.
I would greatly appreciate some help.
I have pasted the code I have uploaded to the chip below:
// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
//#############################################################################################
//#############################################################################################
//# Adafruit NeoPixel library
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
// Data pin on ATtiny85
#define PIN 0 // ATtiny85 LED Data pin
// How many NeoPixels are attached
#define NUMPIXELS 13 // Popular NeoPixel ring size
#define DELAYVAL 0 // Time (in milliseconds) to pause between pixels
// When setting up the NeoPixel library, we tell it how many pixels,
// and which pin to use to send signals. Note that for older NeoPixel
// strips you might need to change the third parameter -- see the
// strandtest example for more information on possible values.
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
// These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
// Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
clock_prescale_set(clock_div_1);
#endif
// END of Trinket-specific code.
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
}
void loop()
{
pixels.clear(); // Set all pixel colors to 'off'
// The first NeoPixel in a strand is #0, second is 1, all the way up
// to the count of pixels minus one.
for(int i=0; i<NUMPIXELS; i++)
{ // For each pixel...
pixels.setPixelColor(i, pixels.Color(255, 0, 0)); //Testing ATtiny85 only... Should be RED color
}
pixels.show();
}
A picture is worth a thousand words. This is how I have it wired up. Thank you for your help. I appreciate it. In the meantime I will look in to how to draw a proper schematic.
Sorry no. It is missing the boxes that represent the power supply and the strip. we need to see how the power wiring is, and what capacitors you have in the circuit.
Here is a schematic I made eirler that does something similar to what you want to do.
Note that the pin numbers are not in the same order as they are in the physical components. Their position is chosen to make the wiring from one part to the next as simple as possible with the minimum number of wires crossing.
Also positive is towards the top of the circuit with ground at the bottom.
The ground symbol on Pin four of the ATtiny 85 is connected to all the other symbols of the same type without showing the wiring in between. The same goes for the 5V symbol with a line under it. This prevents the schematic getting cluttered.
In your case you seem to be missing anything on the reset pin (pin 1 of the 85). This should be connected to 5V through a 10K series resistor.
The capacitors across this need to be as close to the chip as possible, and have an large electrolytic in parallel with a 0.1uF ceramic capacitor across the input and output to ground.
That is probably the issue.
I normally put a 100uF 'before' the 7805, and about 10uF after, the ATtiny doesn't draw a lot of power though, smaller values will probably suffice. The capacitor on the 5v rail is not optional though.
OK I have watched the electrical schematic video from Collins lab. Question, I am using the Ubuntu OS. Is there a recommended software to create these schematics that is easy to use for someone like myself, just getting started? I do want to learn this stuff. Its a lot of fun. If anyone could suggest a good software package for this I would appreciate it. I loaded the blink sketch to the ATtiny85 and it worked fine running off the power supply I have in my current design if that matters..
Also, I created another "schematic" that might give you more information. I currently do not have anything connected to the reset. If you think that is where I am going wrong, I will definitely give it a shot. What does connecting the reset do btw? Curious.. I appreciate your help very much. I also included a picture of the prototype board that I built, thinking that it would work from the getgo, lol.
Thanks again for your help. I appreciate it. Again, if anyone knows of a good linux based software for designing electrical schematics that would be very helpful. Preferably something relatively easy to use for a newbie like myself
try Kicad it is a program to design PCB's and has a program to create schematics included.
The reset pin needs to be above 0.5 * VCC or the board resets. Some ATtinys have a pullup resistor on it, but i don't think the 85 does. so unless you pull it high, the board may reset at any time.,
FWIW I did add the .1uf ceramic capcitor after the 10uf 25v electrolytic capacitor as well as connected the reset with a 10K resistor. I also moved the ATtiny to the same breadboard as the L7805cv. I still have the same issue...
Any debugging ideas? I've tried both 8 and 16MHZ with the same result.
Blockquote
The reset pin needs to be above 0.5 * VCC or the board resets. Some ATtinys have a pullup resistor on it, but i don't think the 85 does. so unless you pull it high, the board may reset at any time.,
The capacitors across this need to be as close to the chip as possible, and have an large electrolytic in parallel with a 0.1uF ceramic capacitor across the input and output to ground.
Well I figured out what I was doing wrong.... I didn't first do "Burn Bootloader" on the ATtiny.
Its running like a champ now! Thanks for your help Mike. I will be sure to add a 10K resistor to the reset going forward. And I'll learn how to make a proper schematic.. haha
@cwojohoitz did you see the edit I added to reply #8 where I showed you what your circuit should look like?
Yes I use Kicad as well when I want a PCB, but I feel the big problem with schematic layout software is that if it is easy to use then generally it is useless. Like Fritzing that will actually generate schematics, the big problem is generating the parts which makes people use totally inappropriate replacements.
Most of the time I use a general 2D drawing package. So on my Mac I use MacDraft. For a Linux system the free equivalent would be Inkscape. Once you have drawn a few symbols you can create a library or collection of these that you can simply copy and paste when you work on a new schematic.
A question probably not related to the problem, maybe it does.
You said it all worked with the Uno but not the ATtiny85. Does the Adafruit library use a timer? If it does, which one - timer1? Remember the ATtiny85 has a timer1 not even close to the normal Uno 16-bit timer1. Does the library, if it uses timer1, cater for the difference?
Just a thought.
Edit: I just saw there is an ATtiny85 specific setting in your code (somehow missed it on the initial read). So, just ignore the above.
No it's just bit-banged, with specific code for 16MHz and 8MHz AVR's and any other architecture it supports.
That bit of code is actually for the use of an ATtiny with a 16MHz Crystal or USB tuned.