ATtiny+ws2801 with Arduino library?

Hey.
Is it possible to run ws2801 LED strip with ATtiny85 via Arduino software?
Will Arduino's library form ws2801 work on ATtiny?
I only need to run 2 pixels and 1 pushbutton to change some static colors and 1 rainbow cycle.

I guess you're using the library from Adafruit (you didn't supply a link to it). I don't have experience with using that library with an ATtiny but I cannot find anything in the code that would make problems on an ATtiny85. It even has support for MCU without hardware SPI. You have to take care that you don't run over the flash and RAM limits of your ATtiny but you probably already know that.

Maybe there are different libraries and some require less resources, I don't know.
How can I tell, how much RAM my program is using?

Ragnar:
How can I tell, how much RAM my program is using?

There are functions to display how much RAM is unused, but in order to set that up on an ATtiny will use even more RAM so won't be particularly helpful. You'll find the ATtiny85 can do quite a lot, but that data structures like arrays chew into your RAM very quickly. From reading the library you're proposing that shouldn't be an issue. I also just compiled the included example for the ATtiny85 core and didn't get any errors, so that's a good sign it's compatible.

If you try it, and your ATtiny85 does random restarts, or acts up...you'll likely have found you're over the available limit.

Alternatively, if you haven't bought your ATtiny85 yet, create your sketch on the Arduino and something like is described here Arduino Playground - HomePage and output the available RAM to your serial monitor. If you have more than 1500 bytes free you've used less than the ATtiny's 512 bytes (rough numbers) and since the code for monitoring the RAM won't be there in the ATtiny version of your sketch you'll be even further ahead.

I'd go for it and see if it works myself :slight_smile:
Geoff

Now I got my Attiny and looks like it doesn't support TimerOne library. :frowning:
Can't compile the code for Attiny.
And at the moment I have LPD6803 LED strip. But I can't get it working.
Actually I just need 7 static colors and 1 rainbow run. Length is only 1 pixel.

Why do you need that library? You might have to describe what you wanna achieve and post the full code you already have. This way we might give you a hint how to get your project to a success.

I have a 12V LPD6803 (later ws2801 with 5V) LED strip. I'd like to take 1 or 2 pixels and put them behind attiny. And every attiny+ledpixel have 1 pushbutton, that changes colors (red, green, blue, cyan, magenta, yellow, white, rainbow scroll).
I need to get them working with 5V power supply (with ws2801, not 12V lpd6803 thatI have for testing at the moment). And it needs to be quite small, not wider than led strip and max 4cm long.
Only code that works is increasing program number with pushbutton and reverting it ti 0 if it exeeds 7.

So you don't have a WS2801 strip yet? I guess the lpd6803 has some other characteristics. I have a WS2801 strip running here with 100 LEDs running it from a Arduino UNO. I don't see any problem getting your setup working. Try the Adafruit library, it comes with an example that does some kind of rainbow but you have to describe what the rainbow effect means in your project.

You haven't defined what you need the TimerOne library for.

I have no problem running lpd6803 or ws2801 with Arduino Uno or Teensy.
I want to run them with attiny. lpd6803 library that works with Arduino Uno, uses timer1 and attiny does not support it.

The Adafruit library for WS2801 does not use anything except SPI. But if you define your own two pins to use it circumvents the hardware SPI and does all the necessary stuff itself.

So I guess you have to wait for your WS2801 strip to arrive and your problems are at least one less.

If I try to compile Adafruit WS2801 library example strandtest, I get multiple errors.

strandtest.cpp:2:29: error: Adafruit_WS2801.h: No such file or directory
In file included from strandtest.cpp:1:
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h: In static member function 'static byte SPIClass::transfer(byte)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h:56: error: 'SPDR' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h:57: error: 'SPSR' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h:57: error: 'SPIF' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h: In static member function 'static void SPIClass::attachInterrupt()':
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h:63: error: 'SPCR' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h:63: error: 'SPIE' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h: In static member function 'static void SPIClass::detachInterrupt()':
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h:67: error: 'SPCR' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h:67: error: 'SPIE' was not declared in this scope
strandtest.cpp: At global scope:
strandtest.pde:-1: error: 'Adafruit_WS2801' does not name a type
strandtest.cpp: In function 'void setup()':
strandtest.pde:-1: error: 'strip' was not declared in this scope
strandtest.cpp: In function 'void rainbow(uint8_t)':
strandtest.pde:-1: error: 'strip' was not declared in this scope
strandtest.pde:-1: error: 'strip' was not declared in this scope
strandtest.cpp: In function 'void rainbowCycle(uint8_t)':
strandtest.pde:-1: error: 'strip' was not declared in this scope
strandtest.pde:-1: error: 'strip' was not declared in this scope
strandtest.cpp: In function 'void colorWipe(uint32_t, uint8_t)':
strandtest.pde:-1: error: 'strip' was not declared in this scope

