COMP 1045 Lab 3_F24
COMP 1045 Lab 3_F24
Circuit diagram: Connect a potentiometer and an RGB LED to the bread board
Level 1: Upload the source code and run it. Also open up the serial monitor on the bottom to
see what values you can read from the rotation sensor.
Source code:
int rotationPin = A0; //The rotation sensor is plugged into pin A0 of the Arduino.
int data=0; //Used to store data from sensor.
Level 3: Use the rotation sensor to cycle through the colours of the rainbow. (ROYGBP)
depending on the value of the rotation sensor. (exL 0-150 = red from 150-300= Orange). Look
up the RGB value for each colour and use analogWrite() to get the proper colours.
Level 4:
Step #1: Create a code that asks the user to input a pattern of colours using R, G or B. Then
display that sequence of colours. Ex: "Please input any combination of R, G or B letters". You
can assume that they will not use other letters. Reference 1 Reference 2
Step #2 Add other colours to the choices available to the user; C = cyan, M = Magenta, Y =
Yellow, W = White. As well as lower case letters. If the user inputs an invalid letter a message
should be displayed to the serial monitor.
Output→ Show's all 7 colours properly and outputs "Invalid colour" twice.