Circuit Documentation
Summary
This circuit is designed around an Arduino UNO microcontroller and includes a variety of components such as an HC-SR04 Ultrasonic Sensor, multiple LEDs of different colors, and resistors. The circuit is powered by a pair of 18650 Li-ion batteries connected through a 2.1mm Barrel Jack with Terminal Block. The LEDs are controlled by the Arduino UNO and are connected with resistors to limit the current through them. The HC-SR04 Ultrasonic Sensor is interfaced with the Arduino for distance measurement.
Component List
Microcontroller
- Arduino UNO: A microcontroller board based on the ATmega328P. It has digital input/output pins, analog inputs, a USB connection for programming, and power management features.
Sensors
- HC-SR04 Ultrasonic Sensor: A sensor that measures distance by emitting ultrasonic waves and measuring the time taken for the echo to return.
LEDs
- LED: Two Pin (blue): A blue light-emitting diode that emits blue light when powered.
- LED: Two Pin (yellow): A yellow light-emitting diode that emits yellow light when powered.
- LED: Two Pin (red): A red light-emitting diode that emits red light when powered.
- LED: Two Pin (green): A green light-emitting diode that emits green light when powered.
Resistors
- Resistor: A passive two-terminal electrical component that implements electrical resistance as a circuit element. In this circuit, all resistors have a value of 220 Ohms.
Power Components
- 2.1mm Barrel Jack with Terminal Block: A connector used to interface external power sources to the circuit.
- 18650 Li-ion Battery x 2: A pair of rechargeable lithium-ion batteries used to power the circuit.
Wiring Details
Arduino UNO
- Digital pins D2 to D8 are connected to the anodes of the LEDs through 220 Ohm resistors.
- Digital pins D12 and D13 are connected to the TRIG and ECHO pins of the HC-SR04 Ultrasonic Sensor, respectively.
- The 5V and GND pins provide power to the HC-SR04 Ultrasonic Sensor.
- The GND pin is also connected to the cathodes of all LEDs.
HC-SR04 Ultrasonic Sensor
- VCC connected to Arduino's 5V.
- TRIG connected to Arduino's D12.
- ECHO connected to Arduino's D13.
- GND connected to Arduino's GND.
LEDs
- The anode of each LED is connected to an Arduino digital pin (D2 to D8) through a 220 Ohm resistor.
- The cathode of each LED is connected to the Arduino's GND.
Resistors
- Each 220 Ohm resistor is connected in series with an LED to limit the current through the LED.
Power Components
- The positive terminal of the 18650 Li-ion batteries is connected to the POS pin of the Barrel Jack.
- The negative terminal of the 18650 Li-ion batteries is connected to the NEG pin of the Barrel Jack.
Documented Code
void setup() {
}
void loop() {
}
The provided code is a template with empty setup()
and loop()
functions, which are the standard structure for Arduino sketches. The setup()
function is intended for initialization code that runs once when the program starts, such as configuring pin modes. The loop()
function contains the main logic of the sketch, which runs repeatedly as long as the Arduino is powered.
For this circuit, the setup()
function would typically be used to initialize the pins connected to the LEDs as outputs and the pins connected to the HC-SR04 sensor. The loop()
function would handle the logic for turning the LEDs on and off and reading distance measurements from the HC-SR04 sensor. However, the actual implementation details are not provided in the input code.