Definir.docx

  • Uploaded by: JAIR
  • 0
  • 0
  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Definir.docx as PDF for free.

More details

  • Words: 111
  • Pages: 1
// Definir const int PIR = 2; // pin 2 va a la señal del sensor de movimiento const int LED = 13; int pir_lectura;

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 }

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 if (pir_lectura == HIGH) { digitalWrite(LED, HIGH); // prende LED Serial.println("Movimiento detectado"); } else { digitalWrite(LED, LOW); // apagar LED Serial.println("No hay movimiento"); } }

More Documents from "JAIR"