Перейти к содержанию

GLULOLOKA1

Members
  • Постов

    2
  • Зарегистрирован

  • Посещение

Сообщения, опубликованные GLULOLOKA1

  1. Делаю сигналку на Arduino .

    Проблема такая.

    Скетч ик управления и скетч PIR Датчика по отдельности работают , а вместе нет.

    Хотелось бы узнать как это решить.

    Скетч и схема предвидена ниже .

    /*

    Сигналка

    */

    int calibrationTime = 10;

    //the time when the sensor outputs a low impulse

    long unsigned int lowIn;

    //the amount of milliseconds the sensor has to be low

    //before we assume all motion has stopped

    long unsigned int pause = 5000;

    boolean lockLow = true;

    boolean takeLowTime;

    int pirPin = 8; //вывод подключения PIR сенсора

    int Sirena = 13;

    int RECV_PIN = 2; //вход ИК приемника

    IRrecv irrecv(RECV_PIN);

    decode_results results;

    int PirPlus = 12;

    /////////////////////////////

    //SETUP

    void setup(){

    Serial.begin(9600);

    pinMode(pirPin, INPUT);

    pinMode(Sirena, OUTPUT);

    digitalWrite(pirPin, LOW);

    irrecv.enableIRIn(); // включить приемник

    pinMode(PirPlus, OUTPUT);

    //дадим датчику время на калибровку

    Serial.print("calibrating sensor ");

    for(int i = 0; i < calibrationTime; i++){

    Serial.print(".");

    delay(1000);

    }

    Serial.println(" done");

    Serial.println("SENSOR ACTIVE");

    delay(50);

    }

    ////////////////////////////

    //LOOP

    void loop(){

    if (irrecv.decode(&results))

    {

    if (results.value == 0xFF00FF) //код моей кнопки "2FD807F". У Вас он будет дугой

    {

    digitalWrite(PirPlus, HIGH);

    }

    if (results.value == 0xFF807F)//код моей кнопки "2FD40BF". У Вас он будет дугой

    {

    digitalWrite(PirPlus, LOW);

    }

    irrecv.resume();

    }

    if(digitalRead(pirPin) == HIGH){

    analogWrite(Sirena, 100); //the led visualizes the sensors output pin state

    if(lockLow){

    //makes sure we wait for a transition to LOW before any further output is made:

    lockLow = false;

    Serial.println("---");

    Serial.print("motion detected at ");

    Serial.print(millis()/1000);

    Serial.println(" sec");

    delay(50);

    }

    takeLowTime = true;

    }

    if(digitalRead(pirPin) == LOW){

    analogWrite(Sirena, 0); //the led visualizes the sensors output pin state

    if(takeLowTime){

    lowIn = millis(); //save the time of the transition from high to LOW

    takeLowTime = false; //make sure this is only done at the start of a LOW phase

    }

    //if the sensor is low for more than the given pause,

    //we assume that no more motion is going to happen

    if(!lockLow && millis() - lowIn > pause){

    //makes sure this block of code is only executed again after

    //a new motion sequence has been detected

    lockLow = true;

    Serial.print("motion ended at "); //output

    Serial.print((millis() - pause)/1000);

    Serial.println(" sec");

    delay(50);

    }

    }

    }

    post-190171-0-29898400-1428860080_thumb.png

×
×
  • Создать...