This circuit is designed to monitor voltage levels and provide visual and audible alerts when a certain threshold is exceeded. It includes an LM358 operational amplifier, a set of resistors, a rotary potentiometer, an Arduino UNO microcontroller, an LM317 voltage regulator, a 12V battery, a 3.3V battery, a buzzer, and an HC-05 Bluetooth module. The Arduino UNO is programmed to read the voltage level from the LM358 output, compare it to a predefined threshold, and activate an LED and a buzzer if the threshold is crossed.
#include <UnoWiFiDevEd.h>
// Define pin connections
const int voltagePin = A0; // Analog pin to read the voltage
const int ledPin = 2; // Digital pin to control the LED
const int buzzerPin = 3; // Digital pin to control the buzzer (optional)
// Define the voltage threshold
const int threshold = 500; // Adjust based on your needs
void setup() {
pinMode(ledPin, OUTPUT); // Set LED pin as output
pinMode(buzzerPin, OUTPUT); // Set buzzer pin as output (optional)
Serial.begin(9600); // Initialize serial communication for debugging
}
void loop() {
// Read the voltage from the measurement circuit
int voltageReading = analogRead(voltagePin);
// Print the voltage reading for monitoring
Serial.print("Voltage Reading: ");
Serial.println(voltageReading);
// Check if the voltage exceeds the threshold
if (voltageReading > threshold) {
digitalWrite(ledPin, HIGH); // Turn the LED on
digitalWrite(buzzerPin, HIGH); // Turn the buzzer on (if used)
} else {
digitalWrite(ledPin, LOW); // Turn the LED off
digitalWrite(buzzerPin, LOW); // Turn the buzzer off (if used)
}
delay(1000); // Wait for 1 second before the next reading
}
This code is designed to run on an Arduino UNO microcontroller. It reads an analog voltage value from pin A0, which is connected to the output of an LM358 operational amplifier. If the voltage exceeds a predefined threshold, it activates an LED and a buzzer to alert the user. The code also includes serial communication for debugging purposes.