This circuit consists of an Arduino UNO microcontroller, a red two-pin LED, a resistor, and a 9V battery. The Arduino UNO is used to control the LED, turning it on and off with a digital output pin. The resistor is used to limit the current flowing through the LED to prevent damage. The 9V battery provides the power source for the circuit.
void setup() {
pinMode(7, OUTPUT); // Set digital pin 7 (D7) as an output
}
void loop() {
digitalWrite(7, HIGH); // Turn the LED on (HIGH is the voltage level)
delay(1000); // Wait for a second (1000 milliseconds)
digitalWrite(7, LOW); // Turn the LED off by making the voltage LOW
delay(1000); // Wait for a second
}
This code is written for the Arduino UNO microcontroller. It initializes digital pin 7 (D7) as an output in the setup()
function. In the loop()
function, it turns the LED on and off with a one-second interval between each state change. The digitalWrite()
function is used to set the voltage level of pin D7 to HIGH or LOW, which in turn controls the LED connected through the resistor.