Pages: [1]   Go Down
Author Topic: Error with ATtiny85 and servo  (Read 414 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 88
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am making Power Laces from Back To The Future, and I was about to program am atiny85 when I got a bunch of error messages for my code. I tried doing it with the attiny servo libraries and such, but I was unsuccessful. It worked fine with an Uno, but when I try uploading it to the attiny, it doesn't work. The same error pops up for any code that uses servos.
The error says that TCCR1A, TCCR1B, TIFR1, and TIMSK1 were not declared in the scope.
I am using Arduino 1.0.4, though it didn't work with 1.0.3 either.
Any help would be great.


Code:
int fsrReading;
#include <Servo.h>
Servo my;
const int buttonPin = 1;
const int pos = 20;

int buttonstate = 0;
 
void setup(void) {

  my.attach(0);
  my.write(180);
  pinMode(buttonPin, INPUT);
}
 
void loop(void) {
  fsrReading = analogRead(A1);


  buttonstate = digitalRead(buttonPin);
 
 
  if (fsrReading > 290) {
    my.write(0);
   
 
  } else{
    if (buttonstate == HIGH) {
      my.write(180);
     
   
 
  }
 }
}
   
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4335
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It would seem that those registers do not exist on the ATtiny85
http://forum.arduino.cc/index.php?topic=90303.0

I presume that they are used by the Servo library.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Denmark
Offline Offline
Edison Member
*
Karma: 36
Posts: 1084
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Try this servo lib, it is made for the ATtiny85

http://www.cunningturtle.com/attiny4585-servo-library/
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 88
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try this servo lib, it is made for the ATtiny85

http://www.cunningturtle.com/attiny4585-servo-library/

I tried doing that, but nothing works. I'm still getting the same errors even with that library.
If also tried it with the SoftwareServo library as well, but i get the same errors.
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 36
Posts: 1084
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Try the test sketch below, it compiles and works on my ATtiny85

I am using this core:

 code.google.com/p/arduino-tiny/

Code:
// Servo8Bit Example code
// Ilya Brutman

#include "Servo8Bit.h"

Servo8Bit myServo;  //create a servo object.


void setup()
{
  
                        

    myServo.attach(1);  //attach the servo to pin PB3

                        //a maximum of five servo objects can be created

    myServo.write(0);   //rotate to the 0 degree position
    delay(2000);        //wait 2 seconds

    myServo.write(180); //rotate to the 180 degree position
    delay(2000);        //wait 2 seconds

    myServo.write(90);  //rotate to the center (90 degree) position
    delay(2000);        //wait 2 seconds

}
    //sweep the servo
   void loop()
    {
        for(int pos = 0; pos < 180; pos++)  // goes from 0 degrees to 180 degrees
        {                                   // in steps of 1 degree
            myServo.write(pos);             // tell servo to go to position in variable 'pos'
            delay(100);                      // waits 15ms for the servo to reach the position
        }

        for(int pos = 180; pos > 1; pos--)  // goes from 180 degrees to 0 degrees
        {
            myServo.write(pos);             // tell servo to go to position in variable 'pos'
            delay(100);                      // waits 15ms for the servo to reach the position
        }
    }

Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 88
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



This seems to work, though I am not sure If two AA batteries is enough power, because it is very slow when it changes positions, I'll have to investigate, but it does work. Thank you for the core and everything!  It's quite possible you saved my project.
« Last Edit: May 16, 2013, 04:55:48 pm by WireJunky » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 88
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Now I'm facing a rather odd problem:
I am uploading to the attiny85, but it doesn't seem to upload.
I put it back on the breadboard, and it still has the sweep code on it.
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 36
Posts: 1084
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm afraid I don't understand the question.

Quote
I am uploading to the attiny85, but it doesn't seem to upload.

Where are the tiny placed when not uploading?
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 88
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm afraid I don't understand the question.

Quote
I am uploading to the attiny85, but it doesn't seem to upload.

Where are the tiny placed when not uploading?

I'll rephrase that.
I programmed the attiny with the swep code, I put it in my circuit, it works, but then I go to upload another code and put it in a different circuit, but it still does the sweep code. It's like the sweep code is stuck on the attiny.
Logged

Pages: [1]   Go Up
Jump to: