5 Simple Arduino Projects for Beginners

Tabrez Ahmed
5 min readApr 30, 2021

So during the past few months, I have been a bit busy with college starting offline semester and a lot of things happening in my life. But I had found anopportunity to try out something which I never tried that is the Arduino! I know you are probably like “It's so outdated” or “Your so late bruh”. But I thought let's give it a go anyway! I like building stuff so I thought it would a good platform to learn and explore so that I can bring my technical ideas into life hopefully.

Arduino is an open-source electronics platform based on easy-to-use hardware and software. It is a platform that makes prototyping easy.

So the first project was a light blinker using the built-in LED in the Arduino and connecting an external LED these are very simple experiments and can be done easily using the Arduino IDE.

The second project was to make an LED Fade, this was also an easy project but in the Arduino IDE it's given using the IF statement here is the code using FOR loop, I have connected LED to pin 11 of the Arduino board.

int led=11;
int brightness; //control brightness
void setup() {

pinMode(led,OUTPUT);
}
void loop() {
//Fade in
for(brightness=0;brightness < 255; brightness= brightness + 5){
analogWrite(led,brightness);
delay(10);
}
//Fade out
for(brightness = 255; brightness>0; brightness = brightness-5){
analogWrite(led,brightness);
delay(10);
}
}

The Third Project was using a Push button and Buzzer, it was a great deal of satisfaction when I saw my first beepy device work! Here is the code for it using While loop:

void setup(){pinMode(button ,INPUT);
pinMode(buzzer, OUTPUT);
}
void loop(){
digital Write(buzzer, LOW); //by default off
//While push button is pressed turn on buzzer
while(digitalRead(button)){
digitalWrite(buzzer,HIGH);
}
delay(100); //100ms delay to stabiilize the button
}

using IF condition

void setup(){pinMode(button ,INPUT);
pinMode(buzzer, OUTPUT);
}
void loop(){
if(digitalRead(button)== HIGH){digitalWrite(buzzer, HIGH);
}else{
digitalWrite(buzzer, LOW);
}

NOW, The interesting part where we add an LED! with the buzzer.

Project 3.1 will consist of a buzzer and an LED! So here is how it will work When the button is not pressed the LED will glow and when the button is pressed the buzzer will go beeeeep! and LED will be off. Here is the code for it:

int button= 2;
int buzzer= 11;
int led=13; // intitalize the push button,buzzer and led variables

void setup() {
// initialize the LED pin as an output:
pinMode(12, OUTPUT);//LED is connected to pin 12
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
pinMode(buzzer, OUTPUT);
}
void loop() {
digitalWrite(buzzer, LOW);

switch(digitalRead(buttonPin)){
//if value is 0 //LED is ON and buzzzer is off
case 0:
digitalWrite(12,HIGH);
digitalWrite(buzzer, LOW);
break;
case 1:
digitalWrite(12,LOW);
digitalWrite(buzzer,HIGH);
break;
default:
digitalWrite(12,LOW);
digitalWrite(buzzer, LOW);
break;
}
delay(100);
}

Since Medium does not allow video files you can't hear the buzzer. But it beeps try it out.

Project 4: RGB Colour Mixer

RGB LED diagram by osoyoo.com

What is an RGB LED? An RGB LED has 3 internal LEDs (Red, Green and Blue) that can be combined to produce almost any colour in the visible spectrum.

We use PWM(Pulse Width Modulation) for stimulating analog output. This will provide different voltage levels to the LEDs and we get the desired colour.

void setup() {

pinMode(9,OUTPUT); //For me this pin gave me Blue
pinMode(10,OUTPUT); // this gave me Green
pinMode(11,OUTPUT); //this this gave me red
}void loop() {
analogWrite(9,0);
analogWrite(10,255);
analogWrite(11,255);// you can vary values of the rgb leds to get different colours.
}

We use analogWrite function to input values to the LEDs. This was a fun and easy experiment to do.

Project 5: Using Potentiometer to control Servomotor

What is a potentiometer?
A potentiometer or pot for short is a variable resistor with 3 terminals 2 Outer terminals are connected to 5 volts and ground respectively. The third (middle one) goes to analog input A0 on the Arduino board. It can be used as a Voltage divider which is adjustable.

It consists of a wiper that wipes over a material of varying resistance hence the resistance across the terminals varies.

By Australianresisitors.com

What is a servo motor?

A servomotor is a motor that allows precise control over angular or linear position. it consists of a Potentiometer, Control circuits, Outer Shaft and Gear System.

The outer shaft has a maximum angle of rotation of 180 degrees.

Code:

#include <Servo.h>Servo myservo;  // create servo object to control a servoint potpin = 0;  // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}

The analogRead() function can read values from 0 to 1023(10 bits) and analogWrite from 0 to 255(8bits, PWM pins). also, the servo motor takes values between 0 and 180(analog values) Hence we use the map function to map potentiometer values to 0 and 180.

omg they grow up so fast

So these are the 5 beginner Arduino projects that you can easily try if you never used an Arduino board before good luck and have fun! Also, I would like to thank Spaientury for their DYKA(Do You Know Arduino) Course which was really helpful for me to get started.

These are really small projects but they will help in the long run if you think about it!

--

--

Tabrez Ahmed

Final-year Electronics & Communication Engineering student at RV College of Engineering.