Close

zrazkomer

Úvodní stránka Fórum Hardware Senzory zrazkomer

  • Toto téma obsahuje celkem 1 odpověď. Do diskuze (2 diskutující) se naposledy zapojil uživatel Luke_CZ a poslední změna proběhla před 7 roky a 5 měsíci.
Aktuálně jsou na stránce zobrazeny 2 příspěvky - 1. až 2. (celkem z 2)
  • Autor
    Příspěvky
  • #9149
    lukacenko
    Účastník

    ahojte prosim vas neviete mi pomoct s tymto zrazkomerom wh 1080

    ako ho pripojit na arduino a aby zarucene fungoval. zatial som to skusal tak ze som to napojil na pin prerusenie napriklad D2 + na GND tak ako tak to funguje ale ked chcem pridat dalsie cidla tak uz to nereaguje.

    dakujem vam

    
    
    /*
    
    Arduino sketch to record the switching of the reed switch in the rain gauge
    
    The sketch works by counting the number of times the reed switch changes status (HIGH or LOW)
    
    */
    
    const int REED = 2;              //The reed switch outputs to digital pin 2
    int val = 0;                    //Current value of reed switch
    int old_val = 0;                //Old value of reed switch
    int REEDCOUNT = 0;              //This is the variable that hold the count of switching
    int cassekund = 2; 
    
    void setup(){
    
     Serial.begin(9600);
     pinMode (REED, INPUT_PULLUP); //This activates the internal pull up resistor
    
    }
    
    void loop(){
     //cassekund += 2;
     //Serial.println(cassekund); 
     val = digitalRead(REED);      //Read the status of the Reed swtich
     if ((val == LOW) && (old_val == HIGH)){    //Check to see if the status has changed
       delay(10);                   // Delay put in to deal with any "bouncing" in the switch.
       REEDCOUNT = REEDCOUNT + 1;   //Add 1 to the count of bucket tips
       old_val = val;              //Make the old value equal to the current value
       Serial.print("Count = ");
       Serial.print(REEDCOUNT);  //Output the count to the serial monitor
    
     }
    
     else {
       old_val = val;              //If the status hasn't changed then do nothing
    
     }
    }
    
    
    #9153
    Luke_CZ
    Účastník

    A, píšeš cosi o přerušení som to napojil na pin prerusenie napriklad D2 + na GND , ale nikde v loop nepřerušuješ běh programu. Pokud dáš, jako ve tvém skeči, vše do loop, tak arduino zpracovává tuto smyčku a nic jiného ho nezajímá.

    B, tvůj skeč v loopu hlídá změnu na D2 a přičítá pulsy do proměnné REEDCOUNT, žádná jiná čidla, jak zmiňuješ ked chcem pridat dalsie cidla tak uz to nereaguje tam nevidím…

Aktuálně jsou na stránce zobrazeny 2 příspěvky - 1. až 2. (celkem z 2)
  • Pro reakci na toto téma se musíte přihlásit.