Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
16 views19 pages

Practical - 1: AIM: Study About Arduino

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 19

Internet of Thing [1010207713] [2107020701005]

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.

Introduction to Arduino Uno


• Atmega328p Microcontroller inside
• The operating voltage is 5V which is given by
• USB socket or
• External power socket
• DC Current for each input/output pin is 40 mA
• Digital input/output pins are 14 to interface digital input or output devices
• There are 6 Analog i/p pins used for interfacing analog input devices.
• Memory Components:
• 32KB flash (program) memory
• SRAM is 2 KB
• EEPROM is 1 KB

BAIT,SURAT Page 1
Internet of Thing [1010207713] [2107020701005]

• Components in Arduino Uno

1. Atmega328p Microcontroller: The heart of the board.

The Atmel® ATmega328P is a low-power CMOS 8-bit microcontroller based on the AVR®
enhanced RISC architecture.

2. On-board LED interfaced with pin 13.

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:

Indicates the status of Arduino whether it is powered or not.

4. GND and 5V pins:

Used for providing +5V and ground to other components of circuits.

5. TX and RX LEDs:

These LEDs indicate communication between Arduino and computer.

6. Reset button:

Use to reset the ATmega328P microcontroller

BAIT,SURAT Page 2
Internet of Thing [1010207713] [2107020701005]

Arduino IDE (Integrated Development Environment) :

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.

The Arduino Software (IDE) – contains:

• A text editor for writing code


• A message area
• A text consoles

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.

Installation of Arduino Software (IDE)

Step1: Downloading

➢ To install the Arduino software, download this page: http://arduino.cc/en/Main/Software


and proceed with the installation by allowing the driver installation process.

BAIT,SURAT Page 3
Internet of Thing [1010207713] [2107020701005]

Step 2: Directory Installation


➢ Choose the installation directory.

Step 3: Extraction of Files


➢ The process will extract and install all the required files to execute properly the Arduino
Software (IDE)

BAIT,SURAT Page 4
Internet of Thing [1010207713] [2107020701005]

Step 4: Connecting the board

➢ 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.

Step 5: Working on the new project

➢ 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.

Step 6: Working on an existing project


To open an existing project example, select File → Example → Basics → Blink.

BAIT,SURAT Page 5
Internet of Thing [1010207713] [2107020701005]

Step 7: Select your Arduino board.

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 → Board and select your board.

Step 8: Select your serial port

Select the serial device of the Arduino board.

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]

Step 9: Upload the program to your board.

Click the "Upload" button in the environment.

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 :

• Raspberry Pi is a single-board computers,developed by Raspberry Pi Foundation in


association with Broadcom and perhaps themost inspiring computer available today.

• 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.

Architecture, Layout and Interface of Raspberry Pi :

▪ Processor

▪ HDMI Port

▪ USB Port

BAIT,SURAT Page 9
Internet of Thing [1010207713] [2107020701005]

▪ Ethernet Port

▪ SD Card Slot

▪ Camera Connector

▪ Composite Video Output

▪ Audio Output

▪ Micro USB Power

▪ 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

// variables will change:


int buttonState = 0; // variable for reading the pushbutton status

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);

// check if the pushbutton is pressed. If it is, the buttonState is HIGH:


if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}

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>

const int ROW_NUM = 4; // four rows


const int COLUMN_NUM = 4; // four columns

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

Keypad keypad = Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM,


COLUMN_NUM );
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column and 2 rows

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)

cursorColumn++; // move cursor to next position


if(cursorColumn == 16) { // if reaching limit, clear LCD
lcd.clear();
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>

Servo myservo; // create servo object to control a servo


// twelve servo objects can be created on most boards

int pos = 0; // variable to store the servo position

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

You might also like