I need help with a simple code for a motion sensor.
The code is supposed to light an LED when the motion sensor receives the input of a servomotors movement, but in this test code it seems to ignore one of the inputs and only register the servos back turn. if someone could help that'd be great
#include <Servo.h>
Servo test;
const byte mt_sen_pin = A2;
const byte LED = 13;
int mt_sen_value;
void setup() {
// put your setup code here, to run once:
pinMode(mt_sen_pin,INPUT);
pinMode(LED,OUTPUT);
Serial.begin(9600);
test.attach(5);
}
void loop() {
// put your main code here, to run repeatedly:
delay(5000);
mt_sen_value = digitalRead(mt_sen_pin);
Serial.println(mt_sen_value);
test.write(180);
if(mt_sen_value>=0,5){
digitalWrite(LED,HIGH);
delay(1000);
digitalWrite(LED,HIGH);
}
if(mt_sen_value<=0.5){
digitalWrite(LED,LOW);
}
delay(5000);
test.write(-180);
delay(1000);
}