COMP 1045 Lab 5 - F24
COMP 1045 Lab 5 - F24
Circuit diagram: For this lab we will be using a button to control LED lights. Please setup
the following circuit and run the code provided in level 1.
Level 1: Run the following code to make sure your button works.
Level 3: Using the RGB LED, have button 1 turn on the RGB light, cycling through the three
colours in repetition(ex:Red→ Green→ Blue → Red→ ect.) with a 500 msec delay. Then use
the second button to shut off the lights. The light should shut off immediately after the current
colour and not continue to cycle to other colours after the button is pressed. There can be a 500
ms button press to shut off lights. Reference #1
Level 4: Add a green and red LED to the circuit with the RGB LED. Include 2 buttons. The first
button will toggle between the red and green LED. If the green LED is on when you hit button 2
the RGB will start cycling through the 3 colours. If the 2nd button is pressed the RGB lights stop.
If the 1st button is pressed the RGB stops AND the green LED turns off and the red LED turns
ON. If the red LED is on, nothing happens when you press the 2nd button. Here's the sequence
used to test your code
End testing
Note: For full marks you must use at least 1 interrupt function during either
level 3 or level 4 code.
Extra Challenge: In this challenge, you will enhance the circuit from Level 4 by allowing the
user to input a sequence of colors using the letters RGBCMYW. The RGB LED will then display
the colors in the sequence entered by the user. Begin with the circuit from Level 4. After
receiving the input, check if the entered string consists only of the valid letters (RGBCMYW). If
the input is invalid, prompt the user to enter a new string.
If the 2nd button from Level 4 is pressed, the RGB lights stop cycling.
If the 1st button from Level 4 is pressed, the RGB lights stop cycling, the green LED turns off,
and the red LED turns ON.
Allow the user to input a new sequence of colors after the sequence has been interrupted by the
buttons.