CLASE 1 - ENCENDIDO Y APAGADO DE UN LED CON UN PULSADOR / BOTON - TINKERCAD | ARDUINO
How to Turn On and Off an LED with a Button
Introduction to the Lesson
- The video begins with an introduction, stating that this lesson will cover how to turn on and off an LED using a button.
- The instructor mentions that they will use a 4-terminal push button instead of the previously used 2-terminal version.
Components Required
- Key components include:
- A 330-ohm resistor for the LED.
- A push button.
- An Arduino board connected via a breadboard (protoboard).
Wiring Setup
- The wiring involves connecting:
- The negative side of the LED through a resistor to ground.
- Terminal connections of the push button: focusing on terminals A1 and A2.
- The positive side of the LED connects to digital pin 2, while one terminal of the push button connects to digital pin 3.
Coding Overview
- Transitioning from block coding to text coding, the instructor emphasizes removing unnecessary parts from previous code snippets.
- They introduce variable declaration for input/output pins, specifically setting up pin modes for reading signals.
Logic Implementation
- An
ifstatement is introduced in programming logic:
- It checks if the signal from pin 3 is HIGH (button pressed).
- If true, it executes code to turn on the LED; otherwise, it turns off.
Simulation and Testing
- After completing coding without errors, simulation starts.
- Observations during simulation show that when not pressed, the LED remains off; pressing it turns on the LED.