Introduction: Arduino Person Counter
I decided to make my own version of an arduino person counter after viewing Login258 tripwire and electro18 IR person counter. This is a great device that can be used to count the number of people who visit a store, detect if a soccer ball complete passed over a goal line, or even security. Additionally, two such setups could be used to construct a speedometer to measure the speed of cars down a one lane road. There are a number of devices that you could make with this or by making minor adjustments to the setup. This is my first instructable so I hope you enjoy!
Step 1: Parts List
Parts you'll need for making this project include:
1) Arduino uno
2) breadboard
3) LCD display
4) Photoresistor
5) Laser pointer
6) Assortment of jumper cables
7) A 10k and 220 ohm resistor
8) 10k potentiometer
Step 2: Circuit Diagram
1) Connect 5V power and ground to one side of the breadboard
2) Place the photoresistor to on the breadboard, connecting one end to 5V and pin7 of the arduino. Connect the other end to the Arduino's analogIn pin 0, and to ground through a 10k ohm resistor.
3) Place the LCD display on the breadboard and wire it according to the circuit diagram above. The register select (RS) pin controls where the characters will appear on the screen. The read/write pin (R/W) puts the screen in read or write mode. The enable (EN) tells the LCD that it will be receiving a command. The data pins (D0-D7) are used to send character data to the screen. There is also a connection for adjusting the contrast of the display using a potentiometer to control this.
4) The liquid Crystal library that comes with the arduino software handles all the writing to these pins, and simplifies the process of writing software to display characters. We'll get to this when we program the circuit. The two outside pins of the LCD (Vss and LED-) need to be connected to ground. Also, connect the R/W to pin to ground. This places the screen in write mode. The LCD power supply (Vcc) should be connnected directly to 5V. The LED+ pin on the screen connects to power through a 220 ohm resistor.
5) Connect: Arduino digital pin 2 to LCD D7, Arduino digital pin 3 to LCD D6, Arduino digital pin 4 to LCD D5, Arduino digital pin 5 to LCD D4. These are the data pin that tell the screen what to display.
6) Connect EN on the screen to pin 11 on your Arduino. RS on the LCD connects to pin 12. This pin enables writing to the LCD.
7) Place the potentiometer on the breadboard, connecting one end pin to power and the other to ground. The center pin should connect to the V0 on the LCD. This will allow you to change the contrast of the screen.
Step 3: Programming
Here is the program that I used to calibrate the photoresistor (which will vary depending on the light source you are using). You can open the serial monitor using the Arduino IDE software and view the values reported. You want the value in the person counter code (value in bold down below) to be set to a value below that of your light source on the photoresistor. So that as things cross your detector and block the light source, the photoresistor values will fluctuate across that value and reflect a count on the LCD.
void setup() {
// put your setup code here, to run once:
pinMode(7, OUTPUT);
Serial.begin(9600); }
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(7, HIGH);
Serial.println(analogRead(0)); }
Here is the program I used for the counter:
// include the library code:
#include
int myCounter = 0; // declare counter variable and set to zero
int flag = 0; // declare flag
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Person Counter!");
lcd.setCursor(0,1);
lcd.print(0); }
void loop() {
// set the cursor to column 0, line 1
lcd.setCursor(0, 1);
if(analogRead(A0) < 900) {
flag = 1; }
if(analogRead(A0) > 900 && flag == 1) {
myCounter++;
lcd.print(myCounter);
flag = 0; } }
I've also attached the files if there is a typo in this =)
Step 4: Test and Troubleshoot
After calibrating your photoresistor and uploading the code you are ready to test out your device.
Before you run the program make sure that the laser pointer is on the device. Otherwise the count will be off, which isn't a big deal. You can just reset the arduino or upload the code again.
Enjoy! I hope this works out for you all and feel free to make/ let me know of any mods you can think of to make this little device even more interesting.