Medium Basics Project 005d SG90 Micro Servo Motor with RGB LED module, LCD1602 I2C, RFID RC522 and piezo bu

of Acoptex.com in UNO

Basics: Project 005d

Project name: Security system / SG90 Micro Servo Motor with RGB LED module, LCD1602 I2C, RFID RC522 and piezo buzzer.

Attachments: libraries and program, pitches.h

In this project, you needed these parts :

1.Aruduino Uno R3 (you can also use the other version of Arduino)

2.SG90 Micro servo motor 9g

3.Arduino IDE ( you can download it from here  )

4.Jumper cables

5. RGB LED module

6. Resistor 1 pc (150 Om for piezo buzzer/optional/)

7. LCD1602 module

8. RFID RC522 module

9. Piezo buzzer active 1 pc

10. Breadboard

Understanding the servo motors

Servo motors function based on the waves of pulses sent by a command, say from a transmitter, to create a mechanical motion. For example, we use a servo to control steering by adjusting the levers back and forth. We also use a servo to control the speed of the car by connecting it to the engine throttle.

The specification of a servo is normally being set by the turning angle per time at 60 degrees (speed) and the load carrying capacities (torque). There are also weight and dimension in the specifications.

In general, a servo contains a control circuit, DC motor, and potentiometer. The potentiometer is a position sensor that is connected to the output shaft. The shaft is attached to the control wheels by gears and the movement as well as its direction is controlled by an electrical signal.

So, how does the servo work? Well, firstly, there are three wires connected to the servo. One of them is the signal wire. This is the component that is responsible for supplying the electrical pulses. The motor turns to the appropriate direction as commanded by the pulses. When the motor rotates, it changes the resistance of the potentiometer and ultimately allows the control circuit to regulate the amount of movement and direction. When the shaft is at the desired position, the supply power shuts off.

Analog servo motor

An Analog servo motor is the standard type of servo. It regulates the speed of the motor by simply sending on and off pulses. Normally, the pulse voltage is at a range between 4.8 to 6.0 volts and constant while at that. The analog receives 50 pulses for every second and when at rest, there is no voltage sent to it. The longer the “On” pulse is being sent to the servo, the faster the motor spins and the higher the produced torque. One of the major drawbacks of the analog servo is its delay in reacting to small commands. It does not get the motor spinning quickly enough. Plus, it also produces a sluggish torque. This situation is called “deadband.”

Digital servo motor

A Digital Servo has a different way of sending pulse signals to the servo motor. If analog is designed to send a constant 50 pulse voltage per second, the digital RC servo is capable of sending up to 300 pulses per second! With this rapid pulse signals, the speed of the motor will increase significantly, and the torque will be more constant; it decreases the amount of deadband.  As a result, when the digital servo is used, it provides quicker response and faster acceleration to the RC component.

Also, with the fewer deadband, the torque also provides a better holding capability. When you operate using a digital servo, you can experience the immediate feel of the control.

Analog Vs Digital

Let say you are to link a digital and analog servo to a receiver. When you turn the analog servo wheel off-center, you will notice it responds and resists after a while – the delay is noticeable. However, when you turn the wheel of the digital servo off-center, you will feel like the wheel and shaft responds and holds to the position that you set very quickly and smoothly.

Physical wise, there is not much of a difference. Both use three-wire connection system and contain similar inner parts. The only difference is perhaps the digital has a microprocessor that automatically regulates the frequency of the pulses. When we compare the two RC servo motors, the difference is more obvious from the operational perspective. Upon comparison, we have learned that the digital version has several advantages over the analog.

  • Digital servos produce higher speeds and acceleration than analog servo
  • Digital servos have a higher torque and consequently better holding capability

As you can see from above, the digital type has a quicker and smoother output compared to analog. However, there is a little bit of disadvantage that comes with this type of servo – high power consumption. It makes sense because the signals of on/off are being sent more frequently compared to analog. Therefore, it sure has a greater accuracy, but it comes with the cost of power.

If you wish to switch from analog to digital servo for your RC models, we highly advise you to use a capable battery or switch to BEC circuit to power the servo. Once you adjust the battery or circuit to suit the powerful digital servo, the power consumption is no longer an issue.

Plus, the digital servo also comes with a little bit of noise when it is in a neutral mode or not being commanded to move. This is due to the rapid voltage adjustment made inside the motor. Regarding the monetary cost, digital servos are more expensive than the analog models.

