Grove-Encoder
This module is an incremental rotary encoder. It encodes the rotation signal from the axis and output the signal by electronic pulse. The Grove – Encoder is one of the Grove series and has a standard Grove interface. When you need to add a rotary knob to your project, for example a volume knob for a speaker, a selection panel or a digital input, this will be your first choice.
Features
- Incremental encoder.
- Grove Interface.
- 360 degree rotary.
Specification
Item | Min | Typical | Max | Unit |
---|---|---|---|---|
Voltage | 4.5 | 5 | 5.5 | V |
Current | 10 | 20 | 30 | mA |
Dimension | 20x 20 | mm | ||
Net Weight | 12 | g |
Platforms Supported
Arduino | Raspberry Pi |
---|---|
caution
The platforms mentioned above as supported is/are an indication of the module's software or theoritical compatibility. We only provide software library or code examples for Arduino platform in most cases. It is not possible to provide software library / demo code for all possible MCU platforms. Hence, users have to write their own software library.
Getting Started
note
If this is the first time you work with Arduino, we firmly recommend you to see [Getting Started with Arduino](https://wiki.seeedstudio.com/Getting_Started_with_Arduino/) before the start.
Play With Arduino
Hardware
- Step 1. Prepare the below stuffs:
Seeeduino V4.2 | Base Shield | Grove - Circular LED | Grove - Encoder |
---|---|---|---|
Get One Now | Get One Now | Get One Now | Get One Now |
- Step 2. Connect Grove-Encoder to port D2 of Grove-Base Shield.
- Step 3. Connect Grove-Circular LED to port D5 of Grove-Base Shield.
- Step 4. Plug Grove-Base Shield into Seeeduino.
- Step 5. Connect Seeeduino to PC via a USB cable.
note
If we don't have Grove Base Shield, We also can directly connect Grove-Encoder and Connect Grove-Circular LED to Seeeduino as below.
Seeeduino | Grove-Encoder |
---|---|
5V | Red |
GND | Black |
D3 | White |
D2 | Yellow |
Seeeduino | Grove-Circular LED |
---|---|
5V | Red |
GND | Black |
D6 | White |
D5 | Yellow |
note
If you want to change to other port for Grove-Encoder, please change the digitalRead(2) and digitalRead(3) in Encoder.cpp.
Software
- Step 1. Download the Encoder Library, CircularLED Library, TimerOne Library from Github.
- Step 2. Refer How to install library to install library for Arduino.
- Step 3. Copy the code into Arduino IDE and upload. If you do not know how to upload the code, please check how to upload code.
#include <CircularLED.h>
#include <Encoder.h>
#include <TimerOne.h>
CircularLED circularLED(6,5);
unsigned int LED[24];
int index_LED;
void setup()
{
encoder.Timer_init();
}
void loop()
{
if (encoder.rotate_flag ==1)
{
if (encoder.direct==1)
{
index_LED++;
if (index_LED>23)
index_LED=24;
SenttocircularBar(index_LED);
}
else
{
index_LED--;
if(index_LED<0)
index_LED=0;
SenttocircularBar(index_LED);
}
encoder.rotate_flag =0;
}
}
void SenttocircularBar(int index)
{
for (int i=0;i<24;i++)
{
if (i<index)
{
LED[i]=0xff;
}
else
LED[i]=0;
}
circularLED.CircularLEDWrite(LED);
}
- Step 4. The light will be changed as encoder rotating as below.
note
It is able to generate another signal when it’s being pressed down. However due to the limitation of the number of Grove signal cable, the module is made without output of this signal.
Schematic Online Viewer
Resources
- [Eagle] Grove-Encoder Eagle files
- [Library] TimeOne Library
- [Library] Encoder Library
- [Library] CircularLED Library
- [Demo] Demo in Arduino forum
Tech Support
Please do not hesitate to submit the issue into our forum.