0% found this document useful (0 votes)
5 views7 pages

Fcongeigao Rodrigues College of Engneerhngffrgrge: Coding

The document outlines an experiment for a laboratory course on Arduino programming, focusing on interfacing a humidity-temperature/ultrasonic sensor with an Arduino Uno. It includes theoretical background on the Arduino board, coding algorithms for a vibration sensor, and example code for implementation. Additionally, it poses post-lab questions regarding the sensor's working principle and the functions used in the program.

Uploaded by

techolic13286
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views7 pages

Fcongeigao Rodrigues College of Engneerhngffrgrge: Coding

The document outlines an experiment for a laboratory course on Arduino programming, focusing on interfacing a humidity-temperature/ultrasonic sensor with an Arduino Uno. It includes theoretical background on the Arduino board, coding algorithms for a vibration sensor, and example code for implementation. Additionally, it poses post-lab questions regarding the sensor's working principle and the functions used in the program.

Uploaded by

techolic13286
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

UES COLLE

sGINEERi wu0CAs UILD ur saTION


MoLDING

FcONGEIGAO RODRIGUES COLLEGE OF ENGNEERHNGfFrGRGE


Department of Electronics and Computer Science (ECs)
Academic year 2024 - 2025 Estimated Time 02 Hours

S.E. (ECS) Embedded systems


Course Subject Name Laboratory
Semester V Chapter Title Arduino programming
Experiment Type Coding Subject Code PCC12EC10

Aim & Objective of Experiment

To interfa ce a Humidity-Temperature /UItrasonic Sensor to the Arduino Uno (Pro teus VSM
/Hardware)

Theory:

Arduino UNO is a microcontroller board based on the ATmega328P. It has 14 digital


input/output pins (of which 6 can be used as PW M outputs), 6 analog inputs, a 16 MHz
ceram ic resonator, a USB Connection, a power jack, an ICSP header and a reset button. It
contains everything needed to support the microcontro ller; simply connect it to a computer
with aUSB cable or power it with an AC-to-DC adapter or battery to get started. ATmega328P
8-bit AVR Microcontroller with 32K Bytes In-Syste mProgramm able Flash.

The Arduino Integrated Development Environment - or Arduino Software (IDE)


contains a text editor for writing code, a message area, a text console, a to olbar with buttons
for common functions and a series of menus. It connects to the Arduino hardware to uplo ad
programs and communicate with them

Writing Sketches
CONGELCA ES C

Programs written using Arduino Software (IDE) are called sketches. These
sketches are written in the text editor and are saved with the file

extension.ino. The editor has features for cutting/pasting and for


MOUL DING sGINEFR; WyoCAN HUIL,
searching/rep lacing text. The message area gives feedback while saving
and exporting and also disp lays erro rs. The console displays text output by the Arduino
Software (|DE), including complete error messages and other in formation. The bottom
righthand corner of the window displays the configured board and serial port. The toolbar
buttons allow you to verify and upload programs, create, open, and save sketches, and open
the serial monitor.

Fr. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING (FrCRCE)


Department of Electronics and Computer Science (ECS)
Vibration Sensor

Algorithm:
1. Start

2. Set pin 2 as input with pull-up and pin 5 as output.


3. Begin serial communication at 9600 baud.
4. Initialize output pin by writing HIGH then LOW with a short delay.
5. Continuously check the input pin in the loop.
6 If input pin reads HIGH, print "VIBRATION ALERT" and blink the output pin 3 tim es.
7. End (loop continues indefinitely)

Code:

int b1 = 2;
int d1 = 5;

int cnt=0,cnt2;

int timer=0;

