Hello Arduino Forum,
Using Uno to turn on seven LEDs using eight motion detectors (PIR [passive infrared]).
Working to get one PIR to turn on one LED.
Sketch copied herewith below.
This is a schematic of the circuit.
It works as designed using a bread board for the components and
a USB connector to the Uno. That is,
when the PIR goes high and sends 2.29v signal to Pin A0, there
is a 1.76v signal at Pin2. (The output from Pin2 will be used to
turn on a transistor which will send 12v to LED.)
The system is designed to work on a single 12 volt power source.
So a barrel jack plug pig tail was run from the power source
on the bread board to barrel jack on the Uno.
When the Uno was plugged into the 12 volts the reading at
Pin 2 goes to .42v and does not change whether the PIR is
low or high. And the LED comes on and does not go off.
Why does the power source to the Uno make the system work so
differently?
Allen Pitts, Dallas TX
+++++++++ sketch PIR to Arduino ++++++++++++++++++++++++++++
int led = A0; // the pin that the sensor is attached to
int sensor = 2; // the pin that the sensor is attached to
void setup() {
pinMode(led, OUTPUT);
pinMode(sensor, INPUT);
Serial.begin(9600);
}
void loop() {
int sensorval = digitalRead(sensor);
Serial.println(sensorval);
if (sensorval == LOW) {
digitalWrite(led, HIGH);
}else{
digitalWrite(led, LOW);
}