You are on page 1of 2

Exercise 1:

Toggle LED with Button Connect an LED to pin 2 and a button to pin 3 of the Arduino board.
Write a program that toggles the LED on and off each time the button is pressed.

Exercise 2:

LED Sequence with Button Connect three LEDs to pins 2, 3, and 4, and a button to pin 5 of
the Arduino board. Write a program that cycles through the LEDs in a sequence, advancing
to the next LED each time the button is pressed. Once the last LED is reached, pressing the
button should reset the sequence back to the first LED.

Exercise 3:

LED Dimming with Button Connect an LED to pin 9 and a button to pin 2 of the Arduino
board. Write a program that gradually increases and decreases the brightness of the LED
each time the button is pressed. Use the analogWrite() function to control the LED
brightness.

Exercise 4:

LED Pattern Selection with Buttons Connect four LEDs to pins 2, 3, 4, and 5, and two buttons
to pins 6 and 7 of the Arduino board. Write a program that allows the user to select a
pattern by pressing the buttons. Each button press should cycle through the available
patterns, and the selected pattern should be displayed using the LEDs.

Exercise 5:

LED Morse Code Connect an LED to pin 2 and a button to pin 3 of the Arduino board. Write
a program that blinks the LED in Morse code. Each time the button is pressed, a different
letter of the alphabet is encoded in Morse code and displayed using the LED.

Exercise 6:

Button Hold Detection Connect a button to pin 2 of the Arduino board. Write a program that
detects how long the button is held down. When the button is pressed and held, a timer
should start counting, and the elapsed time should be displayed on an LCD screen. When the
button is released, the timer should stop.

Exercise 7:

Button Debouncing Connect a button to pin 2 of the Arduino board. Write a program that
debounces the button signal to prevent false triggers. When the button is pressed, an LED
connected to pin 13 should toggle on and off without any unintended flickering or bouncing.

Exercise 8:

Button Interrupt Connect a button to pin 2 of the Arduino board. Write a program that uses
an interrupt to detect button presses. Each time the button is pressed, an LED connected to
pin 13 should toggle on and off.

You might also like