10. Output Devices
Group Assignment
For our group assignment, we determined how to measure the power consumption of an output device. We then experimented measuring voltage and currents of an output device to measure power. Output device being a motor with a fan.
Research
For this weeks assignment, I added a buzzer module (Piezo Speaker) using Arduino Uno. This weeks board still had the fire sensor attached, making my plan to create a mini fire alarm.
Buzzer

The following code works because tone(buzzer, 1000) sends a 1KHz sound signal to pin 9, delay(1000) pause the program for a second and noTone(buzzer) stops the signal sound. The loop makes the short beeping sound run again and again.
Code For Buzzer Module
I added a basic code for the buzzer module I found on Arduino Projects Hub. I then edited my original fire sensor code using the buzzer coding to give the following code. The use of tone(pin, frequency, duration) was added to make it so the buzzer silences when there is no fire detected. Arduino Modules - Buzzer Module
// lowest and highest sensor readings:
const int sensorMin = 0; // sensor minimum
const int sensorMax = 1024; // sensor maximum
void setup() {
// initialize serial communication @ 9600 baud:
Serial.begin(9600);
pinMode(A0, INPUT);
pinMode(D2,OUTPUT);
}
void loop() {
// read the sensor on analog A0:
int sensorReading = analogRead(A0);
// map the sensor range (four options):
// ex: 'long int map(long int, long int, long int, long int, long int)'
int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
// range value:
switch (range) {
case 0: // A fire closer than 1.5 feet away.
Serial.println("** Close Fire **");
tone(D2, 1000);
break;
case 1: // A fire between 1-3 feet away.
Serial.println("** Distant Fire **");
break;
case 2: // No fire detected.
Serial.println("No Fire");
noTone(D2);
break;
}
delay(1); // delay between reads
}
Working Fire Buzzer