0% found this document useful (0 votes)
97 views8 pages

R195328R Practical Report M2

The document discusses an Arduino practical report that involves using sensors and microcontrollers. It introduces Arduino and its programming environment. The practical has two main tasks - building a temperature controller using a temperature sensor and an Arduino board, and designing a distance measurement sensor and water level controller using an ultrasonic sensor. For both tasks, the circuit designs and Arduino codes are presented, showing how the sensors take readings and the boards respond based on preset threshold values by activating outputs like LEDs and buzzers. The report concludes that all systems worked as intended, though debugging hardware errors was challenging due to limited breadboard space. Overall, the practical's goals of learning microcontroller usage and interfacing real-world sensors were achieved.

Uploaded by

Chris M Ncube
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)
97 views8 pages

R195328R Practical Report M2

The document discusses an Arduino practical report that involves using sensors and microcontrollers. It introduces Arduino and its programming environment. The practical has two main tasks - building a temperature controller using a temperature sensor and an Arduino board, and designing a distance measurement sensor and water level controller using an ultrasonic sensor. For both tasks, the circuit designs and Arduino codes are presented, showing how the sensors take readings and the boards respond based on preset threshold values by activating outputs like LEDs and buzzers. The report concludes that all systems worked as intended, though debugging hardware errors was challenging due to limited breadboard space. Overall, the practical's goals of learning microcontroller usage and interfacing real-world sensors were achieved.

Uploaded by

Chris M Ncube
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/ 8

MICROCONTROLLERS PRACTICAL REPORT

Introduction
Arduino comprises of both a physical programmable circuit board (commonly known as a
microcontroller) and a programming software, or IDE (Integrated Development
Environment) that can be run on a PC, used to compose and transfer PC code to the circuit
board. It can be done by using the Arduino programming language (based on Wiring), and
the Arduino Software (IDE), based on Processing. Unlike other programmable circuit boards,
the Arduino does not require a different equipment (called a software engineer) to upload
code to the circuit board, one can essentially utilize a USB link. Also, the Arduino IDE
utilizes a rearranged rendition of C++, making it simpler to figure out how to program. In a
word, Arduino make the functions of the micro-controller into a more accessible
package. The Uno is one of the more prevalent boards in the Arduino family and an
extraordinary. The use of sensors helps us get analog output from the environment and create
variables that will help us control devices in our circuits, an example can be a temperature
sensor in this instance measures the instantaneous temperature of the air around the sensor
and we can make regulations based on its readings and so on. These sensors var widely each
with its specific task such that they can be applied in different situations requiring different
attentions to certain states of environment e.g., humidity, proximity etc.

1. To teach microcontroller interfacing using real examples (LEDs and sensors)


2. To learn micro-controller usage:
• parallel IO
• serial IO
• Hardware Interrupt
• Operating systems.
• Use of Sensors

3. To learn to build interfaces between real world data and the computer getting analog input from
different sensors.
Task #1: Arduino Based Temperature Controller.
Task#2: Arduino Based distance sensor.
i) Distance measurement.
ii) Water level Controller.

• Arduino Uno
• Connecting Wires
• LEDs
• Push Switch
• Breadboard
• Computer (Arduino C IDE installed)
• Temperature sensor (LM35)
• Ultrasonic range detector (HC SR-04)
(a)
The air conditioner is to be triggered automatically by a relay
if the air temperature is below 30°C and switched off when it is at least 40C. A red
led is turned on when the heater is triggered and a green led is turned on when it is
switched off. Write an Arduino C programme which solves the above problem and
implement the temperature controller to monitor and control the air temperature.

const int temp_reading = 1 ; //naming pin 0 of analog input side as


temp_reading
const int high = 8 ; // For turning on and off red LED
const int low = 9 ; // For turning on and off Green LED

void setup()
{
Serial.begin(9600) ; //Starting serial Communication at baud rate of
9600
pinMode(high,OUTPUT); //declaring LED pins as OUTPUT
pinMode(low,OUTPUT);
}
void loop()
{
int temp_reading = analogRead(1) ; //reading analog voltage and
storing it in an integer
temp_reading = temp_reading * 0.48828125; //converting reading into
Celsius
Serial.print("TEMPRATURE = "); //to Display on serial monitor
Serial.print(temp_reading); //Temperature reading
Serial.print("*C"); //TEMPRATURE = 27*C ETC
Serial.println(); //To end the line
delay(5000); //1 Sec delay
/*
LOGIC:
if (temperature (temp_reading) > 30 ° C )
turn on Yellow Leds
turn off Green Leds
else
turn off Yellow Leds
turn on Green Led
*/
if(temp_reading > 40) // This is the control statement
{
digitalWrite(high,HIGH) ;
digitalWrite(low,LOW) ;
}
else
{
digitalWrite(high,LOW) ;
digitalWrite(low,HIGH) ;

}
}

