Hello,
First time using an ATtiny85 and I'm not sure if this is the right place to ask. I've installed the relevant drivers and libraries for Digispark, and a demo code does compile and upload to the board.
I wrote my code and tested on an UNO and everything works as intended. However, I get an error when compiling for Digispark. The error message seems to suggest it's because of FastLED, but anything I can find online suggests that it should work.
Blockquote In file included from D:\Users\Steve\Documents\Arduino\libraries\FastLED/FastLED.h:65:0,
from D:\Users\Steve\Documents\Arduino\LED_nightlight\LED_nightlight_attiny\LED_nightlight_attiny.ino:1:
D:\Users\Steve\Documents\Arduino\libraries\FastLED/fastspi.h: At global scope:
D:\Users\Steve\Documents\Arduino\libraries\FastLED/fastspi.h:130:23: note: #pragma message: No hardware SPI pins defined. All SPI access will default to bitbanged output
pragma message "No hardware SPI pins defined. All SPI access will default to bitbanged output"
This might be a very dumb question, but I was under the impression that I can use the same arduino coding for the ATtiny as long as I'm using the arduino ide. But I cannot for the life of me find the answer to this.
I'm at a loss at what I need to do. Any help would be much appreciated.
Thank you.
#include <FastLED.h>
#define LED_PIN 5
#define NUM_LEDS 48
//#define BRIGHTNESS 10
#define LED_TYPE WS2812B
CRGB leds[NUM_LEDS];
uint8_t paletteIndex = 0;
int button = 1;
int dimmerButton = 3;
//int color;
//int readColor;
int brightness;
//main button
int inputDelay = 400;
long int previousInput;
//int buttonInterval = 1000;
int buttonCounter = 0;
bool buttonState = 1;
bool lastButtonState = 1;
bool powerState = 0;
//dimmer button
int dimmerButtonCounter = 0;
bool dimmerButtonState = 1;
bool lastDimmerButtonState = 1;
//timing
unsigned long startTime = 0;
long int timer[] = {5000, 10000, 15000};
long int timeOne = 5000;
long int timeTwo = 10000;
long int timeThree = 15000;
void setup() {
//delay( 3000 ); // power-up safety delay
//Serial.begin(9600);
pinMode(button, INPUT_PULLUP);
pinMode(dimmerButton, INPUT_PULLUP);
FastLED.addLeds<LED_TYPE, LED_PIN,GRB>(leds, NUM_LEDS);
FastLED.clear();
FastLED.show();
}
void loop() {
dimmerButtonState = digitalRead(dimmerButton);
if(dimmerButtonState != lastDimmerButtonState)
{
if(dimmerButtonState == 0)
{
dimmerButtonCounter++;
}
delay(50);
}
lastDimmerButtonState = dimmerButtonState;
if(dimmerButtonCounter == 0)
{
brightness = 30;
}
if(dimmerButtonCounter == 1)
{
brightness = 60;
}
if(dimmerButtonCounter == 2)
{
brightness = 90;
}
if(dimmerButtonCounter == 3)
{
dimmerButtonCounter = 0;
}
buttonState = digitalRead(button);
if (buttonState != lastButtonState)
{
if (buttonState == 0)
{
buttonCounter++;
switch(buttonCounter)
{
case 0:
//Serial.println("0");
FastLED.clear();
FastLED.show();
powerState = 0;
break;
case 1:
//Serial.println("1");
startTime = millis();
powerState = 1;
break;
case 2:
//Serial.println("2");
startTime = millis();
powerState = 1;
break;
case 3:
// Serial.println("3");
startTime = millis();
powerState = 1;
break;
case 4:
//Serial.println("4");
powerState = 1;
break;
}
}
delay(50);
}
lastButtonState = buttonState;
if(buttonCounter != 0)
{
brightnessSet();
setColor();
}
if(buttonCounter > 4)
{
buttonCounter = 0;
// Serial.println("0");
FastLED.clear();
FastLED.show();
powerState = 0;
}
if(powerState && (millis() - startTime > timer[buttonCounter - 1]) && buttonCounter != 4)
{
buttonCounter = 0;
//Serial.println("0");
FastLED.clear();
FastLED.show();
powerState = 0;
}
// Serial.println(average);
}
void setColor() {
for(int i = 0; i < NUM_LEDS ; i++)
{
leds[i] = CRGB(255,85,0);
FastLED.show();
}
}
void brightnessSet(){
FastLED.setBrightness( brightness );
FastLED.show();
}```