Skip To Main Content

Middle School Coding Initiative 6-8

Coding Initiative

Middle School Coding Initiative
 
Phase I
The 2017 MST Middle School Coding Project allowed students to learn how to code an "Arduino" using Autodesk's free program Circuits.io.  For this project students assembled electronic components (Breadboard, Resistors, Jumper Wires and LEDs) in a virtual environment and added a preset code to build the Traffic Light Circuit.  When completed students were given a challenge of creating their own light sequence by changing the code, number of LEDs and LED color.
 
To see the code in action:
Click on "Start Simulation"
 
To see the code:
Click on "Code Editor"
 

 
Below is the sample diagram and Arduino Sketch Code.
 

ARDUINO/CIRCUIT BOARD LAYOUT

 

 

// Pin 13 has an LED connected on most Arduino boards.

// give it a name:

int ledRed = 13;

int ledYellow = 12;

int ledGreen = 11;


// the setup routine runs once when you press reset:

void setup()

{

 // initialize the digital pin as an output.

 pinMode(ledRed, OUTPUT);

 pinMode(ledYellow, OUTPUT);

 pinMode(ledGreen, OUTPUT);

}


// the loop routine runs over and over again forever:


//GREEN, YELLOW, RED YOU NEED TO CHANGE THE ORDER FOR THE TRAFFIC LIGHT

 

void loop()

{

 digitalWrite(ledGreen, HIGH);   // turn the LED on (HIGH is the voltage level)

 delay(5000);               // wait for a second

 digitalWrite(ledGreen, LOW);

 

 digitalWrite(ledYellow, HIGH);   // turn the LED on (HIGH is the voltage level)

 delay(3000);               // wait for a second

 digitalWrite(ledYellow, LOW);

 

 digitalWrite(ledRed, HIGH);   // turn the LED on (HIGH is the voltage level)

 delay(5000);               // wait for a second

 digitalWrite(ledRed, LOW);    // turn the LED off by making the voltage LOW  

 

   // turn the LED off by making the voltage LOW

   // turn the LED off by making the voltage LOW


// wait for a second

}