Hello I am trying to utilize the PIR sensor with conditionals in the arduino language and I wrote this very simple code to see if the sensor works;
int readpin=11;
int ledpin=7;
int readval;
void setup() {
Serial.begin(2000000);
pinMode(readpin, INPUT);
pinMode(ledpin,OUTPUT);
}
void loop() {
readval=digitalRead(readpin);
Serial.println(readval);
if (readval==1){
pinMode(ledpin, HIGH);
}
else {
pinMode(ledpin,LOW);
}
}
and it seems like the sensor does work and I see the the value of 1 on the serial monitor when it detects movement however it does not turn on the led hooked up to pin 7. I made sure the LED is actually working. (The PIR sensor out is connected to pin 11).