Code not working with ATTINY 85

I have successfully used this code on the Uno board to control a LED and latching relay. I adjusted the pins for an attiny85. The programming is working correctly for a blink sketch but when I upload the following code it does not work properly. I’m new to arduino and uploading to the attinys so I’m not sure that all the code is supported by the attiny85. For right now the switch is using an external pull up. Any help is much appreciated!

/*  Alternating LED  & Relay  */
#include <Bounce.h>

const int inputPin = 0;    // momentary switch
const int ledPin =  4;      // the number of the LED pin
const int relayPin1 =  2;
const int relayPin2 = 3;

byte mode = 0;

Bounce bouncer = Bounce(inputPin,75);   //settup debounce for first push button

void setup() 
  pinMode(inputPin, INPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(relayPin1, OUTPUT);
  pinMode(relayPin2, OUTPUT);

void loop() {
  bouncer.update ( );    // Update the debouncer for the push button
  switch( mode )
    case 0://------------------------ I'm off and in restmode
      if ( == HIGH )
        digitalWrite (ledPin, HIGH);  // switch LED ON
        digitalWrite (relayPin2, LOW);  // switch relay ON
        digitalWrite (relayPin1, HIGH);  // switch relay ON
        delay (30);
        digitalWrite (relayPin1, LOW);
        mode = 1;
    case 1://------------------------ I'm in ON mode, w8 4 keyrelease
      if ( == LOW )
        mode = 2;
    case 2://------------------------ I'm ON and in restmode
      if ( == HIGH )
        digitalWrite (relayPin1, LOW);  // switch relay OFF
        digitalWrite (relayPin2, HIGH);  // switch relay OFF
        digitalWrite (ledPin, LOW);  // switch LED OFF
        delay (30);
        digitalWrite (relayPin2, LOW);
        mode = 3;
    case 3://------------------------ I'm in OFF mode, w8 4 keyrelease
      if ( == LOW )
        mode = 0;



What exactly does it do on the ATTiny? Also could you post a photo of your circuit so we can verify your connections?


One thing that could make it

not work properly

is the timing. The bounce library use millis(), and if you choose for example the board: Attiny85@8MHZ without setting the right fuses, the timing will be off by a factor 8.

The factory default is 1MHz, so unless you have set the fuses yourself you should choose Attiny85@1MHZ

If you want to run 8MHz, do this:

Select Board -> Attiny85@8MHZ select Programmer -> Arduino as ISP (or watever programmer you are using) Select ->Burn bootloader

I'm not sure that all the code is supported by the attiny85

It is

Thanks everyone for the help!

I got it working properly. I had the program set to 8MHz and the attiny was at 1MHz :blush:

I also was accidentally pulling down the reset pin, because I had the LED and CLR on the wrong pin.

Thanks again!

Karma Bump!