Panier d’achat

Aucun produit dans le panier.

Capteur de porte/fenêtre MC38 Interrupteur magnétique

25.00 د.م.

31 en stock

Quantité Discount (%) Prix
1 - 29 25.00 د.م.
30+ 28 % 18.00 د.م.

Tutoriel : Utilisation MC38 interrupteur magnétique avec arduino (English)


Hardware Components

Arduino UNO R3 × 1
MC-38 Magnetic Sensor Anti Theft Alarm × 1
Male to Female jumper wire × 1

Software Apps

Arduino IDE

Interfacing MC-38 Magnetic Sensor Anti Theft Alarm with Arduino

Step 1: Circuit

The following circuit shows how you should connect Arduino to MC-38 module. Connect wires accordingly.
MC38 Sensor Arduino circuit

 

Step 2: Code

Upload the following code to your Arduino. This code displays the status of the switch in the serial window.
/* 

* Code d'exemple pour un capteur magnétique MC-38. 
* Réaliser par Micro-Electroniques Générales au Maroc 
* Visite notre site megma.ma 

*/
const int magnet_switch = 2;     // Magnet switch
const int ledPin =  13;      // LED pin

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(magnet_switch, INPUT_PULLUP);

  Serial.begin(9600);
}

void loop() {
  if (digitalRead(magnet_switch) == LOW) {
    Serial.println("Switch Closed");
    digitalWrite(ledPin, HIGH);
    while (digitalRead(magnet_switch) == LOW) {}
  }
  else {
    digitalWrite(ledPin, LOW);
  }
} 

Plus d’information visite notre page Facebook.


Avis

Il n’y a pas encore d’avis.

Soyez le premier à laisser votre avis sur “Capteur de porte/fenêtre MC38 Interrupteur magnétique”

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Tous les résultats de recherche
×