This is a quick hack for those who want to protect Arduino's pins from beeing connected with voltages > 5Volt by using an optocuppler

This quick hack is for the guys who want to protect the arduino pins from voltages higher than 5 Volts. An optocuppler is a great option to do that and it's simple to use. In this sample I have connected the digital pin 3 of the Arduino with the input side of an optocuppler. Remember: pin 3 is a PWM pin, therefore a great starting point for motor controls. The output pin of the optocuppler is connected with a simple 20 milliampere LED and a resistor of 1 KOhm to limit the current of the LED. The LED is connected to the 12V power supply. I have also used a resistor of 1 KOhm to limit the current on the arduino pin and on the optocuppler internal LED. The optocuppler is a standard PC817. If you want to use other Voltages and/or other optocupplers please check and adjust the resistors. The good news on optocupplers: A mistake on your circuit will not kill your arduino. Please note: Be carefull with voltages > 12V!