Introduction: Arduino Nano: Rotary Encoder With Visuino

The Rotary encoders are very useful precise rotation sensors, also often used as user controlled input devices instead of potentiometers. They are easy to connect to Arduino, and with the help of Visuino - an easy to use graphical development environment for Arduino, they are equally easy to program.

Step 1: Components

Picture of Components
  1. One Arduino compatible board (I use Arduino Nano, because I have one, but any other will be just fine)
  2. One Rotary Encoder module I got from this cheap 37 sensors set.
  3. 4 Female-Female jumper wires

Step 2: Connect the Rotary Encoder to Arduino

Picture of Connect the Rotary Encoder to Arduino
  1. Connect Ground(Black wire), Power(Red wire), Direction(Brown wire), and Clock(White wire) to the Rotary Encoder Module (Picture 1)
  2. Connect the other end of the Power wire(Red wire) to the 5V power pin of the Arduino board(Picture 2)
  3. Connect the other end of the Ground wire(Black wire) to Ground pin of the Arduino board(Picture 2)
  4. Connect the Clock wire(White wire) to Digital pin 2 of the Arduino board(Picture 3)
  5. Connect the Direction wire(Brown wire) to Digital pin 3 of the Arduino board(Picture 3)
  6. Picture 4 shows where are the Ground, 5V Power, Digital 2 and Digital 3 pins of the Arduino Nano.

Step 3: Start Visuino, and Select the Arduino Board Type

Picture of Start Visuino, and Select the Arduino Board Type

To start programming the Arduino, you will need to have the Arduino IDE installed from here: http://www.arduino.cc/ .

Make sure that you install 1.6.7 or higher, otherwise this Instructable will not work!

The Visuino: https://www.visuino.com also needs to be installed.

  1. Start Visuino as shown in the first picture
  2. Click on the "Tools" button on the Arduino component (Picture 1) in Visuino
  3. When the dialog appears, select Arduino Nano as shown in Picture 2

Step 4: In Visuino: Add and Connect Rotary Encoder Component

Picture of In Visuino: Add and Connect Rotary Encoder Component
  1. Type "rota" in the Filter box of the Component Toolbox then select the "Rotary Encoder Sensor" component (Picture 1), and drop it in the design area
  2. Connect the "Out" pin of the Digital[ 2 ] channel of the Arduino component to the "Clock(A)" pin of the RotaryEncoderSensor1 (Picture 2)
  3. Connect the "Out" pin of the Digital[ 3 ] channel of the Arduino component to the "Direction(B)" pin of the RotaryEncoderSensor1 (Picture 3)

Step 5: In Visuino: Add and Connect Up/Down Counter Component

Picture of In Visuino: Add and Connect Up/Down Counter Component
  1. Type "coun" in the Filter box of the Component Toolbox then select the "Up/Down Counter" component (Picture 1), and drop it in the design area
  2. Connect the "Up" pin of the RotaryEncoderSensor1 component to the "Up" pin of the UpDownCounter1 component (Picture 2)
  3. Connect the "Down" pin of the RotaryEncoderSensor1 component to the "Down" pin of the UpDownCounter1 component (Picture 3)
  4. Connect the "Out" pin of the UpDownCounter1 component to the "In" input pin of the Serial[ 0 ] channel of the Arduino component(Picture 4)

Step 6: Generate, Compile, and Upload the Arduino Code

Picture of Generate, Compile, and Upload the Arduino Code
  1. In Visuino, Press F9 or click on the button shown on Picture 1 to generate the Arduino code, and open the Arduino IDE
  2. In the Arduino IDE, click on the Upload button, to compile and upload the code (Picture 2)

Step 7: And Play...

Picture of And Play...

Picture 1 shows the completed and running project.

If you connect to the Arduino with Serial Terminal from the Arduino IDE or Visuino and then rotate the encoder back and forth, you will see in the terminal the value of the counter showing the encoder changes (Picture 2)

On Picture 3 you can see the complete Visuino diagram.

Congratulations! You have learned how to connect Rotary Encoder to Arduino, and how to read it.

Also attached is the Visuino project, that I created for this Instructable. You can download and open it in Visuino: https://www.visuino.com

Comments

KurtRoesener made it! (author)2015-12-20

I just made this and it worked Great!

BoianM (author)KurtRoesener2015-12-20

Cool! Enjoy :-)

pramodmaster (author)BoianM2017-08-28

dear i am from india and i want to conect a stepper with homing switch sensor and run it in a range with display on nextion and control with two push buutons on nextion with travel distance reading pl help me it is urgent i have purchased a copy of visuino thank you

BoianM (author)pramodmaster2017-08-28

Thank you! Please contact me directly so I can help. I am not sure I understand all the details of what you need. My e-mail is mitov @ mitov.com, and I can send you Skype contact there ;-)

SimonM83 (author)2016-03-28

And here's a way of doing it without the need for Visuino, just the regular Arduino IDE. Hope it's helpful:

https://www.instructables.com/id/Improved-Arduino-Rotary-Encoder-Reading

Peter.Steele (author)SimonM832017-06-26

You do realize that the guy that posted this is the developer of Visuino, right? And that the point of this Instructable was to demonstrate the use of his software?

BoianM (author)Peter.Steele2017-06-26

No harm in him showing his project :-) . Actually without Visuino Rotary Encoder is not that trivial, so his project only highlights the advantage of Visuino ;-)

About This Instructable

4,246views

18favorites

License:

More by BoianM:Program Arduino UNO With Visuino to Draw on ILI9341 TFT Touchscreen Display Shield With PenAssemble Kuman Wi-Fi Robot With Camera and ManipulatorArduino and Visuino: Long Distance Remote Light Sensor With RFM95W/RFM98W Makerfabs LoRa Shields
Add instructable to: