
Beginners Guide to Robotics
Robo Explorers 1
Arduino
What is Arduino
Imagine you have a tiny robot friend that listens to your instructions. That’s kind of like what an Arduino is!
Arduino is a small computer. It has a little brain (called a microcontroller) that can think and do tasks for you.
You write simple instructions (like a list of steps) and upload them to the Arduino. When you power it on, it follows your instructions exactly!
How It Works
Inputs and Outputs:
Think of inputs like buttons, sensors, or even a little microphone. They tell the Arduino, "Hey, something happened!"
Outputs are things like lights, buzzers, or motors. The Arduino tells them what to do like turning on a light or making a sound.Making Things Happen:
For example, you could tell your Arduino to:Turn on a light when you press a button.
Make a buzzer beep when it hears a clap.
Spin a motor when it gets a signal from a sensor.
Why Is It Cool?
Build Fun Projects:
You can use Arduino to build cool projects like a dancing robot, a simple game, or even a weather station to measure temperature!Learn by Doing:
With Arduino, you learn how electronics work, how to program, and how to bring your ideas to life, just like building with LEGO blocks but with lights, sounds, and movements.Easy to Use:
Even though it’s like a mini computer, Arduino uses simple commands. It’s designed so that kids and beginners can create amazing things without needing to be an expert.
In Short, Arduino is your little helper that listens to your ideas and makes them happen with lights, sounds, and motion. It’s like having a magic box that turns your cool thoughts into real-world projects!
How to connect Arduino and turn on Yellow Tyro Board
Components of Arduino
1. The LEDs
What They Are:
Little lights that turn on when the board is powered up.What They Do:
They tell you, "Hey, I’m awake!" Sometimes one LED might blink when the board is sending or receiving messages.
2. The Button (Reset Button)
What It Is:
A tiny button you can press on the board.What It Does:
It restarts the Arduino Nano—like rebooting a computer when you need a fresh start.
3. The Chip
What It Is:
The microcontroller chip (usually an ATmega328) is the brain of the Nano.What It Does:
It listens to the instructions (code) you write and tells the board what to do—like turning on an LED or making sounds.
4. The USB Socket
What It Is:
A small port where you plug in a USB cable.What It Does:
It connects your Arduino Nano to your computer. This lets you send your code to the Nano and sometimes even powers it.
Here's How the Pins Work
Digital Pins (labeled with D):
These are like simple on/off switches. When you tell a digital pin to turn on, it gives power to something (like lighting up an LED). When it’s off, nothing happens.Analog Pins (labeled with A):
These pins can read different amounts of power. Imagine a volume knob that can be turned up or down; analog pins can sense changes in things like light or temperature.Power Pins:
These pins give your Arduino power (like 5V or 3.3V) or help you connect the board to the ground (GND). They are like the battery and the plug of the board.
Code Breakdown
Welcome to the magical world of the Yellow Tyro board! Think of this board as a clever robot that comes to life with its secret recipe called code. Every single line in this recipe is like a tiny instruction or a special step on a treasure map. The very first line might be the command that wakes the board up, while the next few lines tell it how to blink its lights, make funny sounds, or even decide what to do when you press a button. As you explore the code line by line, you’ll discover how these little instructions work together—just like pieces of a puzzle—to create something truly amazing. Get ready for an adventure where learning about code is as fun as uncovering hidden treasures!
Let's learn the line by line interpretition of our code!
We create a list of 5 numbers (3, 4, 5, 6, 7) for the pins that control 5 little lights (LEDs). These lights will always be turned on.
We say that pin number 8 is for the buzzer, which makes a beeping sound.
Pin 9 and pin 10 are for the motor. Pin 9 makes the motor turn forward, and pin 10 makes it turn backward.
The motor switch (button) is connected to analog pin A0 and the buzzer switch (button) is on A1.
We create a little memory box called motorState
that remembers if the motor should go forward (0) or reverse (1). It starts at 0, so the first time, the motor will go forward.
The setup()
part is like the “get ready” stage. It runs one time when the robot (Arduino) is turned on.
Here, we tell the Arduino that the pins for the LEDs (3, 4, 5, 6, 7) are “outputs” – this means the Arduino can send signals (like turning the lights on). We do this for each of the 5 LED pins using a loop (like doing the same thing 5 times).
Now we tell the Arduino that the pins for the buzzer (8) and the motor (9 and 10) are also outputs, so the Arduino can control them.
Here we tell the Arduino that the button pins (A1 for the buzzer and A0 for the motor) are “inputs”. With INPUT_PULLUP
, it means these pins are normally HIGH (like a light on) until you press the button, which then makes them LOW (like turning off a light).
Before starting, we make sure that the buzzer and motor are off by sending a LOW signal to them.
The loop()
part is where the Arduino keeps doing things again and again – it never stops until you turn it off.
Every time the loop runs, we go through the 5 LED pins and turn them on. This keeps the 5 lights on all the time.
We check if the buzzer button (on A1) is pressed. Because of the pull-up setting, if the button is pressed, it reads LOW.
If the button is pressed, we turn the buzzer on so it can make a sound.
We wait a tiny bit (100 milliseconds, which is a very short time) so the buzzer can beep. Then we turn the buzzer off so it stops beeping. We wait a little longer (200 milliseconds) to make sure the button press is clear and not too noisy. This is called “debouncing.”
Now we check if the motor button (on A0) is pressed. Again, if it is pressed, it will read LOW. We check if our little memory box motorState
is 0 (which means the motor should go forward).
If motorState
is 0:
We turn on the motor’s forward pin (pin 9) and make sure the reverse pin (pin 10) is off.
We let the motor run forward for 2 seconds.
Then we change
motorState
to 1 so next time the motor will run in reverse.
If the motor button is pressed but motorState
is not 0 (it must be 1), we do the reverse:
If motorState
is 1:
We turn off the forward pin and turn on the reverse pin.
We let the motor run in reverse for 2 seconds.
Then we change
motorState
back to 0 for the next press.
After the motor has run for 2 seconds, we turn it off completely by setting both pins to LOW.
We wait 300 milliseconds to make sure the button press is clean (debouncing) before checking again.
Some resources
For Windows
Open Your Internet Browser:
Open Chrome, Firefox, or another browser.Go to the Arduino Website:
Type https://www.arduino.cc/en/software in the address bar and press Enter.Download for Windows:
Click the "Windows Installer" button.
(You can also use the ZIP file if you like, but the installer is easiest.)Install Arduino:
When the file finishes downloading, double-click it.
Follow the simple instructions on the screen.Start Creating:
After installing, open Arduino and have fun making projects!
For Mac
Open Your Internet Browser:
Use Safari, Chrome, or another browser.Go to the Arduino Website:
Type https://www.arduino.cc/en/software in the address bar and press Enter.Download for macOS:
Click the "macOS" download button.Install Arduino:
When the download is done, open the ZIP file.
Drag the Arduino icon into your Applications folder.Start Creating:
Open the Arduino app from Applications and enjoy your new projects!
Fun Activity!
In this fun activity, you'll learn how to program your Arduino Nano to make its on-board LED blink every second—like a little heartbeat that you control with your code. It's a great way to see how simple instructions can make things come alive with light! So, grab your board and let's start coding.
Code Explanation
setup()
Function:
This part runs one time when the Arduino Nano starts.pinMode(LED_BUILTIN, OUTPUT);
tells the Arduino, "Hey, this LED is something we want to control!" The LED is usually connected to pin D13.
loop()
Function:
This part runs over and over, like a never-ending cycle.digitalWrite(LED_BUILTIN, HIGH);
turns the LED on. Think of HIGH as "power on."delay(1000);
makes the Arduino wait for 1000 milliseconds, or 1 second.digitalWrite(LED_BUILTIN, LOW);
turns the LED off. LOW means "no power."The next
delay(1000);
waits another 1 second before the loop starts again.Because the
loop()
function repeats endlessly, the LED will keep blinking on and off every second.
Thank you for visiting our corner of creativity and innovation. As you explore the endless possibilities with Arduino, let every project spark your imagination and guide you toward a brighter, inventive future—one brilliant idea at a time. Now, you can proceed to the next chapter, where we dive into the exciting world of LEDs.