The 9V Battery is a versatile and commonly used power source for a variety of electronic devices and projects. It is particularly favored in the realm of hobby electronics and prototyping, especially when a portable and compact power source is required. This type of battery is often used in applications such as smoke alarms, walkie-talkies, and as a convenient power source for Arduino-based projects.
The 9V battery has a simple two-terminal design:
Pin | Description |
---|---|
+ | Positive terminal (smaller, typically marked with a "+" sign) |
- | Negative terminal (larger, snap-on connector) |
Connecting to a Breadboard:
Connecting to an Arduino:
// This example demonstrates how to power an Arduino UNO with a 9V battery.
void setup() {
// Initialize the built-in LED pin as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
// Turn the LED on (HIGH is the voltage level)
digitalWrite(LED_BUILTIN, HIGH);
// Wait for a second
delay(1000);
// Turn the LED off by making the voltage LOW
digitalWrite(LED_BUILTIN, LOW);
// Wait for a second
delay(1000);
}
// Note: This code does not directly interact with the 9V battery.
// It assumes the Arduino is powered by the 9V battery through the power jack.
Note: The above code is a simple blink program that assumes the Arduino UNO is powered by the 9V battery. It does not include battery monitoring or power management features. Always ensure that the Arduino's power requirements are compatible with the 9V battery's output.