Ano Directional scroll wheel

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
C_Herrmann
 
Posts: 2
Joined: Thu May 19, 2022 1:44 am

Ano Directional scroll wheel

Post by C_Herrmann »

I am having trouble getting the scroll wheel to work. I have tried using an Arduino Uno and Pro Trinket 5v. I don't have a pixel ring, but I do have neopixel strips and sticks. Every other button work they way they are supposed to. I have tried 2 separate ANO scroll pads. I have tried multiple different pins. I've tried ComA and ComB on a low pin and on ground. I am not an expert, and I have reached the end of my knowledge.

Code: Select all

// SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
//
// SPDX-License-Identifier: MIT

#include <Adafruit_NeoPixel.h>
#include <RotaryEncoder.h>

#define PIN_ENCODER_A 8
#define PIN_ENCODER_B 9
//#define COM_A    5
//#define COM_B    SDA
#define BUTTON_UP 10
#define BUTTON_LEFT 11
#define BUTTON_DOWN 3
#define BUTTON_RIGHT 9
#define BUTTON_IN 4

RotaryEncoder encoder(PIN_ENCODER_A, PIN_ENCODER_B, RotaryEncoder::LatchMode::TWO03);
// This interrupt will do our encoder reading/checking!
void checkPosition() {
  encoder.tick(); // just call tick() to check the state.
}
int last_rotary = 0;


#define NUMPIXELS 12
Adafruit_NeoPixel pixels(NUMPIXELS, A0, NEO_GRB + NEO_KHZ800);


void setup(void) {
  Serial.begin(115200);
  while (!Serial);
  Serial.println("ANO Rotary Encoder Demo");
/*
  pinMode(COM_A, OUTPUT);
  digitalWrite(COM_A, LOW);
  pinMode(COM_B, OUTPUT);
  digitalWrite(COM_B, LOW);
*/
  attachInterrupt(digitalPinToInterrupt(PIN_ENCODER_A), checkPosition, CHANGE);
  attachInterrupt(digitalPinToInterrupt(PIN_ENCODER_B), checkPosition, CHANGE);

  pinMode(BUTTON_UP, INPUT_PULLUP);
  pinMode(BUTTON_DOWN, INPUT_PULLUP);
  pinMode(BUTTON_LEFT, INPUT_PULLUP);
  pinMode(BUTTON_RIGHT, INPUT_PULLUP);
  pinMode(BUTTON_IN, INPUT_PULLUP);
  pixels.begin();
  pixels.setBrightness(30);
  pixels.show();
}


void loop(void) {
  // read encoder
  int curr_rotary = encoder.getPosition();
  RotaryEncoder::Direction direction = encoder.getDirection();
  
  pixels.clear();
  if (curr_rotary != last_rotary) {
    Serial.print("Encoder value: ");
    Serial.print(curr_rotary);
    Serial.print(" direction: ");
    Serial.println((int)direction);
  }
  last_rotary = curr_rotary;

  pixels.setPixelColor((curr_rotary + (1000*NUMPIXELS)) % NUMPIXELS, pixels.Color(0, 150, 0));

  if (! digitalRead(BUTTON_UP)) {
    pixels.setPixelColor(0, pixels.Color(150, 0, 0));
  }
  if (! digitalRead(BUTTON_LEFT)) {
    pixels.setPixelColor(NUMPIXELS/4, pixels.Color(150, 0, 0));
  }
  if (! digitalRead(BUTTON_DOWN)) {
    pixels.setPixelColor(NUMPIXELS/2, pixels.Color(150, 0, 0));
  }
  if (! digitalRead(BUTTON_RIGHT)) {
    pixels.setPixelColor(NUMPIXELS*3/4, pixels.Color(150, 0, 0));
  }
  if (! digitalRead(BUTTON_IN)) {
    pixels.fill(pixels.Color(50, 50, 50));
  }
  pixels.show();

  delay(20);
}

I appreciate any help I can get.

User avatar
mikeysklar
 
Posts: 14165
Joined: Mon Aug 01, 2016 8:10 pm

Re: Ano Directional scroll wheel

Post by mikeysklar »

What are you seeing on the serial console when you run the code? There should be Encoder value and direction data being printed out.

Code: Select all

  if (curr_rotary != last_rotary) {
    Serial.print("Encoder value: ");
    Serial.print(curr_rotary);
    Serial.print(" direction: ");
    Serial.println((int)direction);
  }
  last_rotary = curr_rotary;

User avatar
C_Herrmann
 
Posts: 2
Joined: Thu May 19, 2022 1:44 am

Re: Ano Directional scroll wheel

Post by C_Herrmann »

There are no readings. I just get the printed "ANO Rotary Encoder" message.
I figured it must be my wiring, but I've lost count of how many times I checked the pins. I have also downloaded a picture of the pinouts on the encoder to check that side numerous times. I have moved it on my solderless breadboard and tried other projects to test that as well.

User avatar
mikeysklar
 
Posts: 14165
Joined: Mon Aug 01, 2016 8:10 pm

Re: Ano Directional scroll wheel

Post by mikeysklar »

I should mention the easy solution first. Use a Feather M4 as the breakout board was designed to maximize ease of use with that device.

https://www.adafruit.com/product/3857

I suspect the problem you are encountering with the scroll wheel is related to interrupt pins. You could try using the Arduino UNO with the examples from the RotaryEncoder library examples provided:

https://github.com/mathertel/RotaryEnco ... r/examples

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”