Hello, I recently created a sketch perfectly working with my uno, which basically controls an RGB strip. I then scaled it down to use it with an attiny 85, powered by 5V. I configured the IDE to use a 8MHz internal frequency, burned the bootloader and the flash but to no avail. No activity on the pin led. For reference I hooked up my UNO to the currently created board and the same sketch and everything works properly. I just have to control 50 leds. What am I doing wrong? thanks
Post your sketch and use code tags when you do
Is the attiny85 a bare board type or do you have some manufactured board?
Has this ever run on an tiney85?
It would help if you could post your code (using the 'code <->' tag... along with a schematic...
I have a number of these around... generally setup like this, bare board attiny85 and an Atmel Dragon programmer...
How it's wired up will help me help you debug it..
Good time to suggest you lean to use one of the many debuggers out there... The time it takes to lean it will be nothing compared to the time you have to 'fiddle' with other items to see what it's doing... The new Arduino has a debug mode, but I don't think it works with the tiny85
Hi, I have a bare chip, it's not my first tiny85 board… I'm using an usbasp to program it. I've been programming those for the last 10 years but something went wrong today.
Here's the sketch it's been copied from a previous sketch.
I'm, 100% positive the sketch works on other boards and gets compiled and uploaded just fine to the tiny. Thanks for any help
#include <Adafruit_NeoPixel.h>
#include <avr/delay.h>
#define PIN_LED 5
#define BRIGHTNESS 8
#define NUM_LED 50
#define DELAY 120
#define TYPE NEO_GRB + NEO_KHZ800
#define STEPS 180
class Strip {
public:
uint8_t effect;
uint8_t effects;
uint8_t effStep;
Adafruit_NeoPixel strip;
Strip()
: strip(NUM_LED, PIN_LED, TYPE) {
effect = -1;
effects = 0;
Reset();
}
void Reset() {
effStep = 0;
effect = 1;
}
};
//
struct Colore {
uint8_t r;
uint8_t g;
uint8_t b;
Colore(uint8_t rosso, uint8_t verde, uint8_t blu) {
r = rosso;
g = verde;
b = blu;
}
Colore() {}
};
struct Effetto {
Colore colori[9];
void set_colori(Colore p, Colore s, Colore t,Colore q, Colore Q,Colore S,Colore e,Colore o, Colore n) {
colori[0] = p;
colori[1] = s;
colori[2] = t;
colori[3]=q;
colori[4]=Q;
colori[5]=S;
colori[6]=e;
colori[7]=o;
colori[8]=n;
}
};
Strip strip_0;
float F = 180.0 / 9.0;
const Colore blu_1 = Colore(0, 100, 200);
const Colore blu_2 = Colore(0, 0, 255);
const Colore blu_3 = Colore(0, 50, 255);
const Colore rosso_1 = Colore(255, 0, 0);
const Colore rosso_2 = Colore(200, 0, 0);
//const Colore rosso_3 = Colore(200, 100, 0);
const Colore verde_1 = Colore(0, 255, 0);
const Colore verde_2 = Colore(20, 200, 20);
//const Colore verde_3 = Colore(20, 150, 20);
//const Colore a_1 = Colore(255, 150, 0);
const Colore a_2 = Colore(200, 150, 0);
const Colore a_3 = Colore(100, 200, 0);
Effetto effetto;
volatile Effetto* Curr_Effetto;
void setup() {
// Serial.begin(9600);
effetto.set_colori(rosso_1,rosso_2,a_2,a_3,verde_2,verde_1,blu_3,blu_1,blu_2);
Curr_Effetto = &effetto;
//Your setup here:
//Serial.println(primo.r);
strip_0 = Strip();
strip_0.strip.begin();
strip_0.strip.setBrightness(BRIGHTNESS);
}
void loop() {
//Your code here:
strips_loop();
}
void strips_loop() {
applyEffect();
strip_0.strip.show();
}
void applyEffect() {
_delay_ms(DELAY);
for (uint8_t i = 0; i < NUM_LED; i++) {
uint8_t ind = STEPS - ((strip_0.effStep - i) % STEPS);
uint8_t col_ind = (uint8_t)((ind % STEPS) / F);
float f1 = 1.0 - ((float)(ind % STEPS - col_ind * F) / F);
float f2 = (float)((((int)(ind - col_ind * F)) % STEPS) / F);
uint8_t next = (col_ind + 1) % 9;
strip_0.strip.setPixelColor(i,
f1 * (Curr_Effetto->colori[col_ind].r) + f2 * (Curr_Effetto->colori[next].r),
f1 * (Curr_Effetto->colori[col_ind].b) + f2 * (Curr_Effetto->colori[next].b),
f1 * (Curr_Effetto->colori[col_ind].g) + f2 * (Curr_Effetto->colori[next].g));
}
if (strip_0.effStep >= STEPS) {
strip_0.Reset();
} else strip_0.effStep++;
}
Can you easily 're-flash' it and and post the output of avrdude?
I assume no errors or other anomalies. ?
You might need to hang an 'led' off one of the pins to help you figure out what's going on.
I assume that adafruit library supports the attiny...
You may want to read the special Neopixel instruction page of attinycore
I'll try as soon as I can. Thanks.
Ok, after quite a substantial reshuffling, in the end I was able to make it work, by changing the pin and the library and I ultimately don't know what made it right but now it's all good.
Cheers!
ps: the code, for reference
#include <tinyNeoPixel.h>
#include <avr/delay.h>
#define PIN_LED PORTB4
#define BRIGHTNESS 28
#define NUM_LED 30
#define DELAY 120
#define TYPE NEO_GRB + NEO_KHZ800
#define STEPS 140
class Strip {
public:
uint8_t effect;
uint8_t effects;
uint8_t effStep;
tinyNeoPixel strip;
Strip()
: strip(NUM_LED, PIN_LED, TYPE) {
effect = -1;
effects = 0;
Reset();
}
void Reset() {
effStep = 0;
effect = 1;
}
};
//
struct Colore {
uint8_t r;
uint8_t g;
uint8_t b;
Colore(uint8_t rosso, uint8_t verde, uint8_t blu) {
r = rosso;
g = verde;
b = blu;
}
Colore() {}
};
struct Effetto {
Colore colori[9];
void set_colori(Colore p, Colore s, Colore t,Colore q, Colore Q,Colore S,Colore e,Colore o, Colore n) {
colori[0] = p;
colori[1] = s;
colori[2] = t;
colori[3]=q;
colori[4]=Q;
colori[5]=S;
colori[6]=e;
colori[7]=o;
colori[8]=n;
}
};
Strip strip_0;
float F = 140.0 / 9.0;
const Colore blu_1 = Colore(0, 100, 200);
const Colore blu_2 = Colore(0, 0, 255);
const Colore blu_3 = Colore(0, 50, 255);
const Colore rosso_1 = Colore(255, 0, 0);
const Colore rosso_2 = Colore(200, 0, 0);
//const Colore rosso_3 = Colore(200, 100, 0);
const Colore verde_1 = Colore(0, 255, 0);
const Colore verde_2 = Colore(20, 200, 20);
//const Colore verde_3 = Colore(20, 150, 20);
//const Colore a_1 = Colore(255, 150, 0);
const Colore a_2 = Colore(200, 150, 0);
const Colore a_3 = Colore(100, 200, 0);
Effetto effetto;
volatile Effetto* Curr_Effetto;
void setup() {
// Serial.begin(9600);
effetto.set_colori(rosso_1,rosso_2,a_2,a_3,verde_2,verde_1,blu_3,blu_1,blu_2);
Curr_Effetto = &effetto;
//Your setup here:
//Serial.println(primo.r);
strip_0 = Strip();
strip_0.strip.begin();
strip_0.strip.setBrightness(BRIGHTNESS);
}
void loop() {
//Your code here:
strips_loop();
// strip_0.strip.setPixelColor(0,155,255,0);
//strip_0.strip.show();
}
void strips_loop() {
applyEffect();
strip_0.strip.show();
}
void applyEffect() {
_delay_ms(DELAY);
for (uint8_t i = 0; i < NUM_LED; i++) {
uint8_t ind = STEPS - ((strip_0.effStep - i) % STEPS);
uint8_t col_ind = (uint8_t)((ind % STEPS) / F);
float f1 = 1.0 - ((float)(ind % STEPS - col_ind * F) / F);
float f2 = (float)((((int)(ind - col_ind * F)) % STEPS) / F);
uint8_t next = (col_ind + 1) % 9;
strip_0.strip.setPixelColor(i,
f1 * (Curr_Effetto->colori[col_ind].r) + f2 * (Curr_Effetto->colori[next].r),
f1 * (Curr_Effetto->colori[col_ind].b) + f2 * (Curr_Effetto->colori[next].b),
f1 * (Curr_Effetto->colori[col_ind].g) + f2 * (Curr_Effetto->colori[next].g));
}
if (strip_0.effStep >= STEPS) {
strip_0.Reset();
} else strip_0.effStep++;
}
Glad you got it up an running...
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.