Control with a button
We need to add parts to the code to make this work. Before we had just the loop, now we add if and else. Every green part of your code needs an open and closing { } to run. The curly brackets are like sandwiches for your statements. Make sure each has them.
Write a code similar to below and upload it to your board to see if it works.
Write a code similar to below and upload it to your board to see if it works.
Learn How to Code! The Basics
We will start by just learning how to send code to the Arduino to make sure it works. You will also learn to name and save your files to a flash drive.
|
|
If you ever get an upload "Problem uploading to board" error, click Tools, then Port, and then select Arduino (shown below).
Once you see the onboard light blinking, you did it!
If you have time left over, play with the wait variable and upload it to see how it affects the light.
After you are done coding the onboard LED, save the file and open a new Arduino IDE code.
If you have time left over, play with the wait variable and upload it to see how it affects the light.
After you are done coding the onboard LED, save the file and open a new Arduino IDE code.
Lighting an LED
You just made your first Arduino program. Congratulations!!
Now we are going to figure out how to light LEDs from the Arduino board so that you can use lights on your robot later.
You will need: wires, a 220 ohm resistor, an LED.
Set up the board like below and see if you can figure out how to get one light on. (MAKE SURE YOU USE THE RESISTOR OR THE LIGHT MAY BREAK)
Once you get one light to work, figure out how to light more LEDs using your board.
Now we are going to figure out how to light LEDs from the Arduino board so that you can use lights on your robot later.
You will need: wires, a 220 ohm resistor, an LED.
Set up the board like below and see if you can figure out how to get one light on. (MAKE SURE YOU USE THE RESISTOR OR THE LIGHT MAY BREAK)
Once you get one light to work, figure out how to light more LEDs using your board.
Series and Parallel
Connect up your lights to the breadboard like below. See what changes between each type. Can you figure out how to power all three setups off the same board? Once you get your lights to work in parallel, try to use different colors. What happens when you try to use all different colored lights?