How to Use an Arduino

by OnTheBrink in Circuits > Arduino

12724 Views, 107 Favorites, 0 Comments

How to Use an Arduino

IMG_0011.JPG

Hello! Today, I will talk to you about what an Arduino is and how to program it. You will need a few things that are listed on the next step.

Parts

For the first project, you will need:

  • Arduino Uno
  • Arduino IDE
  • USB Cable
  • LED

For the second project, you will need:

  • Arduino Uno
  • Arduino IDE
  • USB Cable

What Is an Arduino?

An Arduino is a kind of computer called a microcontroller. Microcontrollers are used for all kinds of things such as controlling motors, LEDs, and Speakers. The Arduino Uno use an ATmega328p chip as its central processor and has 32kb of flash memory. If you would like to know more specs, go to arduino.cc.

Project 1: Blink

IMG_0013.JPG
  1. Open the Arduino IDE and create a new sketch.
  2. Click on the Open tab and find examples. Find the blink sketch and open it. Upload it to your board.
  3. If you'd like, you can add an external LED to the board, by connecting the positive lead of the LED to digital pin 13 and connecting the negative lead to one of the ground ports. Make sure you use an appropriate resistor when making this circuit, in order to avoid frying the LED.

Once you have uploaded the program, the orange LED will start blinking. If you inserted the extra LED, it will start blinking too.

Read the code notes until you understand what each command does. Once you have done that, try making small modifications to the code until you can use these commands and have them committed to memory.

Downloads

Project #2-Servo Control

IMG_0015.JPG

For the second project, you will learn how to control a servo. The code for this project is fairly simple, but it is still more complicated than the "Blink" sketch. I pasted it below with the code notes.

#include Servo myservo; // create servo object to control a servo

int pos = 0; // variable to store the servo position

void setup() { myservo.attach(9); // attaches the servo on pin 9 to the servo object

}

void loop() {

for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees

myservo.write(pos); // tells servo to go to position in variable 'pos'

delay(15); // waits 15ms for the servo to reach the position }

for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees

myservo.write(pos);

// tell servo to go to position in variable 'pos'

delay(15); // waits 15ms for the servo to reach the position } }

This code can be directly pasted into the IDE and used. As before, pay attention to the code notes and make sure you understand how to use each command. Make small adjustments to the code, like changing the servo pin or changing the initial position of the servo a small amount. There are many possibilities.

Downloads

Finish

Meaning-of-vault-boy-thumbs-up-jpg.jpg

You are done with this tutorial! You know have a very basic understanding of Arduino code. Please continue to learn more about it and keep on making!