int pos = 0;
void setup() {

Serial. begin(9600);
pinMode(b1, INPUT_PULLUP);

pinMode(d1, OUTPUT );
digitalWrite(d1, HIGH);
digitalWrite (d1,LOW);
delay(300);
cnt=0;

void loop() {

if(digital Read(b1) == HIGH){


Serial.println("VIBRATION ALERT");

digitalWrite(d1, HIGH);
delay(300);
digitalWrite(d1, LOW);
delay(300);

digitalWrite(d1, HIGH);
delay(300):
digitalWrite(d1, LOW);
delay(300);

digitalWrite(d1, HIGH);
delay(300 );
digitalWrite(d1, LOW) ;
delay(300 );

vibra Arduino IDE 2.2.1 X

File Edit Sketch Tools Help


Aduito Unu

vibra ino

int bi- 2;
int d1 5:

t2;

il a maximum of eight servo objects can be created


int pos- 0; 1| variable to store the servo position
9 void setup() {
10
Serial.begin(960e); 1linitialize serisl
11 pintode(b1, INPUT_PULLUP):
petteld1., HIG);
14
digitalurite(d1, LOW);
15 delay(300); ( wait for a second
1 cnt-0;
17
18
void loop ()
21 if(digitalRead(b1) m HIGH)(
CanialnnintlnthnnaTT AEOT"
Oulpul

ja328p -o "C:\\users\\Rutika\\VppData\\Local\\Tamp\ \arduino\\sketches\\9EAR1524MIFB6CB6C91CB6818E3FSE/vibra. ino.el f" "C:\\Usersi\Rutikal \\ppData\\Local\\Temp\\arduino\ \sketches\\9EAg1524M1


10-change-warnings --change-section-Ima .eeprom-0 "C:\\Users\\RutikalAppData\\Local\ \Tenp\ \arduino\\sketches\\9EA81524AM1FB6CB6c91C886818E3F5E/vibra.ino.elf" "C:\\Users\\Rutika\ \AppData\\LOC
\arduino\\sketchesi\9EA81524A41FB6CB6C91C8B6818E3FSE/vibra. ino. elf""C:\\Uses| \Rutika\\AppData\\Local\|Temp\\earduino\\sketches \9EA81524MIFBOCBeC91 C8B6818E3FSE/vibra. ino . hex"
|9EA81524A41FB6CB6C91C8B6818E3F5E/vibra. ino. elf

R Vibra- Proteus 8Professional- Schematic Capture


File Edit View Iool Design Graph Debug LIbrary Template System Heip
A O a QBS Base Design
schomatie Capture X

Virtual Terminal
TPL VIRRATTON ALRRT
N VIBiwTION AlBRT
Lo3ICST VIRRATONN

nB1
atiov

ARDT

ViIbratlon Sensor
UES COLLE

sGINEFRi uoCAN0LD rNATION


MoULDING

Fr. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING (FrCRCE)


Department of Electronics and Computer Science (ECS)

Post- Lab Questions:

1. Explain the principle of working of the sensor used.


2. Expla in all the Arduino functions used in the program.
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING

Exyevimert 6

Post Las Ques tonsi

&Cxploatn the pstactple o woxktg of the sensesu


v lAatio AenseL Qn a slaple mechantal
>The Sw- u
`wtthiag peneple Sastde Hhe sensoe
Rn nomal candH oas ohen
thal &tays sspend e
the senson expelences wilLatf on, the spseaq the cluit
kouhes a coataak , momenlaurly closig
sfgae o tee oala and compau
ailoaud
Tuis coatact sends a atgaal
(wsually LM393)whsh prcesses
tais analogsqal
HIGH Sgaa uhenuuc
clean &fqital
anl autputs a
emalas
fs m w i a a n the outpt

le adfus bed tag the anloand


how nuchwlatfon es
potenttemetee o contol
the Qutput The &ense has tuee
needed ko kulqqcke
O0rciqital awtput)
Lp?asi Vcclpow), GNo(qiouad)`
when connecte
HIGH wicn the A Ldino Carie od
Qutput pta go
Jisplot a mesdage

8aGxplafn all the Adefao functtens wwed Ea thepAqam

DtaModel_ptamode)i sts a pla as IaeUT or o0reUT.


(HIGH or Low)

ntke cpra)i dends a digttal afqAal ko a pi


: tats seut al communfcatton at a given aud
Late
" deil-paintla (data)i Patas data ko the seeal monttr with a
newlne.
detup (.): Runs Once at statup Ra
. doop (): Repeats continous y lo ceck sensor rput and
act acco xcs nq

You might also like