Go Down

Topic: ATtiny+ws2801 with Arduino library? (Read 4847 times) previous topic - next topic

Ragnar

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.

pylon

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.

Ragnar

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?

strykeroz


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 http://arduino.cc/playground/Code/AvailableMemory 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  :) 
Geoff
"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

Ragnar

Now I got my Attiny and looks like it doesn't support TimerOne library. :(
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.

pylon

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.

Ragnar

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.

pylon

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.

Ragnar

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.

pylon

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.

Ragnar

If I try to compile Adafruit WS2801 library example strandtest, I get multiple errors.
Code: [Select]
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

pylon

In my version of strandtest it just says:

Code: [Select]
#include "WS2801.h"

You might have got an old version?

Ragnar

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

pylon

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.

Ragnar

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.

Go Up