Go Down

Topic: Error with ATtiny85 and servo (Read 468 times) previous topic - next topic

WireJunky

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: [Select]

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);
     
   

  }
}
}
   

UKHeliBob

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.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Erni

Try this servo lib, it is made for the ATtiny85

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

WireJunky


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.

Erni

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

I am using this core:

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

Code: [Select]
// 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
       }
   }


WireJunky

#5
May 16, 2013, 11:28 pm Last Edit: May 16, 2013, 11:55 pm by WireJunky Reason: 1


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.

WireJunky

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.

Erni

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?

WireJunky


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.

Go Up