kidsbits blocks coding Rotary Encoder module is fully compatible with kidsbits control board and Lego building blocks.
You can easily connect it to kidsbits control board for communication using an RJ11 cable without worrying about wrong connection and damage.
The rotary encoder module can count the pulse outputting times during the process of rotation in positive and reverse direction by rotating.
This rotating counting is unlimited, not like potential counting. It can be restored to initial state to count from 0.
In the following section, we are going to introduce how to use the rotary encoder module with the dual LED module.
2. Technical Parameters
- Interface: EASY plug
- Operating voltage: DC 5V
3. Wiring Diagram
4. Import kidsbits library
Begin with the Mixly blocks coding, you should first import the corresponding kidsbits library for those sensor modules.
Connect the control board to your computer using a USB cable.
Then open the Mixly blocks software 0.998, set the board to UNO R3, select your correct COM port. On the upper right corner you can switch the language.
After that, click Import, import the keyes-kidsbits library. Shown below.
If import custom library successfully, you should see the sensor module library shown below.
Click on the special module block of keyes_kidsbits, you can directly use the corresponding module.
5. Test Code
Open the code folder we provided, or you are able to directly drag the code to Mixly window.
You can click the Code to check the C language.
6. Code Explanation
Adding code library:
Before compiling the program, check out the C language code, you can see that the software needs to call the libraries PinChangeInt.h
If fail to compile the code, note that you should follow the method below to add the libraries into Arduino libraries folder.
First step should open the Mixly software package, you will see an Arduino IDE 1.8.5 software. Shown below.
Then open the IDE software, find the libraries folder.
Do remember to copy and paste the library folder into Arduino libraries directory.
Libraries added successfully, restart the Mixly software. The library can take effect.
7. Test Result
Upload the code success, open the monitor and set the baud rate to 9600. You should see the pulse value output from the rotary encoder.
Turning the rotary encoder, when the absolute value of the data is an even number, dual LED will turn on red; if it is an odd number, turn on green light.
When press the encoder button, the D13 led on the control box will turn on; or else turn off.