Can not upload code to ATTiny85. Please help

I am trying to upload this cose to my ATTiny85 but keep getting the error: error compiling for board ATTiny

 #include <Servo.h>

// Set digital pin numbers:
const int servoPin = 10;  // The number of the Servo pin

const int buttonPin = 9;  // The number of the Pushbutton pin
int buttonState = 0;  // Variable for reading the pushbutton status
int directionState = 0;  // Variable for reading direction of the servo

Servo myservo;  // Create servo object to control a servo

int pos = 0;  // Variable to store the servo position


void setup() {
  myservo.attach(10);  // attaches the servo on pin 8 to the servo object
  pinMode(buttonPin, INPUT);  // initialize the pushbutton pin as an input
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  if (directionState == 0) {
    //The button is pushed
    if (buttonState == HIGH) {
      directionState = 1;// The direction for the servo is clockwise

      // goes from 0 degrees to 90 degrees in steps of 1 degree
      for (pos = 2; pos < 92; pos = pos + 1)
      {
        myservo.write(pos);  // tell servo to go to position in variable ‘pos’
        delay(15);  // waits 15ms for the servo to reach the position
      }
    }

  } else if (directionState == 1) {
    // The button is pushed
    if (buttonState == HIGH) {
      directionState = 0;  // The direction for the servo is anti-clockwise

      // goes from 90 degrees to 0 degrees in steps of 1 degree
      for (pos = 92; pos >= 2; pos = pos - 1)
      {

        myservo.write(pos);  // tell servo to go to position in variable ‘pos’
        delay(15);  // waits 15ms for the servo to reach the position
      }
    }
  }
}

Please post ALL of the messages. There should be more.

Here is the Error.

Arduino: 1.8.1 (Windows 10), Board: "ATtiny x5, ATtiny85 @ 8 MHz  (internal oscillator; BOD disabled)"

WARNING: Category '' in library EEPROM is not valid. Setting to 'Uncategorized'
WARNING: Category '' in library SoftwareSerial is not valid. Setting to 'Uncategorized'
Warning: platform.txt from core 'Arduino AVR Boards' contains deprecated compiler.path={runtime.ide.path}/hardware/tools/avr/bin/, automatically converted to compiler.path={runtime.tools.avr-gcc.path}/bin/. Consider upgrading this core.
Warning: platform.txt from core 'Arduino AVR Boards' contains deprecated tools.avrdude.cmd.path={runtime.ide.path}/hardware/tools/avr/bin/avrdude, automatically converted to tools.avrdude.cmd.path={path}/bin/avrdude. Consider upgrading this core.
Warning: platform.txt from core 'Arduino AVR Boards' contains deprecated tools.avrdude.config.path={runtime.ide.path}/hardware/tools/avr/etc/avrdude.conf, automatically converted to tools.avrdude.config.path={path}/etc/avrdude.conf. Consider upgrading this core.
Warning: platform.txt from core 'Arduino AVR Boards' contains deprecated recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}", automatically converted to recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}". Consider upgrading this core.
C:\Program Files (x86)\Arduino\libraries\Servo\src\avr\Servo.cpp: In function 'void __vector_3()':

C:\Program Files (x86)\Arduino\libraries\Servo\src\avr\Servo.cpp:82:44: error: cannot convert 'volatile uint8_t* {aka volatile unsigned char*}' to 'volatile uint16_t* {aka volatile unsigned int*}' for argument '2' to 'void handle_interrupts(timer16_Sequence_t, volatile uint16_t*, volatile uint16_t*)'

   handle_interrupts(_timer1, &TCNT1, &OCR1A);

                                            ^

C:\Program Files (x86)\Arduino\libraries\Servo\src\avr\Servo.cpp: In function 'void initISR(timer16_Sequence_t)':

C:\Program Files (x86)\Arduino\libraries\Servo\src\avr\Servo.cpp:128:5: error: 'TCCR1A' was not declared in this scope

     TCCR1A = 0;             // normal counting mode

     ^

C:\Program Files (x86)\Arduino\libraries\Servo\src\avr\Servo.cpp:129:5: error: 'TCCR1B' was not declared in this scope

     TCCR1B = _BV(CS11);     // set prescaler of 8

     ^

C:\Program Files (x86)\Arduino\libraries\Servo\src\avr\Servo.cpp:136:5: error: 'TIFR1' was not declared in this scope

     TIFR1 |= _BV(OCF1A);     // clear any pending interrupts;

     ^

C:\Program Files (x86)\Arduino\libraries\Servo\src\avr\Servo.cpp:137:5: error: 'TIMSK1' was not declared in this scope

     TIMSK1 |=  _BV(OCIE1A) ; // enable the output compare interrupt

     ^

exit status 1
Error compiling for board ATtiny x5.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

The stock Servo library doesn't support the tiny85. The x5 series has that weirdo high-speed timer for timer1 instead of the usual 16-bit one, so it needs special treatment, which hasn't been done in the basic Servo library.

I have used TinyServo library
with ATTinyCore on ATtiny45 and 85 with good results (Arduino IDE 1.6.5r5).

BTW:

const int servoPin = 10;  // The number of the Servo pin
const int buttonPin = 9;  // The number of the Pushbutton pin

This may not work with ATtiny85.
Pin numbers are 0...4 (with most cores).

im still having troubles with this not too sure if i am over looking something. here is my most recent error.

Arduino: 1.8.1 (Windows 10), Board: "ATtiny x5, ATtiny85 @ 8 MHz  (internal oscillator; BOD disabled)"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Mendez\AppData\Local\Arduino15\packages -hardware C:\Users\Mendez\Documents\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Mendez\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Mendez\Documents\Arduino\libraries -fqbn=tiny:avr:tinyx5:cpu=attiny85at8 -ide-version=10801 -build-path C:\Users\Mendez\AppData\Local\Temp\arduino_build_64285 -warnings=none -prefs=build.warn_data_percentage=75 -verbose C:\Users\Mendez\Documents\Arduino\Rangefinder\Rangefinder.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Mendez\AppData\Local\Arduino15\packages -hardware C:\Users\Mendez\Documents\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Mendez\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Mendez\Documents\Arduino\libraries -fqbn=tiny:avr:tinyx5:cpu=attiny85at8 -ide-version=10801 -build-path C:\Users\Mendez\AppData\Local\Temp\arduino_build_64285 -warnings=none -prefs=build.warn_data_percentage=75 -verbose C:\Users\Mendez\Documents\Arduino\Rangefinder\Rangefinder.ino
Using board 'tinyx5' from platform in folder: C:\Users\Mendez\Documents\Arduino\hardware\tiny\avr
Using core 'tiny' from platform in folder: C:\Users\Mendez\Documents\Arduino\hardware\tiny\avr
Warning: platform.txt from core 'Arduino AVR Boards' contains deprecated compiler.path={runtime.ide.path}/hardware/tools/avr/bin/, automatically converted to compiler.path={runtime.tools.avr-gcc.path}/bin/. Consider upgrading this core.
Warning: platform.txt from core 'Arduino AVR Boards' contains deprecated tools.avrdude.cmd.path={runtime.ide.path}/hardware/tools/avr/bin/avrdude, automatically converted to tools.avrdude.cmd.path={path}/bin/avrdude. Consider upgrading this core.
Warning: platform.txt from core 'Arduino AVR Boards' contains deprecated tools.avrdude.config.path={runtime.ide.path}/hardware/tools/avr/etc/avrdude.conf, automatically converted to tools.avrdude.config.path={path}/etc/avrdude.conf. Consider upgrading this core.
Warning: platform.txt from core 'Arduino AVR Boards' contains deprecated recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}", automatically converted to recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}". Consider upgrading this core.
Detecting libraries used...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections  -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=8000000L -DARDUINO=10801 -DARDUINO_AVR_TINYX5 -DARDUINO_ARCH_AVR   "-IC:\Users\Mendez\Documents\Arduino\hardware\tiny\avr\cores\tiny" "C:\Users\Mendez\AppData\Local\Temp\arduino_build_64285\sketch\Rangefinder.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections  -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=8000000L -DARDUINO=10801 -DARDUINO_AVR_TINYX5 -DARDUINO_ARCH_AVR   "-IC:\Users\Mendez\Documents\Arduino\hardware\tiny\avr\cores\tiny" "-IC:\Program Files (x86)\Arduino\libraries\Servo\src" "C:\Users\Mendez\AppData\Local\Temp\arduino_build_64285\sketch\Rangefinder.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections  -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=8000000L -DARDUINO=10801 -DARDUINO_AVR_TINYX5 -DARDUINO_ARCH_AVR   "-IC:\Users\Mendez\Documents\Arduino\hardware\tiny\avr\cores\tiny" "-IC:\Program Files (x86)\Arduino\libraries\Servo\src" "C:\Program Files (x86)\Arduino\libraries\Servo\src\avr\Servo.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections  -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=8000000L -DARDUINO=10801 -DARDUINO_AVR_TINYX5 -DARDUINO_ARCH_AVR   "-IC:\Users\Mendez\Documents\Arduino\hardware\tiny\avr\cores\tiny" "-IC:\Program Files (x86)\Arduino\libraries\Servo\src" "C:\Program Files (x86)\Arduino\libraries\Servo\src\sam\Servo.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections  -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=8000000L -DARDUINO=10801 -DARDUINO_AVR_TINYX5 -DARDUINO_ARCH_AVR   "-IC:\Users\Mendez\Documents\Arduino\hardware\tiny\avr\cores\tiny" "-IC:\Program Files (x86)\Arduino\libraries\Servo\src" "C:\Program Files (x86)\Arduino\libraries\Servo\src\samd\Servo.cpp" -o "nul"
Generating function prototypes...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections  -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=8000000L -DARDUINO=10801 -DARDUINO_AVR_TINYX5 -DARDUINO_ARCH_AVR   "-IC:\Users\Mendez\Documents\Arduino\hardware\tiny\avr\cores\tiny" "-IC:\Program Files (x86)\Arduino\libraries\Servo\src" "C:\Users\Mendez\AppData\Local\Temp\arduino_build_64285\sketch\Rangefinder.ino.cpp" -o "C:\Users\Mendez\AppData\Local\Temp\arduino_build_64285\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\Mendez\AppData\Local\Temp\arduino_build_64285\preproc\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=attiny85 -DF_CPU=8000000L -DARDUINO=10801 -DARDUINO_AVR_TINYX5 -DARDUINO_ARCH_AVR   "-IC:\Users\Mendez\Documents\Arduino\hardware\tiny\avr\cores\tiny" "-IC:\Program Files (x86)\Arduino\libraries\Servo\src" "C:\Users\Mendez\AppData\Local\Temp\arduino_build_64285\sketch\Rangefinder.ino.cpp" -o "C:\Users\Mendez\AppData\Local\Temp\arduino_build_64285\sketch\Rangefinder.ino.cpp.o"
Compiling libraries...
Compiling library "Servo"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=attiny85 -DF_CPU=8000000L -DARDUINO=10801 -DARDUINO_AVR_TINYX5 -DARDUINO_ARCH_AVR   "-IC:\Users\Mendez\Documents\Arduino\hardware\tiny\avr\cores\tiny" "-IC:\Program Files (x86)\Arduino\libraries\Servo\src" "C:\Program Files (x86)\Arduino\libraries\Servo\src\avr\Servo.cpp" -o "C:\Users\Mendez\AppData\Local\Temp\arduino_build_64285\libraries\Servo\avr\Servo.cpp.o"
C:\Program Files (x86)\Arduino\libraries\Servo\src\avr\Servo.cpp: In function 'void __vector_3()':