A red LED turned on when the temperature reading from the sensor was 40 degrees Celsius and the
Green LED turned on when the temperature fell below 30 degrees Celsius.

b.
Arduino based distance sensor uses 2 sensors along with Arduino. The two
sensors are infrared proximity sensor and ultrasonic range finding sensor. The IR
sensor has a light source, which bounces the infrared light from the objects to the
sensor. The ultrasonic range finder sensor produces the high frequency sound
waves and calculates the echo time, to determine the distance.
(i) Design a distance measuring sensor using the Ultrasonic Sensor HC - SR04
and the Arduino Uno board. Design an experiment to calibrate the sensor for
measurements from 0 to 1 m. Present the results of the calibration.
Design an Arduino Based Water Level Controller that will control the water
(ii) level of a tank automatically by detecting the water level by using sensors (e.g.,
the Ultrasonic Sensor HC - SR04). As the water level drops below a preset
value, the circuit alerts the user by sounding an alarm and it automatically.
int duration;
float distance;
int enchopin = 13;
int trigpin = 9;
void setup()
{
Serial.begin(9600);
pinMode(enchopin,INPUT);
pinMode(trigpin,OUTPUT);
digitalWrite(trigpin,LOW);
delay(200);
}
void loop()
{
digitalWrite(trigpin,HIGH);
delay(500);
digitalWrite(trigpin,LOW);
duration = pulseIn(enchopin,HIGH);
Serial.println("the distance is ");
distance = duration*0.034/2;
Serial.print(distance);
Serial.print("cm");
Serial.println();
delay(1000);

There’s a continuous reading on the serial of the Arduino IDE interface when there are changes done
in proximity between the Utrasonic sensor and the object and there’s a 2 second delay put in place
to make sure the object whose proximity is in question can settle well before a reading is taken.
int duration;
float distance;
int enchopin = 13;
int trigpin = 9;
int buzzer = 7;
int Red = 6;
int Green = 5;
int preset_value1 = 40;
int preset_value2 = 10;
void setup()
{
Serial.begin(9600);
pinMode(enchopin,INPUT);
pinMode(trigpin,OUTPUT);
pinMode(buzzer,OUTPUT);
pinMode(Red,OUTPUT);
pinMode(Green,OUTPUT);
digitalWrite(trigpin,LOW);
digitalWrite(Red,LOW);
digitalWrite(Green,LOW);
digitalWrite(buzzer,LOW);
delay(200);
}
void loop()
{
digitalWrite(trigpin,HIGH);
delay(500);
digitalWrite(trigpin,LOW);
duration = pulseIn(enchopin,HIGH);
Serial.println("the distance is ");
distance = duration*0.034/2;
Serial.print(distance);
Serial.print("cm");
Serial.println();
delay(1000);
if( distance > preset_value1)
{
digitalWrite(buzzer,HIGH);
digitalWrite(Green,HIGH);
digitalWrite(Red,LOW);
}
else if( distance < preset_value2)
{
digitalWrite(buzzer,HIGH);
digitalWrite(Red,HIGH);
digitalWrite(Green,LOW);
}
else
{
digitalWrite(buzzer,LOW);
digitalWrite(Red,LOW);
digitalWrite(Green,LOW);
}
}

There’s a continuous reading on the serial of the Arduino IDE interface when there are changes done
in proximity between the Utrasonic sensor and the object and there’s a 2 second delay put in place
to make sure the object whose proximity is in question can settle well before a reading is taken and
a buzzer sounds to signify either very low water levels and very high water levels, the red LED turns
on in Synchrony with the buzzer when the distance becomes very small resembling very high water
levels and the Green LED turns on together with the sound of a buzzer when the distance is greater
signifying very low water level.

All the systems in question were, connected, programmed and launched thus the whole
practical’s scope was illuminated on the actual interface.

All the circuits and projects worked out so well, according to the script they were supposed
to follow; the challenges were on the amount of space on the breadboard which was almost
elapsed and it was too difficult to debug errors on the hardware once the whole circuit was
connected. However, the practical was a success, being well familiarized with the
equipment and managing the new interface of Arduino C to program the Arduino UNO and
the components on the board; thus, the whole of the practical’s aim was achieved.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy