Practical - 1: AIM: Study About Arduino
Practical - 1: AIM: Study About Arduino
Practical - 1: AIM: Study About Arduino
PRACTICAL – 1
AIM : Study about Arduino.
Arduino is an open-source electronics platform based on easy-to-use hardware and software.
Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter
message - and turn it into an output - activating a motor, turning on an LED, publishing
something online. You can tell your board what to do by sending a set of instructions to the
microcontroller on the board. To do so you use the Arduino programming language (based on
Wiring), and the Arduino Software (IDE), based on Processing.
BAIT,SURAT Page 1
Internet of Thing [1010207713] [2107020701005]
The Atmel® ATmega328P is a low-power CMOS 8-bit microcontroller based on the AVR®
enhanced RISC architecture.
The LED's legs are connected to two pins on the Arduino: ground and pin 13. The component
between the LED and pin 13 is a resistor
3. Power LED:
5. TX and RX LEDs:
6. Reset button:
BAIT,SURAT Page 2
Internet of Thing [1010207713] [2107020701005]
Introduction:
The Arduino Software (IDE) is easy-to-use and is based on the Processing programming
environment. The Arduino Integrated Development Environment (IDE) is a cross-platform
application (for Windows, macOS, Linux) that is written in functions from C and C++. The
open-source Arduino Software (IDE) makes it easy to write code and upload it to the board.
This software can be used with any Arduino board.
A toolbar with buttons for common functions and a series of menus. It connects to the Arduino
hardware to upload programs and communicate with them.
Step1: Downloading
BAIT,SURAT Page 3
Internet of Thing [1010207713] [2107020701005]
BAIT,SURAT Page 4
Internet of Thing [1010207713] [2107020701005]
➢ The USB connection with the PC is necessary to program the board and not just to power
it up. The Uno and Mega automatically draw power from either the USB or an external
power supply. Connect the board to the computer using the USB cable. The green power
LED (labelled PWR) should go on.
➢ Open the Arduino IDE software on your computer. Coding in the Arduino language will
control your circuit.
➢ Open a new sketch File by clicking on New.
BAIT,SURAT Page 5
Internet of Thing [1010207713] [2107020701005]
To avoid any error while uploading your program to the board, you must select the correct
Arduino board name, which matches with the board connected to your computer.
Go to Tools → Serial Port menu. This is likely to be COM3 or higher (COM1 and COM2 are
usually reserved for hardware serial ports).
To find out, you can disconnect your Arduino board and re-open the menu, the entry that
disappears should be of the Arduino board. Reconnect the board and select that serial port.
BAIT,SURAT Page 6
Internet of Thing [1010207713] [2107020701005]
Wait a few seconds; you will see the RX and TX LEDs on the board, flashing.
If the upload is successful, the message "Done uploading" will appear in the status bar.
BAIT,SURAT Page 7
Internet of Thing [1010207713] [2107020701005]
BAIT,SURAT Page 8
Internet of Thing [1010207713] [2107020701005]
PRACTICAL – 2
AIM : Study about Raspberry Pi.
Raspberry Pi :
• Because of its low cost and open design, the model became far more popular than
anticipated.
• It is widely used to make gaming devices, fitness gadgets, weather stations, and much
more.
• In 2012, the company launched the Raspberry Pi and the current generations of regular
Raspberry Pi boards are Zero, 1, 2, 3, and 4.
▪ Processor
▪ HDMI Port
▪ USB Port
BAIT,SURAT Page 9
Internet of Thing [1010207713] [2107020701005]
▪ Ethernet Port
▪ SD Card Slot
▪ Camera Connector
▪ Audio Output
▪ GPIO Pins
▪ Status LEDs
Processor:
Raspberry Pi uses Broadcom BCM2835 system on chip which is an ARM processor and Video
core Graphics Processing Unit (GPU). It is the heart of the Raspberry Pi which controls the
operations of all the connected devices and handles all the required computations.
HDMI:
High Definition Multimedia Interface is used for transmitting video or digital audio data to a
computer monitor or to digital TV. This HDMI port helps Raspberry Pi to connect its signals
to any digital device such as a monitor digital TV or display through an HDMI cable.
GPIO ports:
General Purpose Input Output ports are available on Raspberry Pi which allows the user to
interface various I/P devices.
Audio output:
An audio connector is available for connecting audio output devices such as headphones and
speakers.
USB ports:
This is a common port available for various peripherals such as a mouse, keyboard, or any
other I/P device. With the help of a USB port, the system can be expanded by connecting more
peripherals.
SD card:
The SD card slot is available on Raspberry Pi. An SD card with an operating system installed
is required for booting the device.
BAIT,SURAT Page 10
Internet of Thing [1010207713] [2107020701005]
Ethernet:
The ethernet connector allows access to the wired network, it is available only on the model B
of Raspberry Pi
Power supply:
A micro USB power connector is available onto which a 5V power supply can be connected.
Camera module: Camera Serial Interface (CSI) connects the Broadcom processor to the Pi
camera.
Display:
Display Serial Interface (DSI) is used for connecting LCD to Raspberry Pi using 15 15-pin
ribbon cables. DSI provides a high-resolution display interface that is specifically used for
sending video data.
BAIT,SURAT Page 11
Internet of Thing [1010207713] [2107020701005]
PRACTICAL – 3
AIM : Write a program for blinking led in Arduino.
Code :
int LEDpin = 13;
int delayT = 1000;
void setup()
{
// put your setup code here, to run once:
pinMode(LEDpin, OUTPUT);
}
void loop()
{
// put your main code here, to run repeatedly:
digitalWrite(LEDpin, HIGH);
delay(delayT);
digitalWrite(LEDpin, LOW);
delay(delayT);
}
Output :
BAIT,SURAT Page 12
Internet of Thing [1010207713] [2107020701005]
PRACTICAL – 4
AIM : Write a program for blinking rgb led color mixing in Arduino.
Code :
void setup()
{
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
}
void loop()
{
analogWrite(11, 255);
analogWrite(10, 0);
analogWrite(9, 0);
delay(1000); // Wait for 1000 millisecond(s)
analogWrite(11, 255);
analogWrite(10, 255);
analogWrite(9, 102);
delay(1000); // Wait for 1000 millisecond(s)
}
Output :
BAIT,SURAT Page 13
Internet of Thing [1010207713] [2107020701005]
PRACTICAL – 5
AIM : Write a program for push button digital input in Arduino.
Code :
// constants won't change. They're used here to set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
Output :
BAIT,SURAT Page 14
Internet of Thing [1010207713] [2107020701005]
PRACTICAL – 6
AIM : Write a program for keypad value print in lcd in Arduino.
Code :
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
char keys[ROW_NUM][COLUMN_NUM] = {
{'1','2','3', 'A'},
{'4','5','6', 'B'},
{'7','8','9', 'C'},
{'*','0','#', 'D'}
};
byte pin_rows[ROW_NUM] = {9, 8, 7, 6}; // connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = {5, 4, 3, 2}; // connect to the column pinouts of the
keypad
int cursorColumn = 0;
void setup(){
lcd.init(); // initialize the lcd
lcd.backlight();
}
void loop(){
char key = keypad.getKey();
if (key) {
lcd.setCursor(cursorColumn, 0); // move cursor to (cursorColumn, 0)
lcd.print(key); // print key at (cursorColumn, 0)
BAIT,SURAT Page 15
Internet of Thing [1010207713] [2107020701005]
Output :
BAIT,SURAT Page 16
Internet of Thing [1010207713] [2107020701005]
PRACTICAL – 7
AIM : Write a program for temperature sensor in Arduino.
Code :
#include <LiquidCrystal.h>
// initialize the library with the pins on the Arduino board
LiquidCrystal lcd(13, 12, 6, 4, 3, 2);
const int temperature = A0; //A0 is the analog pin
const int D = 8; // Vo of LCD is connected to pin 8 of the Arduino
void setup()
{
lcd.begin(16, 2);
Serial.begin(9600);
pinMode(D, OUTPUT);
}
void loop()
{
digitalWrite(D,LOW);
int Temp = analogRead(temperature);
float volts = (Temp / 965.0) * 5;
float celcius = (volts - 0.5) * 100;
float fahrenheit = (celcius * 9 / 5 + 32);
Serial.println(fahrenheit);
lcd.setCursor(5, 0);
lcd.print(fahrenheit);
delay(2000);
// time delay of 2000 microseconds or 2 seconds
}
Output :
BAIT,SURAT Page 17
Internet of Thing [1010207713] [2107020701005]
PRACTICAL – 8
AIM : Write a program for servo motor control using Arduino.
Code :
#include <Servo.h>
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
Output :
BAIT,SURAT Page 18
Internet of Thing [1010207713] [2107020701005]
BAIT,SURAT Page 19