 //  PWM  (A 6) (D  4)  PA6  7|    |8   PA5  (D  5) (A 5)   PWM
 //                           +----+
 //
+// 8MHz: avrdude -c usbtiny -p attiny84 -U lfuse:w:0xe2:m -U hfuse:w:0xd7:m -U efuse:w:0xff:m
+
 const int speedInPin = A0;
 const int rateOfSpeedChangeInPin = A1;
 const int speedOutPin = 5;
 const int onOffSwitchInPin = 7;
 const int directionSwitchInPin = 8;
-const int directionOutPin = 6;
-
-#elif defined( __AVR_ATtinyX5__ )
-
-// ATMEL ATTINY85 / arduino-tiny mapping
-//                           +-\/-+
-//  Ain0       (D  5)  PB5  1|    |8   VCC
-//  Ain3       (D  3)  PB3  2|    |7   PB2  (D  2)  INT0  Ain1
-//  Ain2       (D  4)  PB4  3|    |6   PB1  (D  1)        pwm1
-//                     GND  4|    |5   PB0  (D  0)        pwm0
-//                           +----+
-//
-// NOTE!!!! This requires use of the RESET pin so either RSTDISBL fuse must be set.
-// 1MHz: avrdude -c usbtiny -p attiny85 -U lfuse:w:0x62:m -U hfuse:w:0x57:m -U efuse:w:0xff:m
-// 8MHz: avrdude -c usbtiny -p attiny85 -U lfuse:w:0xE2:m -U hfuse:w:0x57:m -U efuse:w:0xff:m
-// After this is done the chip cannot be reprogrammed except by the high-voltage method
-
-const int speedInPin = A3;
-const int rateOfSpeedChangeInPin = A0;
-const int speedOutPin = 0;
-const int onOffSwitchInPin = 2;
-const int directionSwitchInPin = 1;
-const int directionOutPin = 4;
-
-#endif
+const int directionOutPin = 3;
+const int rpmInPin = 2;
+// I2C SCL = PA4 (D6)
+// I2C SDA = PA6 (D4)
 
 // Settings and limits
 const int switchDebounceTime = 30;

#include <Bounce.h>
#include <UserTimer.h>

const int CLOCKWISE = 1;
const int COUNTER_CLOCKWISE = 0;

#if defined(__AVR_ATmega328P__)

// Arduino Pins
const int speedInPin = A0;
const int rateOfSpeedChangeInPin = A1;
const int speedOutPin = 9;
const int onOffSwitchInPin = 7;
const int directionSwitchInPin = 6;
const int directionOutPin = 5;

#elif defined( __AVR_ATtinyX4__ )

// ATMEL ATTINY84 / arduino-tiny mapping
//

  
  currentSpeed += SlewToward(currentSpeed, targetSpeed);
  analogWrite(speedOutPin, abs(currentSpeed));           
  
  UpdateRpmDisplay();
  
  // Rather than trying to write a fixed-delay loop we're being lazy and using a
  // variable-deplay loop to control the rate at which we change the motor speed.
