跳到主要内容

Grove-Encoder

pir

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.

pir

Features

  • Incremental encoder.
  • Grove Interface.
  • 360 degree rotary.

Specification

ItemMinTypicalMaxUnit
Voltage4.555.5V
Current102030mA
Dimension20x 20mm
Net Weight12g

Platforms Supported

ArduinoRaspberry Pi

pir

pir

警告
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

备注
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.2Base ShieldGrove - Circular LEDGrove - Encoder

pir

pir

pir

pir

Get One NowGet One NowGet One NowGet 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.

pir

备注
If we don't have Grove Base Shield, We also can directly connect Grove-Encoder and Connect Grove-Circular LED to Seeeduino as below.
SeeeduinoGrove-Encoder
5VRed
GNDBlack
D3White
D2Yellow
SeeeduinoGrove-Circular LED
5VRed
GNDBlack
D6White
D5Yellow
备注
If you want to change to other port for Grove-Encoder, please change the digitalRead(2) and digitalRead(3) in Encoder.cpp.

Software

#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.

pir

备注
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

Tech Support

Please do not hesitate to submit the issue into our forum.


Loading Comments...