Electronics > Beginners
Arduino PIR
darinsquared:
--- Quote from: Wimberleytech on December 07, 2019, 10:13:54 pm ---
--- Quote from: darinsquared on December 07, 2019, 10:11:21 pm ---
--- Quote from: Wimberleytech on December 07, 2019, 10:04:57 pm ---What color is the LED? Red????
Can the PIR see it???
--- End quote ---
white. I cover the LED (it is directly on Arduino) and it make no difference.
--- End quote ---
I just ran an experiment using a red LED and it will indeed trigger the PIR and oscillate. Different code.
Next question. Is it a fresh 9V battery?
BTW, you did not need to test the PIR for a transition. The PIR is already handling that for you.
--- End quote ---
I covered the LED so it could not be triggering the PIR. If that was the case it should have occurred as well when the board was connected to computer?
I also noticed that when connected to computer the TX diode blinks before and after the LED turns ON and OFF. this does not occur connected to battery.
Wimberleytech:
Gotta go now...will come back to this later.
Kasper:
--- Quote from: darinsquared on December 07, 2019, 10:48:17 pm ---9V battery is putting out 6.8V.
--- End quote ---
Your battery seems low. Batteries sometimes change output voltage when load changes and it sometimes changes extra when battery is low.
Measure Vbat when led on and when led off.
Vbat (led on) = ___ V
Vbat (led off) = ___V
If it varies then do some experiments to see if turning led on/off triggers motion detection. Try a new battery, does that solve it? Do you have long battery wires? That causes extra voltage fluctuations with changing load.
Some PIRs can be sensitive to fluctuations in their supply voltage. The changing load from the LED can cause Vbatt to change and cause false trigger on PIR.
A picture of your setup and wiring could be helpful.
Wimberleytech:
--- Quote ---9V battery is putting out 6.8V.
How is your code different?
--- End quote ---
Your battery is dead.
--------------------
Here is my code
--------------------
int ledpin = 13; //Set the digital 13 to LED
int buzzPin = 6; // buzzer pin for pwm output
int PIRpin = 2; //Set the digital 2 to PIR
void setup() {
Serial.begin(9600);
pinMode( ledpin, OUTPUT); //initialize the led pin as output
pinMode( PIRpin, INPUT); //initialize the PIR pin as input
pinMode( buzzPin, OUTPUT); //initialize the buzzer pin as an output
}
int count = 0;
void loop() {
//Serial.print (count);
delay(1 * 100); //delay one hundred milliseconds
if (digitalRead(PIRpin) == HIGH) //Detecting whether the body movement information
{
count = 0;
digitalWrite(ledpin,LOW);//LED ON
}
else
{
count++;
}
if(count == 30)
{
digitalWrite(ledpin,HIGH);//LED ON
count=0;
}
}
Wimberleytech:
An arduino uno takes your input voltage and drops it across a diode and then regulates using a regulator with about 1V dropout voltage.
6.8 V - 0.7 V = 6.1 V
The regulator is just on the edge of stability.
In addition, the internal resistance will drop the open-circuit voltage from 6.8V to something lower (as current flows out of the battery).
Thus, for this application, your battery is dead (as stated in a previous post).
Navigation
[0] Message Index
[*] Previous page
Go to full version