You are on page 1of 12

Laboratory Experiment 4

COE 5
INPUTS

Push Buttons

Potentiometers

Light Dependent Resistors (LDR)


Potentiometers
A potentiometer is a resistor whose value changes smoothly as the
KNOB is turned. With three legs, the middle leg should be connected
to ANALOG IN 0 on the Arduino. The other two should be connected
to +5V and the other to GND respectively (ground).

ANALOG IN vs DIGITAL IN
Exercise 1: Potentiometer-Button-Led Circuit 1
 The purpose of the Potentiometer-Button-Led Circuit 1 is to demo
how Arduino will be controlling an LED via pushbutton
potentiometer and pushbutton.
Exercise 1: Potentiometer-Button-Led Circuit 1
Write the sketch below and verify the result.

This function re-maps a number from


one range to the other since the
analogRead returns a value in the range
of 0-1023 but analogWrite can only take
a value from 0-255
Exercise 2: Potentiometer-Button-Led Circuit 1
Write the sketch below and verify the result.
Exercise 3: LDR-LED Circuit 2
 The purpose of the LDR-LED Circuit 2 is to demo how Arduino can
change the blink rate of the LED using light dependent resistor
(LDR).
Exercise 2: LDR-LED Circuit 2
Write the sketch below and verify the result.
Activity
1. Change the speed at which the LED blinks based on the value of the
pot ONLY when the button is pressed. (In other words, you can adjust
the potentiometer, but it has no effect until you press the “ON”
button)

2. Use the LDR to control the pitch of a sound produced by a speaker.

Include comments in your program codes to explain/dissect the overall


program.
Have your work checked by your lab professor…..
Yours Program Codes Here!

(paste your program codes here)


Observations and Conclusions

(one/two pager only)


References

Arduino Cookbook
Recipes to Begin, Expand, and Enhance Your Projects
By Michael Margolis

Introduction to Arduino
by Alan G. Smith

Arduino On Line Courses

You might also like