For this unit, we started off by learning about coding through a gizmo. Gizmo is a site with interactive simulations and the gizmo we used was the programmable rover gizmo. We practiced coding and learning about block coding and text coding. Both are used to create commands for an object or electronic. After we had learned and practiced the basics of coding with the gizmo, we made a virtual circuit and coded an LED to blink using TinkerCAD. TinkerCAD is a site that allows you to code virtual circuits before using real materials. After making and coding one LED to blink, we were tasked with creating a virtual stop light. We simply added two more lights and made sure the circuit worked properly. I coded the stoplight in a way that would allow each colored light to blink at separate times, like an actual stoplight would. Then, after making both virtual circuits, I made both using real materials found in the Fablab.
Practicing Coding With A Gizmo
Before making an actual circuit, we had to practice our coding skills with a gizmo. In this gizmo, there were multiple challenges that required us to create a code for a robot that needed to complete a task. For example, we needed to reach an X marked on the ground or pick up a "rock sample". Code allowed us to tell the robot to complete the necessary actions to complete the task. We started off by using block code, which was dragging blocks, that looked like puzzle pieces, with each individual action indicated by the drawing on the block. After completing a mission with block coding, we learned how to use text coding. Text coding is taking the blocks that we just assembled and changing each action into a small phrase. We use text coding to optimize code. For example, if you needed to go forward two times, you would place two forward blocks. Instead, while using text coding, you could simply change the forward code, translate(1); to translate(2); which optimizes the code.
TinkerCAD One Blinking Light
After I completed all of the missions on our gizmo, I moved on to creating a circuit. I was tasked with assembling a bread board powered by an Arduino that made one LED blink. I had to assemble the board and create a code that would make the LED blink. Before making a real circuit board out of real materials, I made a virtual circuit board using TinkerCAD. I used one LED, one breadboard, one Arduino, and one 470-Ohm resistor. For the circuit to work correctly, I could not just place each piece anywhere I wanted on the board. There had to be a certain order to have an electric flow so that all of the pieces would do what they were supposed to, and my circuit would work. I added a wire, connecting from the ground on the Arduino board to the negative power rail on the bread board. I added another wire, going onto one of the rows on the inside of the board. On this row, I added my shorter leg of the LED, called a cathode, and on the row next to it, I added my longer leg of the LED, called an anode. The cathode is negative and the anode is positive. On the row with the anode, I added one side of the resistor and in a different row I added the other. In the row with the other side of the resistor, I added a wire and connected it to pin 13 on the Arduino board. This created a properly working flow for electricity and my circuit would work. Under the code panel, I added two "set pin" blocks and two "wait" blocks. I changed the pin on both of the "set pin" blocks to 13, because this was the pin my circuit was connected to, and I changed the wait time to 3 seconds on both "wait" blocks just to make the blink longer. For the first "set pin" block, I selected HIGH and for the second I selected LOW which turns the LED on and off.
This is my virtual circuit board after all of the pieces had been added.
This is the code that I used to light up my virtual LED.
This is my virtual circuit board and one LED lighting up, once I selected start simulation.
Real One Blinking Light
For my real one blinking LED, I used real materials found in the Fablab. I assembled the real breadboard in the same way that I assembled it online using TinkerCAD. I also used the same code as I used on my virtual blinking light. On TinkerCAD, I changed my block code into text code and copied it. I went to the Arduino IDE application on my computer and pasted this code into the space on the screen. I made sure my text code and punctuation was correct, as it would not work if it was not correct, and I connected my Arduino and completed breadboard to the computer. I made sure to change my port to Comp5 under the tool category. This would send my code to the Arduino board. I pressed verify and then upload and I watched as my LED blinked.
This is my completed circuit board with one blinking LED.
This is my completed board, with the code, blinking.
TinkerCAD Model Stop Light
Like the one LED TinkerCAD model, I needed to practice making a circuit board virtually before assembling it with real materials. I kept the same design for the first LED, which I changed to the color green, and did the same design for the yellow and red LEDs. When adding the last wire, which connects each LED to the Arduino board, I could not put all of the different LEDs into the same pin on the Arduino board. I had to use a different pin for each LED. For the green, I used pin 13, for the yellow, I used pin 12, and for the red, I used pin 8. This was important when coding my stop light. I used two "set pin" blocks with one "wait" block in the middle for each LED, so I repeated this code three times. For the first "set pin" block, I set the pin to 13 and HIGH. For the second, I set the pin to 13 and LOW, for the third, I set the pin to 12 and HIGH, for the fourth, 12 and LOW, for the fifth, 8 and HIGH, and for the sixth, 8 and LOW. This made each light blink at different times, like a real, working stoplight would. For each "wait" block, I set the time to 3 seconds.
This is my final virtual model stoplight with all of the elements added.
This is the code that I used for my virtual model stoplight.
This is my virtual model stoplight, with all of the lights blinking at the correct times.
Real Model Stop Light
For my actual model stoplight, I assembled my breadboard in the same way I did on TinkerCAD. I used the same code that I used for my virtual model stoplight on TinkerCAD. On TinkerCAD, I changed my block code into text code and copied it. I went to the Arduino IDE application on my computer and pasted this code into the space on the screen. I made sure my text code and punctuation was correct, as it would not work if it was incorrect, and I connected my Arduino and completed breadboard to the computer. I made sure to change my port to Comp5 under the tool category. This would send my code to the Arduino board. I pressed verify and then upload and I watched as my model stoplight lit up at the correct times.
This is my completed model stoplight.
This is my model stoplight after the code had been sent and it was lighting up.
Problems Faced While Making My Virtual
Model Stop Light
One problem I encountered while doing this project was when I was making my virtual model stoplight on TinkerCAD. I did not know how to keep the flow of electricity going through all of my LEDs and all of their pieces. At first, I added a wire from the end of the green light's resistor to the cathode of the yellow light. I thought that this would continue the flow of electricity through all of the parts and LEDs. Only the green light ended up turning on. In order to keep the circuit going, I figured out that I had to connect all of the LEDs to the power rail charged by the wire connected to the Arduino board. Only the green light lit up because this was the only LED getting power from this board.