photoelectric counter sensor to increase/decrease speed code??


I’m new to using arduino and electronics for that matter. I am hoping to employ the arduino in my sculptures to create movement. Here’s what I’m hoping to get it to do, and maybe someone might point me in the right direction to find or write a code.

I want to use a photoelectric sensor to create incrementing values and decrementing values (through counting) to control the speed of a DC motor.

when the first sensor is tripped on entrance by a person into the room, the value would increase (+) which would speed up the motor (20 people is = max speed, after 20 it continues at max)

when second sensor is tripped by a person on exit of the room, the value will decrease (-) the speed of the motor ( everyone leaves the motors stop)

I will be using 2 standard 12V motors (max I’d like to run them is around 8 volts)
I’ll be running them off of L293D Secret motor driver and an arduino uno.
not quite sure what sensor I will be using quite yet.

any suggestions?


Depending how the doorways are arranged, finding a reliable way to count how many people have entered and left the room might prove tricky. Apart from that it all sounds feasible.