Hello everyone! I am trying to run a sketch that uses a 9 LED ledstrip, as well as a mini pushbutton switch (as an on/off button). I need the ATTINY85, because my set up has to be very small.
I am using Arduino 1.8.8 and found several tutorials on how to program the ATTINY85 with the Arduino Uno. This I managed to do and tested with the blink. Beyond that, I find it difficult to find tutorials that describe how to upload your own code, also when it involves several pins.
My logic follows that I can just upload it to the ATTINY85 in the basic setup and then set up the independent circuit. I am planning to use https://www.circuito.io/app?components=97,9442,12027,8300591 for that.
When I now try to upload I get the infamous 'exit status 1' error message.
My code is as follows:
#include <Button.h>
#include <FastLED.h>
#define NUM_LEDS 9
#define DATA_PIN PB0
#define LED_PIN PB0
#define BRIGHTNESS 64
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
int inPin = PB1; // the number of the input pin
int outPin = PB2; // the number of the output pin
int state = HIGH; // the current state of the output pin
int reading; // the current reading from the input pin
int previous = LOW; // the previous reading from the input pin
// the follow variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long time = 0; // the last time the output pin was toggled
long debounce = 200; // the debounce time, increase if the output flickers
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
delay( 3000 ); // power-up safety delay
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
pinMode(inPin, INPUT);
pinMode(outPin, OUTPUT);
}
void loop() {
{
reading = digitalRead(inPin);
// if the input just went from LOW and HIGH and we've waited long enough
// to ignore any noise on the circuit, toggle the output pin and remember
// the time
if (reading == HIGH && previous == LOW && millis() - time > debounce) {
if (state == HIGH)
state = LOW;
else
state = HIGH;
time = millis();
}
digitalWrite(outPin, state);
previous = reading;
}
leds[0] = CRGB::Green;
FastLED.show();
delay(3000);
leds[1] = CRGB::Green;
FastLED.show();
delay(3000);
leds[2] = CRGB::Green;
FastLED.show();
delay(3000);
leds[3] = CRGB::Green;
FastLED.show();
delay(3000);
leds[4] = CRGB::Green;
FastLED.show();
delay(3000);
leds[5] = CRGB::Green;
FastLED.show();
delay(3000);
leds[6] = CRGB::Green;
FastLED.show();
delay(3000);
leds[7] = CRGB::Green;
FastLED.show();
delay(3000);
leds[8] = CRGB::Green;
FastLED.show();
delay(3000);
for (int i = 0; i < 9; i++) {
leds[i] = CRGB::Green;
FastLED.show();
leds[i] = CRGB::Black;
delay(100);
}
randomSeed(millis());
int wait=random(10,30);
int dim=random(4,6);
int max_cycles=8;
int cycles=random(1,max_cycles+1);
rainbowCycle(wait, cycles, dim);
}
void rainbowCycle(int wait, int cycles, int dim) {
//loop several times with same configurations and same delay
for(int cycle=0; cycle < cycles; cycle++){
byte dir=random(0,2);
int k=255;
//loop through all colors in the wheel
for (int j=0; j < 256; j++,k--) {
if(k<0) {
k=255;
}
//Set RGB color of each LED
for(int i=0; i<NUM_LEDS; i++) {
CRGB ledColor = wheel(((i * 256 / NUM_LEDS) + (dir==0?j:k)) % 256,dim);
leds[i]=ledColor;
}
FastLED.show();
FastLED.delay(wait);
}
}
}
CRGB wheel(int WheelPos, int dim) {
CRGB color;
if (85 > WheelPos) {
color.r=0;
color.g=WheelPos * 3/dim;
color.b=(255 - WheelPos * 3)/dim;;
}
else if (170 > WheelPos) {
color.r=WheelPos * 3/dim;
color.g=(255 - WheelPos * 3)/dim;
color.b=0;
}
else {
color.r=(255 - WheelPos * 3)/dim;
color.g=0;
color.b=WheelPos * 3/dim;
}
return color;
}
Now to my two main questions:
- In which circuit set-up do I best install my sketch?
- Which pins do I put into my sketch, the ones that are connected to the Arduino Uno right now or according to the ATTiny85 schematic?
I am grateful for direct troubleshooting and hints, as well as general resources that would help! Thank you.