C:\Program Files (x86)\Arduino\libraries\Servo\src\avr\Servo.cpp:82:44: error: cannot convert 'volatile uint8_t* {aka volatile unsigned char*}' to 'volatile uint16_t* {aka volatile unsigned int*}' for argument '2' to 'void handle_interrupts(timer16_Sequence_t, volatile uint16_t*, volatile uint16_t*)'

   handle_interrupts(_timer1, &TCNT1, &OCR1A);

                                            ^

C:\Program Files (x86)\Arduino\libraries\Servo\src\avr\Servo.cpp: In function 'void initISR(timer16_Sequence_t)':

C:\Program Files (x86)\Arduino\libraries\Servo\src\avr\Servo.cpp:128:5: error: 'TCCR1A' was not declared in this scope

     TCCR1A = 0;             // normal counting mode

     ^

C:\Program Files (x86)\Arduino\libraries\Servo\src\avr\Servo.cpp:129:5: error: 'TCCR1B' was not declared in this scope

     TCCR1B = _BV(CS11);     // set prescaler of 8

     ^

C:\Program Files (x86)\Arduino\libraries\Servo\src\avr\Servo.cpp:136:5: error: 'TIFR1' was not declared in this scope

     TIFR1 |= _BV(OCF1A);     // clear any pending interrupts;

     ^

C:\Program Files (x86)\Arduino\libraries\Servo\src\avr\Servo.cpp:137:5: error: 'TIMSK1' was not declared in this scope

     TIMSK1 |=  _BV(OCIE1A) ; // enable the output compare interrupt

     ^

Using library Servo at version 1.1.2 in folder: C:\Program Files (x86)\Arduino\libraries\Servo 
exit status 1
Error compiling for board ATtiny x5.

You are attempting to compile a sketch using the Servo library on the Tiny85.

This is not supported by the Servo library - as evidenced by the errors you're receiving.

The Servo library attempts to make use of specific hardware functionality (namely, the normal 16-bit timer/counter 1) which the tiny85 doesn't have.

I am sure that someone has made an alternative servo library for the tiny85.

Testing and rigging up a Servo library that works on all the attiny's that my core (note: I am aware that you are using the dmellis core, not my core. My core is way better :wink: ) supports is on my list of things to do (It would be rigged up so you could just use Servo like on other boards and have it work, like you're trying to do - here's the issue: Servo Library support for x61, x5, and other unloved 'tinies · Issue #85 · SpenceKonde/ATTinyCore · GitHub ), but I just haven't had a chance to work on it. I think i basically need to set up a servo testbed (might mean I need to like, buy a servo :frowning: ) and sort through the #define hell in the servo library to make it support the x61 and x5 (they're similar - but not identical. Both have a bizzaro high speed timer for timer1 instead of the normal 16-bit one) and test it out to make sure it works.

Hi,
The solution of using Servo with Attiny x5 (including ATtiny85) is illustated in this link: [Solved]ATtiny 85 and servo library - Motors, Mechanics, Power and CNC - Arduino Forum

// Code Example Postet in the link above

#include <SoftwareServo.h>

SoftwareServo servo;

void setup()
{
 servo.attach(0);}

void loop() {
   int pos;
   for(pos = 0; pos < 180; pos += 1) {
       servo.write(pos);             
       delay(50);                     
       SoftwareServo::refresh();//this row....
   }
   for(pos = 180; pos>=1; pos-=1) {                               
       servo.write(pos);             
       delay(50);                     
       SoftwareServo::refresh();//This row....
   }
}