This is a super easy project where you can learn how to fade an LED with an Arduino board and a push button.
Follow along to create your own fading heart!
To build the circuit, I used:
Why add a resistor when using a push button?
It turns out there is electromagnetic interference (EMI) generated by external forces all around us.
EMI makes it hard to get a consistent value reading from the pins. This is known as floating pins.
If we were to connect a push button to a pin on the Arduino board without a resistor, we would get
random readings when the push button is left unpressed.
There are two ways of connecting the resistor:
Fading in action
Making it a little more interesting...
I cut an acrylic sheet in the shape of a heart using a laser cutter. I taped a red LED to one side.
I connected the positive leg of the LED to pin 6 and the negative leg to the 320 Ω resistor.
The value of the resistor was determined by using Ohm’s law.
Now when I press the button the heart fades on and then off untill the button is pressed again.