Skip to content

Instantly share code, notes, and snippets.

@ceiborg
Last active September 24, 2019 14:34
Show Gist options
  • Select an option

  • Save ceiborg/b5bd4f93f05a746464eeea0db237c60b to your computer and use it in GitHub Desktop.

Select an option

Save ceiborg/b5bd4f93f05a746464eeea0db237c60b to your computer and use it in GitHub Desktop.
Sensor Movimiento PIR
/*
#############%@
#### #########%
## #########&
#% ##########
### ############
################### ceiborg.com
################### tecnotextiles
##################
#################
##############
##
#
*/
// Definir
const int PIR = 4; // pin 4 va a la señal del sensor de movimiento
const int LED = 13;
int pir_lectura = 0;
void setup() {
// Configuración
pinMode(LED, OUTPUT); // Configurar LED como salida o OUTPUT
pinMode(PIR, INPUT); // Configurar pir como entrada o INPUT
Serial.begin(9600); // Configurar el puerto serial a 9600 por si queremos monitoriar
}
void loop() {
// Código principal donde ocurren en loop
// Encender LED si hay movimiento
pir_lectura = digitalRead(PIR); //leer el pin del sensor de movimiento PIR
Serial.println (pir_lectura);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment