Arduino fast intro

From Interaction Station Wiki
Jump to: navigation, search

Arduino Uno

Aqrduino ide.PNG


Hello everyone hello hello hello,

now what is an Arduino ...well...find a detailed introduction here [[1]]
Computer and processor are generic terms for the anything that can run a program, basically.
Controller or microcontroller usually refers to a simple processor that does only one task, like listening to sensors. In explaining microcontrollers, we’ll distinguish them from computers, which contain more powerful processors that can run an operating system.
Arduino is an open source physical computing platform based on a simple input/output (I/O) board and a development environment that implements the Processing language. Arduino can be used to develop standalone interactive objects or can be connected to software on your computer.
The Arduino contains a microcontroller.
Most electronic devices today have a microcontroller at their core. Microcontrollers are optimized for control of general input and output. What Is Physical Computing? Physical Computing uses electronics to prototype new materials for ( in our case ) designers and artists.
Arduino is composed of two major parts: the Arduino board, which is the piece of hardware you work on when you build your objects; and the Arduino IDE, the piece of software you run on your computer. You use the IDE to create a sketch (a little computer program) that you upload to the Arduino board. The sketch tells the board what to do.

In the meantime, HERE you can find ANYTHING about Arduino, including download the software

The pins on your Arduino are the places where you connect wires to construct a circuit (probably in conjunction with a breadboard and some wire. They usually have black plastic ‘headers’ that allow you to just plug a wire right into the board. The Arduino has several different kinds of pins, each of which is labeled on the board and used for different functions.
Board layout.PNG

First things first, Blink it

we start by figuring put if our Arduino is all good or it is somehow damaged is a basic test to check and run a simple script at the same time.

Go to File ---> Examples ---> Basics --->Blink

so we have something like this

  Turns on an LED on for one second, then off for one second, repeatedly.
  Most Arduinos have an on-board LED you can control. On the Uno and
  Leonardo, it is attached to digital pin 13. If you're unsure what
  pin the on-board LED is connected to on your Arduino model, check
  the documentation at
  This example code is in the public domain.
  modified 8 May 2014
  by Scott Fitzgerald
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second

GOOOD! lets dissect this

  • commenting / one line and multiple lines
  • setup
  • loop

Choose board


Choose port


Lets compile this

--- Press/ Click upper most left button, looks like a Tick. Observe the messages appearing in the bottom of the Arduino software window ( there must be a sentence Done Compiling

Lets upload this


And we should have a Blinking aka Flashing on board LED


Let's add a trough hole led

LED pinout.jpg

Schematic wiriting.PNG

OK, wait...the BREADBOARD

OK, first, what's with the name....bread board? Bread, like in food? Well yes, kind of.

This terminology goes way back in the days. Generally, you would mount electronic components to a piece of wood (the actual "breadboard"), and do all the wiring with point-point wire and the components just hanging between the various devices.

00 px

The story goes that an engineer had an idea for a vacuum tube device late one night. Looking around the house, the only base for his prototype that he found was indeed his wife's breadboard, from the breadbox.

A video by the Make magazine people

Ok, but why do we need to breadboard?
Well, they are useful for making temporary circuits and prototyping, and they require absolutely no soldering.
Prototyping is the process of testing out an idea by creating a preliminary model from which other forms are developed or copied, and it is one of the most common uses for breadboards.
The best way to explain how a breadboard works is to take it apart and see what’s inside. Breadboard02.jpg

connections lines are connected like this

so Hello world on the breadboard


Exercise: Now make something that blinks .....a morse code message

473px-International Morse Code.svg.png

Using the blink example knowledge, lets make a simple morse code message here What is morse code

translate a message to morse here

Controlling Outputs

Servo motor

Now we will hookup a servo motor and instruct it to behave a certain way.

This is a servo, a very small one


The servo has 3 wires, we need to connect them all to the arduino.

red is for 5V

you will find it easy to plug one end of a jumper wire inside the connectors of the servo motor, and the other end to the corresponding pin of the Arduino make sure you use corresponding colors for the jumpers, in bigget setups messy wire can cause you more time to debug

brown is for GND

to GND of the Arduino

and orange is for signal

signal is going into the pin of the Arduino we will use to control the servo motor We will look for a pin that has a wave next to the number ( look at the Arduino board). Those pins are able to output Pulse Width Modulation (PWM) is a fancy term for describing a type of digital signal. Pulse width modulation is used in a variety of applications including sophisticated control circuitry. Also in our case control the servo motor. The control wire is used to send this pulse. For more info how servos work look here [[2]]

Oneservo hello.png
We will use another example to see if our servos work


Now with knowing where the examples are located, find a servo example sketch called sweep.

you should have a code that looks like this

/* Sweep
 This example code is in the public domain.
 modified 8 Nov 2013
 by Scott Fitzgerald
#include <Servo.h>
Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards
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
    // in steps of 1 degree
    myservo.write(pos);              // tell 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

Let's upload the sketch to the board
Observe the motor---->sweeping?

Getting data from an input

The knob


  Reads an analog input on pin 0, prints the result to the Serial Monitor.
  Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
  This example code is in the public domain.
// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  delay(1);        // delay in between reads for stability

Led pot.PNG

int potPin = A0;
int potValue = 0;
int ledPin = 9;
void setup() {
  // put your setup code here, to run once:
void loop() {
  // put your main code here, to run repeatedly:
 potValue = analogRead(potPin);
 analogWrite(ledPin, potValue);

Now MAP the values

int potPin = A0;
int potValue = 0;
int ledPin = 9;
void setup() {
  // put your setup code here, to run once:
void loop() {
  // put your main code here, to run repeatedly:
  potValue = analogRead(potPin);
  int mappedValue = map(potValue, 0, 1023, 0, 255);
  analogWrite(ledPin, mappedValue);