Hello,
I started working with Arduino's about a month ago, and decided to do my first big project.
So I wanted to make an automatic alcohol dispenser using one of those cheap IR sensors and an Arduino Pro Micro.
I've already written the code, and I'm waiting for the parts, but I wanted some advice on what should I use to power the whole thing.
Since both the relay and the water pump are 5v, I think I can use an USB charger capable of supplying 1.50 amps.
I'm wondering if I can power the Arduino, the relay and the pump all from the same charger, by just striping the wires, and connecting them to all of the inputs. Will this work or will it cause any problems?
I actually have written the code in a way so it pumps alcohol for 1 second then stops accepting any signal from the IR sensor for about 5 seconds and only after that it can pump again.
I'm gonna be honest with you, I found the PIR sensor part of the code itself on some website that I don't remember so it would be easier to start.
I'm not sure but I think that the purpose of that variable is to tell if something is in the way of the sensor, to detect motion. LOW should be the state when there's no motion and then it switches to HIGH when there's motion. I'm not sure, I might be completely wrong.
Edit: After messing around a bit more with the 'pirState' variable I'm not really sure what was it's purpose, it was present in some lines of the code, but after changing the parts that contained 'pirState' to 'inputPin' and totally removing the 'pirState' variable from the start of the code, it works exactly the same way...