I am trying to use this sketch with the Attiny85:
// Ambient RGB light
//
// Controls RGB LEDs; smoothly transitions through color values.
// Delay time: sets the time in milliseconds between loop iterations.
// Make this value large for slower transitions.
#define DELAY_TIME 10
// Maximum Brightness: the maximum level the pins will reach.
#define MAX_BRIGHT 255
// The pins which each color value is output to.
#define PIN_RED 0
#define PIN_GREEN 1
#define PIN_BLUE 2
// The initial values of each color.
int red = 0;
int green = 170;
int blue = 170;
// Indicates whether a color is incrementing (1) or decrementing (0).
int incR = 1;
int incG = 1;
int incB = 0;
// Smoothly changes the color values
void transition()
{
if (red >= MAX_BRIGHT)
incR = 0;
else if (red <= 0)
incR = 1;
if (green >= MAX_BRIGHT)
incG = 0;
else if (green <= 0)
incG = 1;
if (blue >= MAX_BRIGHT)
incB = 0;
else if (blue <= 0)
incB = 1;
if (incR)
red++;
else
red--;
if(incG)
green++;
else
green--;
if(incB)
blue++;
else
blue--;
}
// Sets the output voltage on the LED pins.
void setColor()
{
analogWrite(PIN_RED, red);
analogWrite(PIN_GREEN, green);
analogWrite(PIN_BLUE, blue);
}
void setup()
{
// Do nothing.
}
void loop()
{
transition();
setColor();
delay(DELAY_TIME);
}
The problem I am having is that on the Attiny85 there are only 2 pins for PWM(unless I am missing something) Pin 0 and Pin 1. These two pulse the LEDs like they are supposed to. However the 3rd LED connected to pin 2 just blinks and doesn't fade in and out like it's supposed to. Is this sketch not possible with the Attiny85? I would like to have an RGB mood light running from the attiny85 if possible. Thanks.
FallenDemon:
The problem I am having is that on the Attiny85 there are only 2 pins for PWM(unless I am missing something) Pin 0 and Pin 1.
Three. Digital pins 0, 1, and 4.
Thanks for replying. However when I changed the sketch to 0, 1, and 4, the LED connected to Pin 4 on the Attiny still doesn't fade like 0 and 1 do. It just blinks. I don't understand.
Genious man! Changed cores and it works! One more thing. I chose ATtiny85 @ 8 MHz. Should I burn the bootloader with this board selected for my other Attiny chips? Reason I ask is because I was doing the "Burn Bootloader" option with the other core and am not sure if it is the same procedure.
EDIT: Also I get these errors while uploading to the Attiny-
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
Now the skecth still uploads and it works just fine, I would just rather not see those errors. Any ideas?
FallenDemon:
Genious man! Changed cores and it works!
Excellent.
One more thing. I chose ATtiny85 @ 8 MHz. Should I burn the bootloader with this board selected for my other Attiny chips? Reason I ask is because I was doing the "Burn Bootloader" option with the other core and am not sure if it is the same procedure.
The two cores work the same in that regard. Select the "board" and execute Burn Bootloader to change the fuses.
EDIT: Also I get these errors while uploading to the Attiny-
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
They are warnings and can be ignored.
Now the skecth still uploads and it works just fine, I would just rather not see those errors. Any ideas?
Towards the bottom of this post...
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286388623/47#47
Very brief instructions for editing avrdude.conf...
Hey thanks a lot! You've been very helpful.