0% found this document useful (0 votes)
13 views3 pages

Arduino Basics in MPI Lab 9

This document summarizes Burhan Ahmed Satti's work on MPI Lab 9. It includes his name, student ID, class, and lab assistant. The objectives were to introduce Arduino, its basic architecture, and the Arduino IDE. The tools used were the Arduino IDE. Two tasks were completed: 1) Read analog voltage from pin A0 and use the value to blink an LED, and 2) Read voltage from pin A5 and light an onboard LED if the voltage drops below a threshold.

Uploaded by

Burhan Ahmed
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)
13 views3 pages

Arduino Basics in MPI Lab 9

This document summarizes Burhan Ahmed Satti's work on MPI Lab 9. It includes his name, student ID, class, and lab assistant. The objectives were to introduce Arduino, its basic architecture, and the Arduino IDE. The tools used were the Arduino IDE. Two tasks were completed: 1) Read analog voltage from pin A0 and use the value to blink an LED, and 2) Read voltage from pin A5 and light an onboard LED if the voltage drops below a threshold.

Uploaded by

Burhan Ahmed
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

MPI LAB

LAB 9
Handling Arduino

Name : Burhan Ahmed Satti


Enrollment No. : 01-134172-065
Class : BSCS 4-A
Subject : MPI Lab
Lab Assistant : Muhammad Atif

Objectives
•Introduction to Arduino
•Introduction to basic architecture of Arduino
•Learning the use of Arduino IDE.

Tools Used
•Arduino IDE
BSCS 4-A Burhan Ahmed Satti 01-134172-065

Task No. 9.1


Write a program to measure analog voltage analog data from channel A0 and display the digi-
tized values on the serial monitor. Use the value as time delay to blink/toggle of led.
Solution
int sensorPin = A0; // select the input pin for the potentiometer
int sensorValue; // variable to store the value coming from the sensor

void setup() {
// start serial communication
[Link](9600);
}

void loop() {
// read the value from the sensor:

sensorValue = analogRead(sensorPin);

//Print the converted result to arduino terminal

[Link](sensorValue);

analogWrite(13, sensorValue);

delay(sensorValue);
}

Result

Conclusion
Task is done.

MPI Lab Page 2 of 3


BSCS 4-A Burhan Ahmed Satti 01-134172-065

Task No. 9.2


Connect potentiometer to the analog channels A5 and write a program which reads & displays
Voltage (V). If V goes below a threshold, on board LED should light up.
Solution
int sensorPin = A5; // select the input pin for the potentiometer
float sensorValue; // variable to store the value coming from the sensor
float VoltageValue;

void setup() {
// start serial communication
[Link](9600);
pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
// read the value from the sensor:

sensorValue = analogRead(sensorPin);

//Print the converted result to arduino terminal

VoltageValue = (sensorValue/1023)*5;

[Link](VoltageValue);

if(VoltageValue < 2.5)


digitalWrite(LED_BUILTIN, LOW);
else
digitalWrite(LED_BUILTIN, HIGH);

delay(1000);
}

Result

Conclusion
Task is done.

MPI Lab Page 3 of 3

You might also like