Electronics Project 1

For this one you will be creating the same thing as Project 0, but you will use 1 button to control the light. Before using your electronics kit build a prototype in Tinkercad. 

IMPORTANT: Work slowly and carefully so you do not break or lose anything in these kits! You will need everything in this kit for other projects.

NOTES: Except for the red, green, and blue lights the color of the wire doesn't matter much for this project. However, in the real world these colors do matter. Here is a chart of common wiring colors and their use.

Make sure before you start wiring the actual device you create your prototype in Tinkercad!

To start a project from scratch go to Tinker at the top of the page and select Circuits.

Step 1

Step 2


Step 3

Step 4

Get the Arduino board from your kit.

Step 5

Go slowly on this step! Doing 1 wire at a time.

Step 6

Step 7

View from the other side.

At this point your wiring should be complete. To test it out get the USB plug from your kit and plug it into your computer. The lights on the Arduino board should come on. Your LED may also light up and begin cycling through the colors.

If you're getting power to the device then proceed to the next stop. If there appears to be no power call the teacher over for help.

Step 8

ARDUINO SOFTWARE

TINKERCAD

Copy and paste the code from below into Code are of tinkercad.

const int buttonPin = 3;

const int redPin = 11;

const int greenPin = 10;

const int bluePin = 9;

int counter = 0;


void setup() {

  pinMode(buttonPin, INPUT);

  pinMode(redPin, OUTPUT);

  pinMode(greenPin, OUTPUT);

  pinMode(bluePin, OUTPUT);

}


void loop() {

  int buttonState;

  buttonState = digitalRead(buttonPin);

  

  if (buttonState == LOW) {

    counter++;

    delay(150);

  }

  

  else if (counter == 0) {

    digitalWrite(red, LOW);

    digitalWrite(greenPin, LOW);

    digitalWrite(bluePin, LOW);

  }

  

  else if (counter == 1) {

    digitalWrite(redPin, HIGH);

    digitalWrite(greenPin, LOW);

    digitalWrite(bluePin, LOW);

  }

  

  else if (counter == 2) {

    digitalWrite(redPin, LOW);

    digitalWrite(greenPin, HIGH);

    digitalWrite(bluePin, LOW);

  }

  

  else if (counter == 3) {

    digitalWrite(redPin, LOW);

    digitalWrite(greenPin, LOW);

    digitalWrite(bluePin, HIGH);

  }

  

  else {

    counter = 0;

  }

}