Anda di halaman 1dari 6

ICT114 – Robotics and Embedded Systems Page number 1

Don Jose Yulo Sr. Blvd. Canlubang, Calamba City, Laguna


Laboratory Activity No. 3
Lesson Title: The Potentiometer
Laboratory Objectives:  Apply control structures in developing Arduino source
codes.
 Apply and connect the Potentiometer to Arduino board.
 Create a source code that will use the Potentiometer
through the Arduino board.

I. Materials Needed:

No. Tools/ Materials/ Equipment Quantity Details


1 Light Emitting Diode (LED) 1 Any Color
2 Resistor 3 1k Ohm Resistor
3 Potentiometer 1 10k PCB Mount
4 Arduino UNO 1
5 Solderless Breadboard 1
6 Male to Male Wires 6
7 USB Type A to USB Type B Connector 1
8 Computer System with Arduino IDE Installed 1

II. Activity Proper


A. Introduction

Potentiometer - A potentiometer is a simple knob that provides a


variable resistance, which we can read into the Arduino board as an
analog value. In this example, that value controls the rate at which an
LED blinks.
(Source: https://www.arduino.cc/en/tutorial/potentiometer )

REMINDERS ON HANDLING THE ARDUINO BOARD

1. Prevent the male pins from touching each other, as well as the leads, on the bottom of the
board.

2. Always place the board on a non-conducting surface

3. Best practice is to hold the boards on its sides/edges.

4. Another best practice is to unpower the board when adding or removing components or
connecting or disconnecting modules.

B. Setting Up

1. Setup the LEDs, wires, resistors, potentiometer, and solderless breadboard as


shown in the illustration
ICT114 – Robotics and Embedded Systems Laboratory Activity No. 3 – Quarter 1
ICT114 – Robotics and Embedded Systems Page number 2
Don Jose Yulo Sr. Blvd. Canlubang, Calamba City, Laguna

(Image Source: Fritzing.org)

Assign the following device to the Arduino Pins

DEVICE ARDUINO PIN


A. Light Emitting Diode & Resistor
Anode + Resistor Pin #9
Cathode GND
B. Potentiometer
Terminal (IN) +5V
Wiper A0 (Analog Pin)
Terminal (GND) GND

ICT114 – Robotics and Embedded Systems Laboratory Activity No. 3 – Quarter 1


ICT114 – Robotics and Embedded Systems Page number 3
Don Jose Yulo Sr. Blvd. Canlubang, Calamba City, Laguna
Actual Setup

(Image Source: https://www.sunfounder.com/learn/lesson-4-controlling-an-led-by-potentiometer-super-kit.html)

2. Connect the Arduino UNO to USB Cable Type B and the other end of the USB
connector connect it to a Computer System.

3. Open the Arduino IDE in the Computer System and make sure to check and
configure the board in the ‘Tools’ option.

ICT114 – Robotics and Embedded Systems Laboratory Activity No. 3 – Quarter 1


ICT114 – Robotics and Embedded Systems Page number 4
Don Jose Yulo Sr. Blvd. Canlubang, Calamba City, Laguna
4. Select the serial device of the Arduino board from the Tools > Serial Port menu

5. Disconnect-reconnect the USB of the Arduino to find out which port to pick, or
use the Device Manager.

C. Coding the Instructions

1. Type the program below in your Arduino IDE.

//Controlling led by potentiometer


//Rotate the shaft of the potentiometer and you should see the luminance of the LED
change.
//Email:support@sunfounder.com
//Website:www.sunfounder.com
//2015.5.7

const int analogPin = A0; //the analog input pin attach to analog pin A0
const int ledPin = 9; //the led attach to pin 9
int inputValue = 0; //variable to store the value coming from sensor
int outputValue = 0; //variable to store the output value

void setup()
{
}
void loop()
{
inputValue = analogRead(analogPin); //read the value from the sensor
outputValue = map(inputValue,0,1023,0,255);
//Convert from 0-1023 proportional to the number of a number of from 0 to 255

analogWrite(ledPin,outputValue); //turn the led on depend on the output value


}

ICT114 – Robotics and Embedded Systems Laboratory Activity No. 3 – Quarter 1


ICT114 – Robotics and Embedded Systems Page number 5
Don Jose Yulo Sr. Blvd. Canlubang, Calamba City, Laguna
D. Uploading the Instructions to the Arduino Board

2. Click “Upload” to check the code and subsequently upload the sketch to your board

3. If upload is successful, the message “Done Uploading” will appear in the status bar

4. Check your prototype if it is working or not.

ACTIVITY

1. Setup 6 LEDs and 6 Resistors on your breadboards. Connect the LEDs to your Arduino board. You
will learn in this activity how to light up a series of LEDs attached to pins 2 through 7 of the Arduino
board, with certain limitations (the pins have to be numbered contiguously, and the LEDs have to
be turned on in sequence). You will use Array and For Loop. Please see below setup. (Please refer to
lecture PowerPoint presentation for more guidance)

ICT114 – Robotics and Embedded Systems Laboratory Activity No. 3 – Quarter 1


ICT114 – Robotics and Embedded Systems Page number 6
Don Jose Yulo Sr. Blvd. Canlubang, Calamba City, Laguna
PERFORMANCE TASKS

1. Based on this laboratory activity, add 2 more Light Emitting Diodes and 2 Resistors.
Create an Arduino prototype that will light the one LED at a time in sequence using a
potentiometer.

1. Jason C. Alcarez, MakerTek Robotics and Embedded Systems: (TechFactors, Inc. Philippines), 48

ICT114 – Robotics and Embedded Systems Laboratory Activity No. 3 – Quarter 1

Anda mungkin juga menyukai