I am using an Attiny85 chip, trying to make a simple program on it, and I tested the blink example to see if the Servo8Bitmaster library was causing the trouble.
Without the library, the blink runs fine.
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 0;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
But add the library, nothing happens.
#include <Servo8Bit.h>
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 0;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Any ideas as to why this happens?
I'm starting to think this library is the source of all of my servo-related issues with the attiny.
I don't know how the timers work on that chip, but different versions of that Servo8bit library default to different timers and the default can also be overridden by modifying the .cpp file. Just including the header file in your sketch would cause the implementation .cpp file to be linked in which would cause an ISR to be registered with the relevant timer, so if there's a problem with it then it's entirely plausible that just including the header file would be enough to provoke it. Do you know which version you're using, and which timer it's using?
I'm not sure what version I'm using (nor the timer), only that it's from this (» ATtiny45/85 Servo Library Cunning Turtle) site.
I'm not sure if there's a better library out there, so I'm kind of stuck.
WireJunky:
I'm not sure what version I'm using (nor the timer),
Since you didn't say which version you were using I googled the library name and took my chances. The source I found included a change log that explained about the updated timer support. This feels like the sort of thing that could definitely affect behaviour of the board at the fundamental level if the servo library pre-empts a timer that the Arduino wanted to use e.g. to update its internal times as used for delay() etc.
I was able to look at the comments of the library's page, and two people (one being the library's creator) were able to produce nearly the same results. The creator said on the 24th that he'd have to take a while to debug it, so I guess all I can do is wait.
The ATtiny85 processor has two timers. The core (whichever core you are using) uses one timer for millis / micros and leaves the other timer alone. The Servo8Bit library also uses one timer and leaves the other timer alone. In your case, both the core and the Servo8Bit library are trying to use timer 1 (the second timer). You need to change the library or the core to use timer 0 instead.
This is the relevant code in the Servo8Bit library...
...
//Options
//pick one, comment out the other one out:
//#define USE_TIMER0
#define USE_TIMER1
...
The comment in the header file states, "pick one, comment out the other one out". Implying that you should only be modifying the two lines (#52 and #53) in the header file.
From the snippet you posted it appears you modified the wrong thing.
//Options
//pick one, comment out the other one out:
#define USE_TIMER0
//#define USE_TIMER1
Still no luck.
I'm not sure if this would have anything to do with it, but I'm modifying it in Microsoft Word. When I open it up in word, it makes a temporary file in the folder that also shows up when I include the library in my code (#include <~$rvo8Bit.h>). If I try to use this one, I get an error having to do with 'size_t'.
Should I modify it with a different program?
Use a simple text editor such as notepad rather than a word processor. With notepad you can be sure you're saving a simple plain ascii text file and not any more complex encoding scheme.
Would it be a problem with the library or core itself? I do recall the creator of the library saying there was a problem with it, so maybe I just have to be patient.
It's conceivable that you have now got a messed-up copy of the file due to having edited it in Word previously. I suggest you make sure you're starting from a clean copy.
Started with a fresh copy and edited it, but I do have one question, that might be the reason I'm having trouble. The new servo library is in the folder with the rest of the libraries, but I have another version of that under the 'contributed' section when I got to import a library, but if I import one, it seems to import the same library. Could that be the cause?