Control Activity 4
Control Activity 4
Experiment/Activity No. 4
Reading From an Analog Input Device
Objective/s:
1. Relate an output to a specified analog input
2. Write a program integrating input and output devices using Arduino IDE
3. Implement a simple application using embedded system
Materials: Arduino board, breadboard, jumper wires, active buzzer, and 10 kΩ-potentiometer.
Direction: Using Arduino IDE, write a program and implement a system that maps the
frequency of the sound of a buzzer to the resistance of the potentiometer. As the potentiometer is
turned clockwise the beeping sound gets faster.
A. Programming
Write the code and append a comment that describes the purpose of each line of code.
int buzzerPin = 2; // digital pin connected to the buzzer at pin 2
int potRead = A0; // analog pin connected to the potentiometer
float potVal; // set potVal as value that can store decimal numbers
int DT; // set DT as an integer
void setup(){
Serial.begin(9600); // sets it to exchange data with the serial monitor at 9600 bits per second
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
_____________________________________________________________________________