There is nothing really new in the code that we will use for this example. We will, just like in the previous one, simply read the digital input corresponding to the phototransistor and only if it is a
HIGH value, which means it is not receiving any light and thus not conducting, will we make the output LED blink.
Once again, just for the sake of simplicity, and given that now we know that we don't really need to store the value read with
digitalRead() and we can simply call the functions inside the
if condition, I have opted this time to save up this variable and simplify even a little more of the code:
/* Chapter 05 - Sensing the real world through digital inputs Optical coin detector By Francis Perea for Packt Publishing ...