Skip to content

Commit 131fcbd

Browse files
authored
Interruptor
1 parent 560b8c1 commit 131fcbd

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Interruptor.ino

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
int led = 4; //Declaramos que o LED está na porta digital 4
2+
int botao = 3; //Declaramos que o LED está na porta digital 3
3+
int estadoLED = 0; //Variável com os estados do LED (0 LOW, 1 HIGH).
4+
5+
void setup () // inicia o void setup
6+
{
7+
pinMode(led, OUTPUT); // Definindo o LED como saída
8+
pinMode(botao, INPUT); // Definindo o Botão como entrada
9+
10+
} // encerra o void setup
11+
12+
void loop ( ) { // Inicia void loop
13+
14+
if (digitalRead(botao) == HIGH) // Se caso o botão for pressionado
15+
{
16+
estadoLED = !estadoLED; // o Estado do LED é alterado, ou seja o LED liga
17+
18+
digitalWrite(led,estadoLED);
19+
while(digitalRead(botao) == HIGH); // Equanto o botão não for pressionado novamete, o LED continua ligado
20+
21+
delay(100); // Delay de 100 milissegundos
22+
}
23+
}

0 commit comments

Comments
 (0)