El LED está encendido hasta que pulsamos el botón y se apaga al pulsar.
Materiales:
- 2 resistencias 330 Ohm.
- 1 led .
- 1 pulsador.
CÓDIGO:
int LED = 10 ;
int boton = 6;
void setup()
{
pinMode( LED, OUTPUT) ; // LED como salida
pinMode( boton , INPUT) ; //botón como entrada
}
void loop()
{
int valor = digitalRead(boton) ; // leemos el valor de boton en valor
digitalWrite( LED, valor) ;
}
int LED = 10 ;
int boton = 6;
void setup()
{
pinMode( LED, OUTPUT) ; // LED como salida
pinMode( boton , INPUT) ; //botón como entrada
}
void loop()
{
int valor = digitalRead(boton) ; // leemos el valor de boton en valor
digitalWrite( LED, valor) ;
}
int LED = 10 ; int boton = 6; void setup() { pinMode( LED, OUTPUT) ; // LED como salida pinMode( boton , INPUT) ; //botón como entrada } void loop() { int valor = digitalRead(boton) ; // leemos el valor de boton en valor digitalWrite( LED, valor) ; }