Robotic and Electronic Systems
Robotic and Electronic Systems
Robotic and Electronic Systems
Description: https://www.tinkercad.com/things/44yD7gIMfv8-leds-torch-/editel
Description of the Arduino LED Button Toggle Circuit
Components Used:
Arduino Uno
Breadboard
3 LEDs
Resistors (typically 220 ohms for the LED and 10k ohm for the pull-down resistor)
Jumper Wires
Circuit Connections:
Circuit Connections:
1. Arduino to Breadboard:
oConnect the 5V pin of the Arduino to the positive power rail (red rail) on the
breadboard.
o Connect the GND pin of the Arduino to the negative power rail (black rail) on
the breadboard.
2. LED Connections:
o Red LED:
Connect the anode (longer leg) of the red LED to the built-in LED pin
on the Arduino (usually digital pin 13) through a 220-ohm resistor.
Connect the cathode (shorter leg) of the red LED to the GND rail.
o Yellow LED:
Connect the anode (longer leg) of the yellow LED to digital pin 12 on
the Arduino through a 220-ohm resistor.
Connect the cathode (shorter leg) of the yellow LED to the GND rail.
o Green LED:
Connect the anode (longer leg) of the green LED to digital pin 11 on
the Arduino through a 220-ohm resistor.
Connect the cathode (shorter leg) of the green LED to the GND rail.
Code Explanation:
The code uploaded to the Arduino simulates a traffic light sequence, cycling through green,
yellow, and red lights.
code
// C++ code
//
int animationSpeed = 0;
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
}
void loop()
{
animationSpeed = 1000;
digitalWrite(LED_BUILTIN, HIGH);
delay(animationSpeed); // Wait for animationSpeed millisecond(s)
digitalWrite(LED_BUILTIN, LOW);
delay(animationSpeed); // Wait for animationSpeed millisecond(s)
digitalWrite(12, HIGH);
delay(animationSpeed); // Wait for animationSpeed millisecond(s)
digitalWrite(12, LOW);
delay(animationSpeed); // Wait for animationSpeed millisecond(s)
digitalWrite(11, HIGH);
delay(animationSpeed); // Wait for animationSpeed millisecond(s)
digitalWrite(11, LOW);
delay(animationSpeed); // Wait for animationSpeed millisecond(s)
}
Variable Definition:
Setup Function:
pinMode(LED_BUILTIN, OUTPUT);: Sets the built-in LED pin (usually pin 13) as an output.
pinMode(12, OUTPUT);: Sets digital pin 12 as an output.
pinMode(11, OUTPUT);: Sets digital pin 11 as an output.
Loop Function:
Detailed Explanation:
Overall Functionality:
This, therefore, is a simple light-up sequence of each LED—the inbuilt LED, the LED at pin 12, and the LED at pin
11—lighting up singly for one second each and then turning off. It shall repeat itself in a cycle. The end result will
thus be a continuous pattern of LEDs lighting up and then switching off in sequence. These delays set a period for
how long each light should be on to create a clear and distinct-looking sequence.
Evaluation
In the development of the cube torch light, there were a few problems I encountered, which
served as valuable learning curves and greatly improved how I approach project work. It
turned out that even though one could book in advance on the 3D printer, there were
frequent interruptions to its work. All this taught me planning and scheduling printing
sessions with greater efficiency. Another challenge was not having any previous experience
with coding, but I was able to pick up the basics from classmates and online tutorials, and
those really improved my coding. Another key thing learned is adapting to a microboard
from an oversized board that I chose initially, which taught me adaptability and planning.
This project has really shown me that peers and online resources, together with study
groups, are very instrumental in sharing knowledge and troubleshooting. I have also learnt
that revising and making changes to the different components of the project is key to
delivering the best results. I realized that consulting for help from friends or through online
tutorials was a major factor in surmounting some of the obstacles and proceeding with this
project. In the future, I will put these lessons into practice by designing a better system—
structured in a manner that will ensure smoother execution of tasks and delivery of better
results.