Disclosure: Hackr.io is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission.
Cool, Fun and Easy Arduino Projects for Beginners


Table of Contents
If you are into coding and programming hardware, then you must be aware of the popular tool Arduino and hence, that brings you here to brush your skills further on this tool. We stated some of the best Arduino projects that you can begin to code to get the hardware's flavor and add them to your profile.
To make this journey smooth, we begin by explaining what Arduino is and why it is useful. We shall also guide you through how to program Arduino so that beginning any project is hassle-free for you. Trying every project on the list is recommended as it would help you get hold of the concepts as every project would offer something different and new for you to learn.
So let us get started with learning cool, fun, and easy Arduino projects.
What is Arduino?
Arduino is an open-source electronics platform for microcontroller devices that makes embedded programming easier. Arduino was born at the Ivrea Interaction Design, and its hardware boards can read inputs, a finger on a button, turn it into an output, light a sensor, activate an LED, and much more.
The Arduino board is programmed by sending a set of instructions to the microcontroller on the board. The Arduino platform composes of the following:
Arduino Programming and Framework: Arduino uses C/C++ frameworks for ARM, AVR, etcetera.
Device Bootloader: This refers to the program, which is pre-programmed on the hardware microcontrollers. The program offers assistance with the loading of the code from memory on startup. The bootloader also provides the functionality of loading the code on the device using a USB cable.
Arduino IDE: The IDE is a glorified text editor desktop application to write, compile, and load Arduino code.
Next, let us see why you choose Arduino and what it offers.
Why is Arduino Useful?
Arduino has been the brain of thousands of projects over the years. It is used by a vast community comprising students, teachers, scientists, professionals, and programmers because it is open-source, cheap, and easy to use. Read on to find out why it is so much preferred and what features does it offer.
- Inexpensive: In contrast with other microcontroller platforms, Arduino boards cost much less, with the least expensive one costing less than $50. If you still want something cheaper, then go to the lowest Arduino version that can be assembled manually.
- Cross-Platform: The Arduino IDE is supported by most operating systems like Macintosh OSX, Linux, Windows, etc.
- Simple, Clear Programming Environment: Arduino software IDE is flexible for all types of users. It is easy to be used by beginners but also offers advanced functionalities for professionals.
- Open Source and Extensible Software: The software is open-source and can be expanded through C++ libraries.
- Open Source and Extensible Hardware: Circuit designers can modify the hardware to make their version of the module extending it or improving it further if required. Beginners can even play with the device and build different modules from it to understand its working.
Let us see the Arduino projects that you can try your hands on; if you wish to brush up on your Arduino skills, you can check out the best Arduino books for quick reference to the concepts while you attempt the projects.
Recommended Course
Arduino For Beginners - 2023 Complete Course
Best Arduino Projects to Try
1. Heartbeat Sensor
Electrocardiography is one of the precise and popular ways to measure heart rate in the medical field. Monitoring heart rate is essential for athletes and patients to determine the heart condition.
With advancements in technology, a heartbeat sensor is an easy and smart way to measure heart rate. The sensors can be installed in wristwatches, smartphones, and chest strips to check on a person's heart rate.
Principle of Heartbeat Sensor
Photoplethysmography is a principle that measures the changes in the volume of blood in an organ. It does this by measuring the changes in the intensity of the light passing through the organ. This principle works behind the working of the Heartbeat Sensor.
An IR LED is generally taken to be the light source in the heartbeat sensor, and photodetectors like Photo Diode, Photoresistor, or an LDR can be used.
It is possible to arrange the components, i.e., the light source and photodetector, in two ways:
- Transmissive Sensor: In this, the light source and detector face each other. The patient must place their finger between the transmitter and the receiver.
- Reflective Sensor: In this arrangement, the light source and the detector are adjacent to each other. The finger of the person is placed in front of the sensor to read the heartbeat rate.
Circuit of Heartbeat Sensor
Components Required
- Arduino UNO x 1 [Buy Here]
- 16 x 2 LCD Display x 1 [Buy Here]
- 10KΩ Potentiometer
- 330Ω Resistor (Optional – for LCD backlight)
- Push Button
- Heartbeat Sensor Module with Probe (finger based)
- Mini Breadboard
- Connecting Wires
Application(s)
This project is an inexpensive alternative to Smart Watches and other expensive Heart Rate, Monitors.
Code
#include <LiquidCrystal.h>
LiquidCrystal lcd(6, 5, 3, 2, 1, 0);
int data=A0;
int start=7;
int count=0;
unsigned long temp=0;
byte customChar1[8] = {0b00000,0b00000,0b00011,0b00111,0b01111,0b01111,0b01111,0b01111};
byte customChar2[8] = {0b00000,0b11000,0b11100,0b11110,0b11111,0b11111,0b11111,0b11111};
byte customChar3[8] = {0b00000,0b00011,0b00111,0b01111,0b11111,0b11111,0b11111,0b11111};
byte customChar4[8] = {0b00000,0b10000,0b11000,0b11100,0b11110,0b11110,0b11110,0b11110};
byte customChar5[8] = {0b00111,0b00011,0b00001,0b00000,0b00000,0b00000,0b00000,0b00000};
byte customChar6[8] = {0b11111,0b11111,0b11111,0b11111,0b01111,0b00111,0b00011,0b00001};
byte customChar7[8] = {0b11111,0b11111,0b11111,0b11111,0b11110,0b11100,0b11000,0b10000};
byte customChar8[8] = {0b11100,0b11000,0b10000,0b00000,0b00000,0b00000,0b00000,0b00000};
void setup()
{
lcd.begin(16, 2);
lcd.createChar(1, customChar1);
lcd.createChar(2, customChar2);
lcd.createChar(3, customChar3);
lcd.createChar(4, customChar4);
lcd.createChar(5, customChar5);
lcd.createChar(6, customChar6);
lcd.createChar(7, customChar7);
lcd.createChar(8, customChar8);
pinMode(data,INPUT);
pinMode(start,INPUT_PULLUP);
}
void loop()
{
lcd.setCursor(0, 0);
lcd.print("Place The Finger");
lcd.setCursor(0, 1);
lcd.print("And Press Start");
while(digitalRead(start)>0);
lcd.clear();
temp=millis();
while(millis()<(temp+10000))
{
if(analogRead(data)<100)
{
count=count+1;
lcd.setCursor(6, 0);
lcd.write(byte(1));
lcd.setCursor(7, 0);
lcd.write(byte(2));
lcd.setCursor(8, 0);
lcd.write(byte(3));
lcd.setCursor(9, 0);
lcd.write(byte(4));
lcd.setCursor(6, 1);
lcd.write(byte(5));
lcd.setCursor(7, 1);
lcd.write(byte(6));
lcd.setCursor(8, 1);
lcd.write(byte(7));
lcd.setCursor(9, 1);
lcd.write(byte(8));
while(analogRead(data)<100);
lcd.clear();
}
}
lcd.clear();
lcd.setCursor(0, 0);
count=count*6;
lcd.setCursor(2, 0);
lcd.write(byte(1));
lcd.setCursor(3, 0);
lcd.write(byte(2));
lcd.setCursor(4, 0);
lcd.write(byte(3));
lcd.setCursor(5, 0);
lcd.write(byte(4));
lcd.setCursor(2, 1);
lcd.write(byte(5));
lcd.setCursor(3, 1);
lcd.write(byte(6));
lcd.setCursor(4, 1);
lcd.write(byte(7));
lcd.setCursor(5, 1);
lcd.write(byte(8));
lcd.setCursor(7, 1);
lcd.print(count);
lcd.print(" BPM");
temp=0;
while(1);
}
2. Wireless Doorbell
In earlier times, a knock on the door worked as a doorbell that asked for permission to let in. The concept further advanced by shifting to electronic doorbells that were wired devices fixed in one place. With the concept of WiFi being introduced, many devices have become wireless and portable. Therefore, the idea of wired doorbells is replaced by Wireless Doorbell Devices that don't require the position of the bell or switch to be fixed.
Principle of Wireless Doorbell
The project uses simple hardware to build a wireless doorbell using the Arduino UNO board. The project demonstrates the RF module's implementation for wireless communication and the UNO Arduino board to analyze the data.
Circuit Diagrams
Components Required
For Transmitter
- 434 MHz RF Transmitter Module
- HT – 12E Encoder IC
- 750 KΩ Resistor
- Push Button
- Power Supply
- Connecting Wires
- Prototyping Board (Breadboard)
For Receiver
- Arduino UNO
- 434 MHz RF Receiver Module
- HT – 12D Decoder IC
- 33 KΩ Resistor
- Small Buzzer
- Power Supply
- Connecting Wires
- Prototyping Board (Breadboard)
Code
int buz=11;
int sen=2;
void setup()
{
pinMode(buz,OUTPUT);
pinMode(sen,INPUT);
digitalWrite(buz,LOW);
digitalWrite(sen,HIGH);
}
void loop()
{
while(digitalRead(sen)==HIGH);
digitalWrite(buz,HIGH);
while(digitalRead(sen)==LOW);
digitalWrite(buz,LOW);
}
Applications
- The idea can be further extended to a real-time wireless doorbell system.
- Since the mode of communication is RF, its range is considerably large than other wireless technologies as the model uses RF.
- The project is suitable for homes, shops, garages, hospitals, offices, etc.
3. RGB LED Matrix
Building the RGB LED matrix is a popular project amongst students. An LED matrix has various usages as signboards with messages, displaying animations, synchronized music spectrum, and more. Building an RGB LED matrix involves designing a circuit, constructing a matrix, assembling components, and coding.
Principle of RGB LED Matrix
The project is to build an 8x6 RGB LED matrix using Arduino Nano, HC-06 Bluetooth Module, and an Android Phone with a custom app. So let us begin with this DIY project for Arduino.
Circuit Diagrams
The image below demonstrates the connections concerning the shift registers. The shift registers are connected to Arduino Nano, source transistors connected to the Columns, and sinking transistors connected to the Rows of R, G, and B LEDs (Cathodes).
The second image shows the layout of the RGB LEDs. They are organized into 8 rows of Cathode terminals and 6 columns of anode terminals. Each row further consists of 3 cathode terminals for Red, Green, and Blue LEDs.
Components Required
- Arduino Nano
- Bluetooth Module HC-06
- 48 X Common Anode RGB LEDs
- 6 X BD136 power PNP Transistors
- 30 X BC337 NPN Transistors
- 4 X 74HC595N Shift Register IC
- 36 X 10KΩ Resistors (¼ W)
- LM35 Temperature Sensor
- Power supply
- A lot of wires and materials like plywood and polystyrene sheet
Application
Used as signboards with messages, displaying animations, synchronized music spectrum, and more
4. Arduino Calculator
A Calculator is a handy device that everyone is aware of to perform simple arithmetic operations to complex mathematical calculations. Scientific calculators also have evolved to perform complex calculations. People rely so much on the device installed in watches, phones, and laptops as applications.
Principle of Calculator
The project is designed using Arduino UNO, a 16x2 LCD, and a 4x4 Matrix Keypad.
Circuit Diagram
Components Required
- Arduino UNO [Buy Here]
- 16 x 2 LCD Display [Buy Here]
- 4 x 4 Matrix Keypad Module or 16 Push buttons
- 10 KΩ Potentiometer
- Bread board ( Prototyping board )
- Connecting wires
Code
#include <LiquidCrystal.h>
#include <Keypad.h>
LiquidCrystal lcd(0, 1, 2, 3, 4, 5);
const byte ROWS = 4;
const byte COLS = 4;
char keys [ROWS] [COLS] = {
{'7', '8', '9', '/'},
{'4', '5', '6', '*'},
{'1', '2', '3', '-'},
{'C', '0', '=', '+'}
};
byte rowPins[ROWS] = {13 ,12 ,11 ,10};
byte colPins[COLS] = {9, 8, 7, 6};
Keypad myKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
boolean presentValue = false;
boolean next = false;
boolean final = false;
String num1, num2;
int answer;
char op;
void setup()
{
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("Electronics Hub ");
lcd.setCursor(0,1);
lcd.print(" Presents ");
delay(5000);
lcd.setCursor(0,0);
lcd.print(" Arduino based ");
lcd.setCursor(0,1);
lcd.print(" Calculator" );
delay(5000);
lcd.clear();
}
void loop(){
char key = myKeypad.getKey();
if (key != NO_KEY && (key=='1'||key=='2'||key=='3'||key=='4'||key=='5'||key=='6'||key=='7'||key=='8'||key=='9'||key=='0'))
{
if (presentValue != true)
{
num1 = num1 + key;
int numLength = num1.length();
lcd.setCursor(15 - numLength, 0); //to adjust one whitespace for operator
lcd.print(num1);
}
else
{
num2 = num2 + key;
int numLength = num2.length();
lcd.setCursor(15 - numLength, 1);
lcd.print(num2);
final = true;
}
}
else if (presentValue == false && key != NO_KEY && (key == '/' || key == '*' || key == '-' || key == '+'))
{
if (presentValue == false)
{
presentValue = true;
op = key;
lcd.setCursor(15,0);
lcd.print(op);
}
}
else if (final == true && key != NO_KEY && key == '='){
if (op == '+'){
answer = num1.toInt() + num2.toInt();
}
else if (op == '-'){
answer = num1.toInt() - num2.toInt();
}
else if (op == '*'){
answer = num1.toInt() * num2.toInt();
}
else if (op == '/'){
answer = num1.toInt() / num2.toInt();
}
lcd.clear();
lcd.setCursor(15,0);
lcd.autoscroll();
lcd.print(answer);
lcd.noAutoscroll();
}
else if (key != NO_KEY && key == 'C'){
lcd.clear();
presentValue = false;
final = false;
num1 = "";
num2 = "";
answer = 0;
op = ' ';
}
}
Application
The project can be extended to perform complex calculations. This may even result in an increased number of switches.
5. Digital Thermometer
We are all aware that a thermometer is a temperature measuring instrument. We have been using this a lot lately during Covid times as every place checks a person's body temperature as part of their check while letting inside their premises. Measuring temperature or keeping a check on temperature is also an important part of other fields besides medicine, such as incubators, storage rooms, laboratories, etc.
Principle of Digital Thermometer
Measuring temperature depends on various principles like the thermal expansion of solids or liquids, gas pressure, measurement of infrared energy, and more. The construction and functioning of the thermometer depend on the principle.
Circuit Diagram
Components Required
Code
#include<LiquidCrystal.h>
LiquidCrystal lcd(7,6,5,4,3,2);
const int Sensor = A0;
byte degree_symbol[8] =
{
0b00111,
0b00101,
0b00111,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000
};
void setup()
{
pinMode(Sensor, INPUT);
lcd.begin(16,2);
lcd.createChar(1, degree_symbol);
lcd.setCursor(0,0);
lcd.print(" Digital ");
lcd.setCursor(0,1);
lcd.print(" Thermometer ");
delay(4000);
lcd.clear();
}
void loop()
{
float temp_reading=analogRead(Sensor);
float temperature=temp_reading*(5.0/1023.0)*100;
delay(10);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Temperature in C");
lcd.setCursor(4,1);
lcd.print(temperature);
lcd.write(1);
lcd.print("C");
delay(1000);
}
Applications
- Thermometers are used in industries, weather studies, the medicinal field, and scientific research.
- The project can monitor a room's temperature within a range of -550C to +1500C with very accurate readings.
- The temperature sensor used (LM35) is a precision centigrade temperature sensor. Use the Fahrenheit temperature sensor (LM34) for Fahrenheit temperature readings.
- The thermometer can be powered by a 9V battery making it a portable device.
- It can be used in vehicles to determine the icing conditions of the road.
- The air conditioning systems, heating, and cooling systems can be controlled manually or automatically, based on the thermometer's readings.
6. Solar Tracker
Solar trackers are devices that orient a payload toward the Sun. Payloads are
usually solar panels, parabolic troughs, fresnel reflectors, lenses, or a heliostat's mirrors.
Principle of Solar Trackers
Solar trackers adjust the direction that a solar panel faces according to the Sun's position. More sunlight strikes the solar panel; less light is reflected by keeping the panel perpendicular to the Sun, so more energy is absorbed. This energy is converted into power for usage.
Circuit Diagram
Components Required
Code
#include <Servo.h>
//defining Servos
Servo servohori;
int servoh = 0;
int servohLimitHigh = 160;
int servohLimitLow = 20;
Servo servoverti;
int servov = 0;
int servovLimitHigh = 160;
int servovLimitLow = 20;
//Assigning LDRs
int ldrtopl = 2; //top left LDR green
int ldrtopr = 1; //top right LDR yellow
int ldrbotl = 3; // bottom left LDR blue
int ldrbotr = 0; // bottom right LDR orange
void setup ()
{
servohori.attach(10);
servohori.write(0);
servoverti.attach(9);
servoverti.write(0);
delay(500);
}
void loop()
{
servoh = servohori.read();
servov = servoverti.read();
//capturing analog values of each LDR
int topl = analogRead(ldrtopl);
int topr = analogRead(ldrtopr);
int botl = analogRead(ldrbotl);
int botr = analogRead(ldrbotr);
// calculating average
int avgtop = (topl + topr) / 2; //average of top LDRs
int avgbot = (botl + botr) / 2; //average of bottom LDRs
int avgleft = (topl + botl) / 2; //average of left LDRs
int avgright = (topr + botr) / 2; //average of right LDRs
if (avgtop < avgbot)
{
servoverti.write(servov +1);
if (servov > servovLimitHigh)
{
servov = servovLimitHigh;
}
delay(10);
}
else if (avgbot < avgtop)
{
servoverti.write(servov -1);
if (servov < servovLimitLow)
{
servov = servovLimitLow;
}
delay(10);
}
else
{
servoverti.write(servov);
}
if (avgleft > avgright)
{
servohori.write(servoh +1);
if (servoh > servohLimitHigh)
{
servoh = servohLimitHigh;
}
delay(10);
}
else if (avgright > avgleft)
{
servohori.write(servoh -1);
if (servoh < servohLimitLow)
{
servoh = servohLimitLow;
}
delay(10);
}
else
{
servohori.write(servoh);
}
delay(50);
}
Applications
Solar trackers are devices used to orient photovoltaic panels, reflectors, lenses, or other optical devices toward the sun.
7. Voice-Activated Home Automation System
The introduction of AI and NLP in home automation has led to a gain in popularity. It reduces human efforts to control household appliances like lights, fans, TV, air conditioners, etc. Securely designed automation systems are integrated with alarms, security cameras, emergency systems as well. Apart from voice-activated automation, devices can also be controlled by BlueTooth, the internet, remote, and other tools and technology.
Principle of Voice-Activated Home Automation Systems
The Voice-Activated Home Automation project is implemented using Arduino UNO, Bluetooth, and a smartphone to control voice commands devices.
Circuit Diagram
Components Required
- Arduino UNO – 1
- HC – 05 Bluetooth Module – 1
- Smartphone or Tablet – 1
- 2N2222 NPN Transistor – 4
- 12V Relay – 4
- 1 KΩ Resistor – 4
- 1N4007 PN Junction Diode – 4
- Power Supply
- Connecting Wires
- Breadboard (Prototyping Board)
- App for transmitting voice to Bluetooth
Code
#include <SoftwareSerial.h>
const int rxPin = 2;
const int txPin = 3;
SoftwareSerial mySerial(rxPin, txPin);
int ac=4;
int light=5;
int fan=6;
int tv=7;
String data;
void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
pinMode(ac, OUTPUT);
pinMode(light, OUTPUT);
pinMode(fan, OUTPUT);
pinMode(tv, OUTPUT);
digitalWrite(ac, LOW);
digitalWrite(light, LOW);
digitalWrite(fan, LOW);
digitalWrite(tv, LOW);
}
void loop()
{
int i=0;
char ch=0;
data="";
while(1)
{
while(mySerial.available()<=0);
ch = mySerial.read();
if(ch=='#')
break;
data+=ch;
}
Serial.println(data);
if(data=="*turn on AC")
{
digitalWrite(ac,HIGH);
Serial.println("ac on");
}
else if(data=="*turn off AC")
{
digitalWrite(ac,LOW);
Serial.println("ac off");
}
else if(data=="*turn on light")
{
digitalWrite(light,HIGH);
Serial.println("light on");
}
else if(data=="*turn off light")
{
digitalWrite(light,LOW);
Serial.println("light off");
}
else if(data=="*turn on fan")
{
digitalWrite(fan,HIGH);
Serial.println("fan on");
}
else if(data=="*turn off fan")
{
digitalWrite(fan,LOW);
Serial.println("fan off");
}
else if(data=="*turn on TV")
{
digitalWrite(tv,HIGH);
Serial.println("tv on");
}
else if(data=="*turn on TV")
{
digitalWrite(tv,LOW);
Serial.println("tv off");
}
else if(data=="*turn on all")
{
digitalWrite(ac,HIGH);
digitalWrite(light,HIGH);
digitalWrite(fan,HIGH);
digitalWrite(tv,HIGH);
Serial.println("all on");
}
else if(data=="*turn off all")
{
digitalWrite(ac,LOW);
digitalWrite(light,LOW);
digitalWrite(fan,LOW);
digitalWrite(tv,LOW);
Serial.println("all off");
}
}
Applications
- The Voice-Activated Home Automation system will help us control different loads (electrical appliances) with simple voice commands.
- This kind of system is beneficial for people with disabilities.
- Different sensors, like light, smoke, etc., can be added to expand the project further.
8. Real-Time Clock Tutorial Using DS1307
A real-time clock is a timekeeping device present in computers, servers, and other embedded systems as an Integrated Circuit (IC). They can be used wherever it is used to keep accurate time. An RTC is powered by a battery and keeps track of time even when there is no power.
Principle of RTC
The project aims to build Arduino based RTC by interfacing Arduino and IC DS1307 or DS3231 as timekeeping devices.
Circuit Diagram
circuit diagram of the Arduino Real Time Clock DS1307 Interface
circuit of a typical DS1307 Real Time Clock Module
Components Required
- Arduino UNO [Buy Here]
- DS1307 RTC Module
- 16×2 LCD Display [Buy Here]
- Breadboard
- Connecting wires
- Power supply
Code
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include <LiquidCrystal.h>
#include "RTClib.h"
RTC_DS1307 etc.;
LiquidCrystal lcd(7, 6, 5, 4, 3, 2); // (rs, e, d4, d5, d6, d7)
char daysOfTheWeek[7][12] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
void setup ()
{
Serial.begin(9600);
lcd.begin(16, 2);
if (! rtc.begin())
{
lcd.print("Couldn't find RTC");
while (1);
}
if (! rtc.isrunning())
{
lcd.print("RTC is NOT running!");
}
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));//auto update from computer time
//rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));// to set the time manualy
}
void loop ()
{
DateTime now = rtc.now();
lcd.setCursor(0, 1);
lcd.print(now.hour());
lcd.print(':');
lcd.print(now.minute());
lcd.print(':');
lcd.print(now.second());
lcd.print(" ");
lcd.setCursor(0, 0);
lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
lcd.print(" ,");
lcd.print(now.day());
lcd.print('/');
lcd.print(now.month());
lcd.print('/');
lcd.print(now.year());
}
Applications
- With the Arduino Real Time Clock interface, we can implement several projects related to data logging, alarms, clock, etc.
- Since the RTC Module DS1307 has a battery backup, it will continue to maintain time even if power fails.
9. DC Motor Control using L298N Motor Driver
We all have studied about DC Motor in our high school; it is the rotary motor that converts electrical energy to mechanical energy. The motor is simple to operate: two leads of the motor to the two terminals of a battery, and the motor begins to rotate. The motor will rotate in a reverse direction if we switch the leads.
The rotation speed is controlled by PWM DC Motor Control, which allows controlling the average voltage delivered to the motor.
Principle of DC Motor Control using L298N Motor Driver
In this project, we attempt to control a DC Motor using an Arduino and L298N Motor Driver.
Circuit Diagram
Components Required
- Arduino UNO [Buy Here]
- L298N Motor Driver Module [Buy Here]
- 12V DC Motor
- 100KΩ Potentiometer
- Push Button
- 12V Power Supply
- Breadboard
- Connecting Wires
Code
Adruino MOFSET DC Motor Control
int PWMPin = 10;
int motorSpeed = 0
void setup()
{
}
void loop()
{
for (motorSpeed = 0 ; motorSpeed <= 255; motorSpeed += 10)
{
analogWrite(PWMPin, motorSpeed);
delay(30);
}
for (motorSpeed = 255 ; motorSpeed >= 0; motorSpeed -= 10)
{
analogWrite(PWMPin, motorSpeed);
delay(30);
}
}
Arduino L298N DC Motor Control
int mot1 = 8;
int mot2 = 9;
int en1 = 10;
int dir = 6;
bool state = true;
int nob = A0;
int val=0;
void setup()
{
pinMode(mot1,OUTPUT);
pinMode(mot2,OUTPUT);
pinMode(en1,OUTPUT);
pinMode(dir,INPUT_PULLUP);
}
void loop()
{
val = analogRead(nob);
analogWrite(en1, val / 4);
if(digitalRead(dir)==LOW)
{
state=!state;
while(dir==LOW);
delay(300);
}
if(state)
{
digitalWrite(mot1,HIGH);
digitalWrite(mot2,LOW);
}
else
{
digitalWrite(mot1,LOW);
digitalWrite(mot2,HIGH);
}
}
Applications
- Arduino DC Motor Control using the L298N Motor Driver project can be extended for further advanced projects.
- Any Arduino based robot can implement this type of motor control using L298N since all robots have wheels, and we need to control the motors connected to those wheels.
10. Color Detector
A Color Sensor is a device that gives the accurate color of the object by sensing or detecting colors. A color sensor emits light using external sources like an array of white LEDs to analyze the object's reflected light, thereby determining its color.
Principle of Color Sensor
We design a simple Arduino Color Sensor application, which can detect different colors. We use TCS3200 color sensors for this purpose and the Arduino board.
Circuit Diagram
Components Required
- Arduino Mega [Buy Here]
- TCS3200 (RGB + Clear) Color Sensor Module
- Breadboard (Prototyping board)
- Power supply
- Connecting wires
Code
/*Arduino Mega*/
#include<LiquidCrystal.h>
LiquidCrystal lcd(42,43,44,46,48,50);
const int S0 = 7;
const int S1 = 6;
const int outPut= 5;
const int S2 = 4;
const int S3 = 3;
unsigned int frequency = 0;
void setup()
{
Serial.begin(9600);
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(OutPut, INPUT);
digitalWrite(S0,HIGH);
digitalWrite(S1,HIGH);
}
void loop()
{
Serial.print("R=");
digitalWrite(S2,LOW);
digitalWrite(S3,LOW);
frequency = pulseIn(outPut, LOW);
Serial.print(frequency);
Serial.print("\t");
delay(500);
Serial.print("B=");
digitalWrite(S2,LOW);
digitalWrite(S3,HIGH);
frequency = pulseIn(outPut, LOW);
Serial.print(frequency);
Serial.print("\t");
delay(500);
Serial.print("G=");
digitalWrite(S2,HIGH);
digitalWrite(S3,HIGH);
frequency = pulseIn(outPut, LOW);
Serial.print(frequency);
Serial.print("\t");
delay(500);
Serial.print("\n");
}
Applications
- Wide range of applications: image processing, digital signal processing, object detection, color identification, etc.
- In industries, for sorting objects based on color.
Conclusion
That wraps up a detailed guide about building Arduino projects. We have provided
all the major details to build up your project. Most of the projects are DIY projects, so give it a try yourself. Still, if you feel stuck, you may want to check some Arduino courses for your guidance. One suggestion is to purchase components once and try building projects with similar components to save money and build up your interest.
After you are well versed with Arduino concepts, you may want to appear for Arduino certifications. If you feel stuck anywhere, feel free to leave a comment below for the community or us.
People are also reading:
- Difference between Arduino vs Raspberry Pi
- Arduino Books
- Best JavaScript Frameworks
- Download JavaScript Cheat Sheet
- What is JavaScript Array?
- Best JavaScript Books
- Best JavaScript Courses
- Best JavaScript Interview Questions
- Best JavaScript IDE
- Best JavaScript Certifications
- Best JavaScript Libraries

what about the circuit diagrams?