In my version of strandtest it just says:

#include "WS2801.h"

You might have got an old version?

I download the latest version from Github, but still the same.

You're right, the latest version has been renamed. But the name in the example file is the same as the library. Have you installed the library correctly? Can you open the example by using the Example menu of the IDE?
The Readme.txt file contains installation instructions.

pylon:
Can you open the example by using the Example menu of the IDE?

Yes, I can.
I've installed libraries before and never had a problem. I'm using Arduino IDE 1.0.

Have you checked for case errors?

Is a file named exactly "Adafruit_WS2801/Adafruit_WS2801.h" within your libraries folder?

Stupid me. It was not in libraries folder. Just in sketchbook. :blush:
Now I still have some errors.

In file included from strandtest.cpp:1:
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h: In static member function 'static byte SPIClass::transfer(byte)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h:56: error: 'SPDR' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h:57: error: 'SPSR' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h:57: error: 'SPIF' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h: In static member function 'static void SPIClass::attachInterrupt()':
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h:63: error: 'SPCR' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h:63: error: 'SPIE' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h: In static member function 'static void SPIClass::detachInterrupt()':
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h:67: error: 'SPCR' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h:67: error: 'SPIE' was not declared in this scope

If I choose Arduino Uno as board, the code compiles.
Errors come with Attiny85 internal 1MHz clock.

Seems like the Arduino IDE's SPI class has no support for the ATtiny's USI yet. You may volunteer to do that? :slight_smile:

But otherwise you can use the non-(hardware)SPI interface and comment #include "SPI.h" out.

If You teach me, I could do that. :smiley:

Commenting SPI.h out does not help.

/Users/raxz/Documents/Arduino/libraries/Adafruit_WS2801/Adafruit_WS2801.cpp: In member function 'void Adafruit_WS2801::updatePins(uint8_t, uint8_t)':
/Users/raxz/Documents/Arduino/libraries/Adafruit_WS2801/Adafruit_WS2801.cpp:77: error: 'SPI' was not declared in this scope
/Users/raxz/Documents/Arduino/libraries/Adafruit_WS2801/Adafruit_WS2801.cpp: In member function 'void Adafruit_WS2801::startSPI()':
/Users/raxz/Documents/Arduino/libraries/Adafruit_WS2801/Adafruit_WS2801.cpp:97: error: 'SPI' was not declared in this scope
/Users/raxz/Documents/Arduino/libraries/Adafruit_WS2801/Adafruit_WS2801.cpp:99: error: 'SPI_MODE0' was not declared in this scope
/Users/raxz/Documents/Arduino/libraries/Adafruit_WS2801/Adafruit_WS2801.cpp:100: error: 'SPI_CLOCK_DIV16' was not declared in this scope
/Users/raxz/Documents/Arduino/libraries/Adafruit_WS2801/Adafruit_WS2801.cpp: In member function 'void Adafruit_WS2801::show()':
/Users/raxz/Documents/Arduino/libraries/Adafruit_WS2801/Adafruit_WS2801.cpp:129: error: 'SPDR' was not declared in this scope
/Users/raxz/Documents/Arduino/libraries/Adafruit_WS2801/Adafruit_WS2801.cpp:130: error: 'SPSR' was not declared in this scope
/Users/raxz/Documents/Arduino/libraries/Adafruit_WS2801/Adafruit_WS2801.cpp:130: error: 'SPIF' was not declared in this scope

I haven't read the relevant USI documentation yet, so I don't know what do to support SPI through USI.

If you gonna use the library in non-SPI mode you can comment the include out and every line in the library source where the SPI object ("SPI.") is mentioned plus the lines with SPDR and SPIF in it. Then you have to use the constructor with the two pins specified.