Neue Artikel

Sonderangebote

Pay with credit cards Pay with credit cards Pay with credit cards Pay with credit cards Pay with credit cards Pay with credit cards Pay with credit cards Pay with credit cards Pay with credit cards Pay with credit cards

Eksempel kode til brug med Jord Fugtigheds Sensor

Med denne kode vil man få en analog måling på fugtigheds niveauet når denne ændrer sig.

Sensoren kan købes i vores shop

/* Trab.dk Example Sketch
 Jord Fugtigheds Sensor
 Connections from Sensor to Arduino:
 Vcc to +5v
 Gnd to Gnd
 D0 to D2
 A0 to A0
 kundeservice@trab.dk */

volatile boolean detected = false;
int analogPin = 0;

void setup() {
     /* Assign interupt 0 to the function sensorInterupt(), and set to FALLING.
     interupt 0 is triggered at arduino pin: D2 */

     attachInterrupt(0, sensorInterupt, FALLING);
     Serial.begin(9600);
}

void sensorInterupt () {
     detected = true;
}

void loop() {
     delay(500);
     Serial.print("Moisture level is now: ");
     Serial.println( analogRead(analogPin));

     if (detected) {
          Serial.println("Moisture level change detected");
          detected = false;
     }
}