This week I continued progress on my final project of building a pinball machine by creating the breakbeam sensor that will denote when the game is over. My plan is to have IR LED and IR Collector position opposite of each other where the ball would fall. However, for this part of my pinball machine I decided to use an Arduino Uno. While I know a large portion of this class is learning how to mill boards and build microcontrollers, I have so many moving parts to my pinball machine that it will be easiest for me to build an entire pinball machine if I had one Arduino microcontroller where all inputs and outputs could feed back to. As such I created this board below to be my breakbeam sensor. The schematic of the circuit is feature above where IR LED is given 5V through a digital pin and the output of the emitter is measured with an analog pin.
The last step was to code the sensor as seen through the code below. I programmed it to read in the analog signal from the collector and found that when there is no IR light reaching the collector the analog signal will read >1000. The most direct connection between the collector and the emitter will read around 20-30 for its analog signal. When this sensor is placed within the playfield of my pinball machine, I will set the code to set of a series of lights denoting game over any time the analog signal is greater than 1000.
The code for the breakbeam sensor can be found here.