Lab Assignment 4 Simple Simon
Lab Assignment 4 Simple Simon
RBT173
The purpose of the laboratory digital input and output using a microcontroller. Also,
construct a program that generates a random sequence of lights, outputs the sequence,
then reads input from the switches. It generates a random sequence of blinking lights,
which the player must imitate. The sequence of switch-presses does not match the
random sequence, then each LED should light, then each LED should turn off, in order.
Implementation – the implementation section of your lab report should include the
following:
Submit a video
//set the pins where the butons, LEDs and buzzer connect
int button[] = {2,4,6,8}; //red is button[0], yellow is
button[1], green is button[2], blue is button[3]
int led[] = {3,5,7,9}; //red is led[0], yellow is led[1],
green is led[2], blue is led[3]
int tones[] = {262, 330, 392, 494}; //tones to play with each
button (c, e, g, b)
void loop(){
//then start going through the sequence one at a time and see if the
user presses the correct button
for(int i=0; i <= roundCounter; i++){ //for each button to be
pressed in the sequence
//----------FUNCTIONS------------
//FLASH LED
void flashLED (int ledNumber){
digitalWrite(led[ledNumber], HIGH);
tone(buzzerPin, tones[ledNumber]);
}
//START SEQUENCE
void startSequence(){
//WIN SEQUENCE
void winSequence(){
//LOSE SEQUENCE
void loseSequence(){
The structure of my program is how it will light the LEDs in order for the player to see the
lighting up and push the buttons. To make it like the Simion where you can hear the music, and I
decided to add it to the program, it would make the sound. Also, when you lose the sequence and
turn all the LEDs on. If you play the right, the sequencing keeps going then; plays music when
you win.
I would say the LED light turns it all on, and then it starts to turn off waiting, a moment to start
playing. Then it’s turning on one led lighting then; you have to click the button where it’s
lighting up. It plays by adding more sequences and turning on the LEDs.
5. Any calculations that you completed during the laboratory (for example, LED
resistor calculations) with explanation of their purpose
There were calculations for the resistor that I went for 330 resistors.