#include <SimpleRotary.h>
#include <Mouse.h>
// soldered my scrollwheel to pins 6 and 7. so fill in the pins that you connected your scrollwheel to. if you have a button asw fill // in the pin you connected that to in the last field, but since I have no middle mouse click connected I left it at 0.
SimpleRotary rotary(6,7,0);

void setup() {
  // startup the mouse code
Mouse.begin();
}

void loop() {
  // put your main code here, to run repeatedly:
  byte i;
  i = rotary.rotate();
  
  // CW rotation
  if ( i == 1 ) {
  // if you want to check if your scrollwheel works you can fill in the following code: (otherwise you can just delete it to clean things up)
 // Serial.print("CCW");
 // Serial.print("\t");
 // Serial.println(i);
 // Mouse.move() let's us either move the x/y-axis or the mouse wheel (which is the third one). in this code if the i is the same as 1 // it'll tell the virtual mouse to scroll up 1 whatever they use to measure this.
    Mouse.move(0,0,1);
    // turns clockwise
  }
  
  // CCW rotation
  if ( i == 2 ) {
// if you want to check if your scrollwheel works you can fill in the following code: (otherwise you can just delete it to clean things up)
 // Serial.print("CCW");
 // Serial.print("\t");
 // Serial.println(i);
 // exact same as before but the other way around
    Mouse.move(0,0,-1);
    // turns counter clock wise
  }
}
