College Arduino Project
College Arduino Project
-------------------------------- -------------------------------
Head of Department Signature of Professor
Department of Physics
Anurag Das
INTRODUCTION
Arduino is an open-source electronics platform based on easy-to-use hardware and
software. It consists of a physical programmable circuit board, often referred to as a
microcontroller, and an Integrated Development Environment (IDE) that runs on a
computer.
The Arduino board is designed to be used by artists, designers, hobbyists, and anyone
interested in creating interactive objects or environments.
The Arduino board is equipped with input/output pins that can be used to connect to
various sensors, actuators, and other electronic components. These pins can be
programmed using the Arduino programming language, which is based on C/C++.
The programming language is easy to learn and use, making it accessible to a wide range
of users. Arduino boards come in different sizes and shapes, each with different features
and capabilities. Some of the popular Arduino boards include the Arduino Uno, Arduino
Mega, and Arduino Nano.
Arduino UNO:
UNO is based on ATmega328P microcontroller. There are two variants of the Arduino UNO:
one which consists of through – hole microcontroller connection and other with surface
mount type. The Arduino Uno board is one of the most popular and widely used
microcontroller boards in the Arduino family. It is based on the ATmega328P microcontroller
and has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB
connection, a power jack, an ICSP header (used to program the boot loader), and a reset
button. The Uno board also has a built-in LED, which is connected to digital pin 13.
1. Microcontroller: ATmega328P
2. USB/TTL controller: ATmega16U2
3. Operating Voltage: 5V
4. Input Voltage (recommended): 7-12V
5. Digital I/O Pins: 14 (of which 6 provide PWM [pulse width modulation] output)
6. Analog Input Pins: 6
7. DC Current per I/O Pin: 20 mA
8. DC Current for 3.3V Pin: 50 mA
9. Flash Memory: 32 KB (ATmega328P) of which 0.5 KB used by bootloader
10.SRAM: 2 KB (ATmega328P)
Page 1
CU Roll no: 213432-21-0013 Date: 12/07/2023
11.EEPROM: 1 KB (ATmega328P)
The Arduino Uno board is versatile and can be used for a wide range of applications. It is
commonly used for prototyping, experimentation, and creating interactive electronic projects.
It can be programmed using the Arduino IDE, which provides a simple and easy-to-use
easy
interface for writing, compiling, and uploading code to the board. Overall, the Arduino Uno
board is an excellent choice for beginners and experienced users alike who want a reliable and
flexible microcontroller board for their projects.
Arduino IDE :
source software, which is used to write and upload code to the Arduino
The Arduino IDE is an open-source
boards. The IDE application is suitable for different operating systems such as Windows, Mac OS X,
and Linux.. It supports the programming languages C and C++.. Here, IDE stands for Integrated
Development Environment.
Page 2
CU Roll no: 213432-21-0013 Date: 12/07/2023
The program or code written in the Arduino IDE is often called as sketching. We need
to connect the Genuino and Arduino board with the IDE to upload the sketch written in
the Arduino IDE software. The sketch is saved with the extension '.ino.'
Toolbar Button
The icons displayed on the toolbar are New, Open, Save, Upload, and Verify.
It is shown below:
Page 3
CU Roll no: 213432-21-0013 Date: 12/07/2023
Upload
The Upload button compiles and runs our code written on the screen. It further uploads
the code to the connected board. Before uploading the sketch, we need to make sure
that the correct board and ports are selected.
We also need a USB connection to connect the board and the computer. Once all the
above measures are done, click on the Upload button present on the toolbar.
The latest Arduino boards can be reset automatically before beginning with Upload. In
the older boards, we need to press the Reset button present on it. As soon as the
uploading is done successfully, we can notice the blink of the Tx and Rx LED.
If the uploading is failed, it will display the message in the error window.
We do not require any additional hardware to upload our sketch using the Arduino
Bootloader. A Bootloader is defined as a small program, which is loaded in the
microcontroller present on the board. The LED will blink on PIN 13.
Sketch
When we click on the Sketch button on the Menu bar, a drop-down list appears. It is
shown below:
Verify/Compile
It will check for the errors in the code while compiling. The memory in the console area
is also reported by the IDE.
We even may use some online platforms like Wokwi Simulator, Tinkercad e.t.c.
We can now start programming with our Arduino board using the Arduino
software and build creative new Arduino projects.
Page 4
CU Roll no: 213432-21-0013 Date: 12/07/2023
Parts Required:
1 x Mini Breadboard | Arduino UNO | 4 x 1 Kilo-Ohm Resistor | Jumper Wires | RGB LED.
#Source Code:
void setup() {
pinMode(PIN_RED, OUTPUT);
pinMode(PIN_GREEN, OUTPUT);
pinMode(PIN_BLUE, OUTPUT);
}
void loop() {
// color code #00C9CC (R = 0, G = 201, B = 204)
setColor(0, 201, 204);
delay(1000);
// color code #F7788A (R = 247, G = 120, B = 138)
setColor(247, 120, 138);
// color code #00C9CC (R = 0, G = 201, B = 204)
delay(1000);
setColor(255, 255, 0); // Red Colour
delay(1000);
setColor(0, 255, 0); // White Colour
delay(1000);
// color code #34A853 (R = 52, G = 168, B = 83)
setColor(52, 168, 83);
delay(1000); // keep the color 1 second
}
Page 5
CU Roll no: 213432-21-0013 Date: 12/07/2023
5 2.5 Volt
Rs 100
0.025 Ampere
#Arduino Circuit & Output:
Output
Page 6
CU Roll no: 213432-21-0013 Date: 12/07/2023
1 x Breadboard | Arduino UNO | 3 x 5mm LED (1x red, 1x yellow, 1x green) | 2 x 3mm LED (1x
red, 1x green) | 6 x 1 Kilo-Ohm Resistor | 1x pushbutton | Jumper Wires.
void setup() {
changeTime = millis();
pinMode(redCar, OUTPUT);
pinMode(yellowCar, OUTPUT);
pinMode(greenCar, OUTPUT);
pinMode(redPed, OUTPUT);
pinMode(greenPed, OUTPUT);
pinMode(button, INPUT);
//turn on the green light
digitalWrite(greenCar, HIGH);
digitalWrite(redPed, HIGH);
digitalWrite(redCar, LOW);
digitalWrite(yellowCar, LOW);
digitalWrite(greenPed, LOW);
Serial.begin(9600);
}
void loop() {
int state = digitalRead(button);
Serial.println(state);
}
}
void changeLights() {
digitalWrite(greenCar, LOW);
digitalWrite(yellowCar, HIGH);
delay(2000);
digitalWrite(yellowCar, LOW);
digitalWrite(redCar, HIGH);
digitalWrite(redPed, LOW);
digitalWrite(greenPed, HIGH);
delay(crossTime);
changeTime = millis();
}
Features:
The car light is always green, and so the pedestrian light is always red unless someone
presses the button. When someone presses the button here’s what happens:
The lights are in this state for a while (in the code this time is the variable “crossTime”).
Page 8
CU Roll no: 213432-21-0013 Date: 12/07/2023
Page 9
CU Roll no: 213432-21-0013 Date: 12/07/2023
The Ultrasonic sensor uses sound waves to detect the presence and proximity of objects. It sends out
high-frequency sound waves that bounce off objects and then measures the time it takes for the sound
waves to return. It usually sends an ultrasonic pulse out at 40kHz which travels through the air.
#Source Code:
//Arduino with Ultrasonic (HC – SR04) Sensor
//Project:3 ; CU Roll No: 213432-21-0013; Date: 26/06/2023
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop()
{
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
// convert the time into a distance
cm = (duration/2) / 29.1; Ultrasonic Sensor (HC-SR04)
inches = (duration/2) / 74;
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(250);
}
# Arduino Circuit & Output:
Page 10
CU Roll no: 213432-21-0013 Date: 12/07/2023
Page 11
CU Roll no: 213432-21-0013 Date: 12/07/2023
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
lcd.begin(16, 2);
}
void loop()
{
lcd.setCursor(0,0);
String msg = "SEC-B1 P: Arduino";
lcd.print(msg);
delay(500);
for (int pos=0; pos<msg.length();pos++);
{
lcd.scrollDisplayLeft();
delay(500);
}
lcd.clear();
lcd.noBlink();
delay(200);
lcd.blink();
delay(200);
}
#Circuit Components:
Page 12
CU Roll no: 213432-21-0013 Date: 12/07/2023
# The LCD (Liquid Crystal Display) is a type of display that uses the liquid crystals for its operation.
LCD Blink:
Page 13
CU Roll no: 213432-21-0013 Date: 12/07/2023
The DHT22 is a basic, low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor
and a thermistor to measure the surrounding air and spits out a digital signal on the data pin.
#Source Code:
#include "DHT.h"
#define DHTPIN 6
#define DHTTYPE DHT22
void loop() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(F("°C "));
Serial.print(f);
Serial.println(F("°F"));
}
Page 14
CU Roll no: 213432-21-0013 Date: 12/07/2023
#Arduino Circuit
# Output Data:
Page 15
CU Roll no: 213432-21-0013 Date: 12/07/2023
#include "SevSeg.h"
SevSeg sevseg;
void setup()
{
//Set to 1 for single digit display
byte numDigits = 1;
Page 16
CU Roll no: 213432-21-0013 Date: 12/07/2023
Parts Required:
Arduino UNO Board | Current limiting Resistances: 4 x 1 Kilo-Ohm Resistor | Jumper wires &
| Common Anode (CA) 7 Segment Display.
Page 17