0% found this document useful (0 votes)
11 views6 pages

Lê Led

Leitura do led

Uploaded by

claudio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views6 pages

Lê Led

Leitura do led

Uploaded by

claudio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

To use an LED with an Arduino, you can

follow these simple steps. Here’s a basic


guide on how to set up an LED circuit and
control it using an Arduino.

### Components Needed:

1. Arduino board (e.g., Arduino Uno)

2. LED (any color)

3. Resistor (220Ω to 1kΩ is typically used)

4. Breadboard and jumper wires (optional,


for easy connections)

### Circuit Diagram:

2
1. **Connect the longer leg (anode) of the
LED** to a digital pin on the Arduino (e.g.,
pin 9).

2. **Connect the shorter leg (cathode) of


the LED** to one end of the resistor.

3. **Connect the other end of the


resistor** to the GND (ground) on the
Arduino.

### Basic Code Example:

Here’s an example of code to blink the


LED on and off:

```cpp

// Define pin number where the LED is


connected

3
const int LED_PIN = 9;

void setup() {

// Set the LED pin as an OUTPUT

pinMode(LED_PIN, OUTPUT);

void loop() {

digitalWrite(LED_PIN, HIGH); // Turn the


LED on

delay(1000); // Wait for one second

digitalWrite(LED_PIN, LOW); // Turn the


LED off

delay(1000); // Wait for one second

4
}

```

### Explanation:

- **pinMode(LED_PIN, OUTPUT);**: Sets


the specified pin to output mode, allowing
it to control the LED.

- **digitalWrite(LED_PIN, HIGH);**: Sends


a HIGH signal to the LED pin, turning the
LED on.

- **digitalWrite(LED_PIN, LOW);**: Sends


a LOW signal to the LED pin, turning the
LED off.

- **delay(1000);**: Pauses the program for


1000 milliseconds (1 second).

5
### Additional Tips:

- You can change the delay time to make


the LED blink faster or slower.

- Try connecting multiple LEDs and


control them independently by assigning
them to different pins.

If you have any specific questions about


your project or need further information,
feel free to ask!

Esta mensagem foi gerada por Nova -


baixe-a gratuitamente:

https://novaappai.page.link/
FGxee8AwT6iyPo4o6

You might also like