Last active
September 24, 2019 14:35
-
-
Save ceiborg/54add454f2a1df8fa9f8bc22682d581d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| #############%@ | |
| #### #########% | |
| ## #########& | |
| #% ########## | |
| ### ############ | |
| ################### 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; // variable que cuandno empieza el programa vale 0, despues le vamos a guardar otros numeros | |
| // el parlantito va una pata a una resistencia de 1K y la otra al pin 11 del arduino | |
| 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); | |
| if (pir_lectura == HIGH) { | |
| tone (11, 1000, 500);} // el primer parametro es el pin del arduino a donde esta conectado el positivo del parlantito, el segundo es la frecuencia | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment