embedded system,arduino,raspberry pi,msp430f169, ARM7

Sunday, April 13, 2014

On 8:20 AM by EDUCATION   No comments
This is the tutorial explains about how to connect the reed switch with arduino
the simple program for the reed switch

//Turn on LED while reed switch is closed

#define LED 13     //pin for the LED
#define SWITCH 7   //input for REED SWITCH

int val = 0;       //used to store input value

void setup() {
  pinMode(LED, OUTPUT);   //tell arduino LED is an output
  pinMode(SWITCH, INPUT);   //SWITCH is input
}

void loop(){
  val=digitalRead(SWITCH);   //read input value and store it
 
  //check whether input is HIGH (switch closed)
  if (val==HIGH) {
    digitalWrite(LED, HIGH);   //turn LED on
  } else{
    digitalWrite(LED, LOW);
  }
}
pls check the video how the reed switch will work


 

0 comments:

Post a Comment