In addition to that, the hundreds of voltage pulses sent to the motor can also drain the battery pretty quickly. On another note, you should know that not all digital servos are better than the analog ones. When you compare between the low-spec digital and high-spec analog, the latter might provide better speed and torque.

Tiny and lightweight with high output power. Servo can rotate approximately 180 degrees
(90 in each direction), and works just like the standard kinds but smaller. You can use any
servo code, hardware or library to control these servos. Good for beginners who want to make
stuff move without building a motor controller with feedback & gear box, especially since it
will fit in small places. It comes with a 3 horns (arms) and hardware.

In our project we will use SG90 Mini servo motor, tiny and lightweight with high output power. Servo can rotate approximately 180 degrees(90 in each direction), and works just like the standard kinds but smaller. You can use anyservo code, hardware or library to control these servos. Good for beginners who want to makestuff move without building a motor controller with feedback & gear box, especially since itwill fit in small places. It comes with a 3 horns (arms) and hardware.

See SG90 mini servo specification here

Understanding LCD 1602 module

 See more details here - check this project

Understanding RFID RC522 module

 See more details here.

Understanding the piezo buzzer

Buzzers can be found in alarm devices, computers, timers and confirmation of user input such as a mouse click or keystroke.

Buzzers can be categorized as active buzzers and passive ones.

Place the pins of two buzzers face up and you can see the one with a green circuit board is a passive buzzer, while the other with a black tape, instead of a board, is an active buzzer, as shown below.

An active buzzer has a built-in oscillating source, so it will make sounds when electrified. But a passive buzzer does not have such source, so it will not beep if DC signals are used; instead, you need to use square waves whose frequency is between 2K and 5K to drive it. The active buzzer is often more expensive than the passive one because of multiple built-in oscillating circuits.

See piezo buzzers data sheets here.

Don’t forget to use a current-limiting resistor.

Signals and contacts SG90 mini servo motor, ULN2003 module, LEDs, LCD 1602 module, RFID RC522 module 


Signals and connections of LCD1602 module you can find here.

Signals and connections of RFID RC522 module you can find here.

Signals and connections of active piezo buzzer

Active piezo buzzer pin marked with (+) sign should be connected to Arduino Uno board digital pin which sends a signal, the other pin of active piezo buzzer should be connected to Arduino Uno board GND.


The following table and picture shows the needed connections with Arduino Uno.

The following table and picture shows the needed connections with Chinese Uno.


See the video here: https://youtu.be/sgSjTHCbR34

Step by Step instruction

  1. Plug your Adruino Uno board into your PC and select the correct board and com port
  2. Find your I2C address. Each device has an I2C address that it uses to  accept commands or send messages. Load the sketch over at http://arduino.cc/playground/Main/I2cScanner and follow the instructions to use it.  By opening up the Serial monitor window after you upload the sketch, Arduino will scan the address range looking for a reply.  Even though the documentation said it was 0x27, this scanner can detect different (in my case 0x3F)
  3. Modify the sketch in attachments above (you can use the sketch below too): the line LiquidCrystal_I2C lcd (0x 3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE) (See part marked bold)
  4. Open up serial monitor and set your baud to 9600 baud.
  5. Scan your card, you will see a bunch of numbers pop out.
  6. Copy only the number and paste it to the column after "int cards[][5] = { " - replace with your card number or numbers, space them with ',' for example my cards were: 0 64 134 25 223}. You can add many cards here. 
  7. Verify and upload the the sketch to your Adruino Uno.



  • See attachments on the begining of this project description.
  • pitches.h file contains all the pitch values for typical notes. For example, NOTE_C4 is middle C. NOTE_FS4 is F sharp, and so forth. This note table was originally written by Brett Hagman, on whose work the tone() command was based. You may find it useful for whenever you want to make musical notes.File should be in the same directory with sketch.
  • The Servo, SPI and Wire library included in Adruino IDE program which installed in your PC.
  • You will need to unzip and add the RFID library to libraries in your PC, for example C:\Users\toshiba\Documents\Arduino\libraries
  • I have used the library - NewliquidCrystal_1.3.4.zip which I downloaded, unzipped, changed the name of folder to LiquidCristal and added to libraries, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC.
  • If you have LiquidCristal folder in this location already - delete this folder and copy folder, which was made by you, to this location.



Other projects of Acoptex.com
Easy Basics: Project 101a Ai Thinker A9G GPRS GPS development board of Acoptex.com, Not selected 23-11-2019
Easy Basics: Project 100a Ai Thinker A9 GSM GPRS development board of Acoptex.com, Not selected 22-11-2019

Published at 05-05-2017
Viewed: 2237 times