> For the complete documentation index, see [llms.txt](https://franzininho.gitbook.io/franzininho-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://franzininho.gitbook.io/franzininho-docs/exemplos/controle-brilho-de-led.md).

# Controle brilho de LED

Nesse exemplo é feito o controle do brilho do LED gradualmente. Para esse exemplo vamos usar a função analogWrite, que aciona a saída com PWM.

## Materiais

* Placa Franzininho;
* Protoboard;
* LED 3mm;
* Resistor 220;
* Jumpers macho/fêmea;

## Circuito

Na protoboard você pode montar o circuito para acionamento do LED da seguinte forma:

![](/files/-MJvXMsvaX0rlfrwZLdl)

## Sketch

```cpp
/*
  Franzininho
  Exemplo: Controle Brilho de LED - PWM

  Esse exemplo exibe como controlar a intensidade de brilho de um LED usando PWM
*/

const int LED = 1; //pino para o LED
int i = 0;        //utilizaremos essa variável para contagem auxiliar

void setup() {
 pinMode(LED,OUTPUT); //configura o pino do LED como uma saída
}

void loop() {
  //faz um loop de 0 a 255 (acende gradualmente)
  for (i = 0; i<255; i++) {
    analogWrite (LED, i);  // define o brilho do LED
    delay (10); //espere 10ms, pois analogwrite é um instantâneo e não veríamos nenhuma alteração
  }

  //faz um loop de 255 a 1 (apaga gradualmente)

  for (i = 255; i > 0; i--) {  
   analogWrite(LED, i); //define o brilho do LED
   delay(10);          //aguarda 10ms
  }
}
```

## Video

{% embed url="<https://www.youtube.com/watch?v=0W5Dos0NHsE>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://franzininho.gitbook.io/franzininho-docs/exemplos/controle-brilho-de-led.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
