Difference between revisions of "About Arduino"

From Interaction Station Wiki
Jump to navigation Jump to search
 
(37 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Hello everyone hello hello hello,
+
=What is an Arduino =
 +
[[File:Uno_board.png|350px|thumb|The Arduino board]]
 +
[[File:ide.png|350px|thumb|The Arduino IDE]]
 +
From the Wikipedia article on Arduino we read<ref>https://en.wikipedia.org/wiki/Arduino</ref>:
 +
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">
 +
Arduino is an open-source computer hardware and software company, project and user community that designs and manufactures kits for building digital devices and interactive objects that can sense and control the physical world. Arduino boards may be purchased preassembled, or as do-it-yourself kits; at the same time, the hardware design information is available for those who would like to assemble an Arduino from scratch.
 +
</pre>
 +
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. These types of work are usually called [[Physical Computing|Physical Computing]].<br>
 +
Physical Computing creates interactive systems by using electronics. The purpose is to  prototype new materials for designers and artists.
 +
<br>
 +
===What makes an Arduino?===
 +
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, [https://www.arduino.cc/ HERE] you can find anything about Arduino, including download the software.
 +
<br>
 +
In essence Arduino is ''just another'' &mu;Controller development board. The main purpose of such a &mu;Controller development board is to make it easy for developers to evaluate the functions of, or create a quick prototype with, a certain type of &mu;Controller. &mu;Controllers come in al sorts of tastes and sizes hence there are many different flavours of &mu;Controller development boards as well. Do, for example, a Google search on [https://www.google.nl/search?hl=en&site=imghp&tbm=isch&source=hp&biw=1366&bih=679&q=microcontroller+development+board microcontroller development board]. You will see an abundance of different different platforms and most likely you will find some Arduino flavours there as well.
 +
 
 +
===A bit of Arduino history===
 +
The project is based on a family of microcontroller board designs manufactured primarily by SmartProjects in Italy, and also by several other vendors, using various 8-bit Atmel AVR microcontrollers or 32-bit Atmel ARM processors. These systems provide sets of digital and analog I/O pins that can be interfaced to various extension boards and other circuits. The boards feature serial communications interfaces, including USB on some models, for loading programs from personal computers. For programming the microcontrollers, the Arduino platform provides an integrated development environment (IDE) based on the Processing project, which includes support for C and C++ programming languages.
  
now what is an Arduino ...well...find a detailed introduction here [[http://interactionstation.wdka.hro.nl/wiki/Arduino_Introduction]] <br>
+
The first Arduino was introduced in 2005. The project leaders sought to provide an inexpensive and easy way for hobbyists, students, and professionals to create devices that interact with their environment using sensors and actuators. Common examples for beginner hobbyists include simple robots, thermostats and motion detectors.
<br>
+
</pre>
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.<br>
 
What Is Physical Computing?
 
Physical Computing uses electronics to prototype new materials for designers and artists.  
 
<br>
 
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, [https://www.arduino.cc/ HERE] you can find ANYTHING about Arduino, including download the software
+
==What do you use Arduino for?==
  
NOW,
+
Arduino is involved in lots of works. Here are some examples:
  
[[File:Arduino-uno.png]]
+
*[https://m-h-z.net/rippler/ Sound sculptures]
 +
*[http://www.susannahertrich.com/work/jacobsons-fabulous-olfactometer/ Sensing pollution]
 +
*[http://vtol.cc/filter/works/you-me-and-all-these-machines Performance / Microphone manipulation]
 +
*[https://vimeo.com/241028491 Light swarm]
 +
*[http://www.mkontopoulos.com/portfolio/machines-that-almost-fall-over/ Machines that almost fall over]
 +
*[http://vtol.cc/filter/works/antenna Mom, I hit a man]
 +
*[http://katihyyppa.com/forbidden-fruit-machine/ Forbidden fruit machine]
 +
*[http://katihyyppa.com/as-light-goes-by/ As light goes by]
 +
*[https://vimeo.com/236594080 Instant messanging?]
 +
*[https://vimeo.com/116904791 String fountain]
 +
*[https://vimeo.com/45747333 What the phonics]
 +
*[https://www.niklasroy.com/project/88/my-little-piece-of-privacy A piece of privacy]
 +
*[https://vimeo.com/224595171 Can be very simple]
 +
*[https://vimeo.com/232937979 Even more simple]
 +
*[https://vimeo.com/74354990 Bottle song test]
 +
*[https://vimeo.com/78889495 Bottle song]
 +
*[https://vimeo.com/201825170 Simple and with a sense of humor 1]
 +
*[https://vimeo.com/140870602 Simple and with a sense of humor 2]
 +
*[https://vimeo.com/138062157 Same but different]
  
=FIRST=
 
  
we start by figuring put if our Arduino is all good or it is somehow damaged ...it is a basic test to check and run a simple script at the same time.
+
<gallery>
 +
File:Smelling-color-lg.jpg|alt=alt language
 +
File:Thumb01.PNG|alt=alt language
 +
File:TactileControls.jpg|alt=alt language
 +
File:Separate-Togetherness.jpg|alt=alt language
 +
</gallery>
  
== Go to File ---> Examples ---> Basics --->Blink ==
+
=The Arduino board=
so we have something like this
+
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 different kinds of pins, each of which is labeled on the board and used for different functions.
 +
<br>
 +
[[File:Board_layout.PNG | 500 px]]<br>
 +
In details: <br>
 +
[[File:Arduino-uno.png| 500px]]
 +
===Inputs and Outputs===
 +
μControllers like Arduino are optimized for control of general input and output. 
 +
What are those two exactly?
 +
<br>
 +
'''Analog Input Pins''' ( we have six of them in the Uno): The area of pins under the ‘Analog In’ label (A0 through A5 on the UNO) are Analog In pins. These pins can read the signal from an analog sensor (like a temperature sensor) and convert it into a digital value that we can read.<br>
 +
'''Digital Input Pins''' (seven on the Uno): Across from the analog pins are the digital pins (0 through 13 on the UNO). These pins can be used for both digital ''input'' (like telling if a button is pushed) and digital ''output'' (like powering an LED).
 +
<br>
  
 +
=Getting started on the Arduino board and software =
 +
Now that we have our board we should start by figuring put if our Arduino is all good or it is somehow damaged. To do this we are running a simple script on the board.
 +
You can download the Arduino software [https://www.arduino.cc/en/software here]. <br>
 +
To upload the sketch you can got to: <br>
 +
<pre>File ---> Examples ---> Basics --->Blink</pre> <br>
 +
You will see something like this:
 
<syntaxhighlight lang=c style="border:3px dashed blue">
 
<syntaxhighlight lang=c style="border:3px dashed blue">
 
/*
 
/*
Line 55: Line 104:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
[[File:Arduino-LED-Overview.jpg | 500 px]]
  
GOOOD! lets dissect this
+
To make sure your board is connected you should check a couple of things
 +
* Make sure your board and port is selected
 +
[[File:Port.png  | 600 px]]
 +
* Compile the sketch
 +
::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 ''' <br>
 +
[[File:Compile.png  | 300 px ]]
 +
* Upload the sketch on the board <br>
 +
[[File:Upload.png| 300px]]
  
* commenting / one line and multiple lines
+
=Example: Getting data from an input=
*setup
+
====The knob====
*loop
 
===Choose board===
 
  
[[File:Board.png | 900 px]]
+
[[File:Analogreadserial.png| 400px]]
  
===Choose port ===
+
<syntaxhighlight lang=c style="border:3px dashed pink">
  
[[File:Port.png | 900 px]]
+
   
 +
/*
 +
  AnalogReadSerial
  
 +
  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.
  
===''Lets compile this'' ===
+
  http://www.arduino.cc/en/Tutorial/AnalogReadSerial
--- 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 ''' <br>
 
[[File:Compile.png ]]
 
 
 
 
 
===''Lets upload this'' ===
 
 
 
[[File:Upload.png ]] <br>
 
 
 
And we should have a Blinking aka Flashing on board LED
 
 
 
 
 
[[File:Arduino-LED-Overview.jpg | 900 px]]
 
 
 
''Italic text''OK, so your Ardiono blinks, that was ''Hello World!''
 
 
 
=Servo motor=
 
Now we will hookup a '''servo motor''' and instruct it to behave a certain way.
 
 
 
[[File:Micro-servo.jpg]]
 
<br>
 
This is a servo, a very small one
 
==Hookup==
 
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
 
===''black'' 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 [[https://www.servocity.com/how-does-a-servo-work]]
 
 
 
 
 
 
 
[[File:Oneservo hello.png | 900 px]]
 
<br>
 
We will use another example to see if our servos work
 
 
 
==Sweep==
 
 
 
Now with knowing where the examples are located, find a servo example sketch called sweep. <br>
 
 
 
<br>
 
you should have a code that looks like this
 
<syntaxhighlight lang=c style="border:3px dashed blue">
 
/* Sweep
 
by BARRAGAN <http://barraganstudio.com>
 
This example code is in the public domain.
 
 
 
modified 8 Nov 2013
 
by Scott Fitzgerald
 
http://www.arduino.cc/en/Tutorial/Sweep
 
 
*/
 
*/
  
#include <Servo.h>
+
// the setup routine runs once when you press reset:
 
 
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() {
 
void setup() {
   myservo.attach(9); // attaches the servo on pin 9 to the servo object
+
   // initialize serial communication at 9600 bits per second:
 +
  Serial.begin(9600);
 
}
 
}
  
 +
// the loop routine runs over and over again forever:
 
void loop() {
 
void loop() {
   for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
+
   // read the input on analog pin 0:
    // in steps of 1 degree
+
  int sensorValue = analogRead(A0);
    myservo.write(pos);             // tell servo to go to position in variable 'pos'
+
  // print out the value you read:
    delay(15);                      // waits 15ms for the servo to reach the position
+
   Serial.println(sensorValue);
  }
+
  delay(1);       // delay in between reads for stability
   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
 
  }
 
 
}
 
}
 
  
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Let's upload the sketch to the board <br>
+
[[File:Led pot.PNG| 400px]]
Observe the motor---->sweeping?
 
  
===Breadboarding===
+
<syntaxhighlight lang=c style="border:3px dashed pink">
OK, first, what's with the name....bread board? Bread, like in food?
 
Well yes, kind of.
 
<br>
 
[[File:Breadboard.jpg ]]
 
  
This terminology goes way back in the days.
+
int potPin = A0;
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.
+
int potValue = 0;
<br><br>
+
int ledPin = 9;
[[File:Breadboardreal.jpg]]
 
<br><br>
 
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.
 
<br><br>
 
[http://www.youtube.com/watch?feature=player_embedded&v=HrG98HJ3Z6w A video by the Make magazine people ]
 
<br>
 
<br>
 
  
Ok, but why do we need to breadboard?
 
<br>
 
Well, they are useful for making temporary circuits and prototyping, and they require absolutely no soldering.
 
<br>
 
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.
 
<br>
 
The best way to explain how a breadboard works is to take it apart and see what’s inside.
 
[[File:Breadboard02.jpg]]
 
<br><br>
 
connections lines are connected like this
 
<br>
 
[[File:Breadboard03.jpg]]
 
  
<br>
+
void setup() {
 +
  // put your setup code here, to run once:
  
==Knob==
+
Serial.begin(9600);
 +
}
  
Great,
+
void loop() {
let us include another agent into the servo situation.
+
  // put your main code here, to run repeatedly:
A potentiometer to exercise some external control
+
potValue = analogRead(potPin);
<br>
+
Serial.println(potValue);
[[File:Servo pot.png | 900 px]] <br>
+
analogWrite(ledPin, potValue);
 +
}
  
<syntaxhighlight lang=c style="border:3px dashed blue">
+
</syntaxhighlight>
/*
 
Controlling a servo position using a potentiometer (variable resistor)
 
by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
 
  
modified on 8 Nov 2013
+
'''Now MAP the values'''
by Scott Fitzgerald
 
http://www.arduino.cc/en/Tutorial/Knob
 
*/
 
  
#include <Servo.h>
+
<syntaxhighlight lang=c style="border:3px dashed pink">
  
Servo myservo; // create servo object to control a servo
+
int potPin = A0;
 +
int potValue = 0;
 +
int ledPin = 9;
  
int potpin = 0;  // analog pin used to connect the potentiometer
 
int val;    // variable to read the value from the analog pin
 
  
 
void setup() {
 
void setup() {
   myservo.attach(9); // attaches the servo on pin 9 to the servo object
+
   // put your setup code here, to run once:
 +
 
 +
  Serial.begin(9600);
 
}
 
}
  
 
void loop() {
 
void loop() {
   val = analogRead(potpin);           // reads the value of the potentiometer (value between 0 and 1023)
+
   // put your main code here, to run repeatedly:
   val = map(val, 0, 1023, 0, 180);    // scale it to use it with the servo (value between 0 and 180)
+
  potValue = analogRead(potPin);
  myservo.write(val);                 // sets the servo position according to the scaled value
+
   int mappedValue = map(potValue, 0, 1023, 0, 255);
   delay(15);                           // waits for the servo to get there
+
   analogWrite(ledPin, mappedValue);
 
}
 
}
 +
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
=Notes=
 +
Here you will find a PDF with diagrams from the Arduino Basics Workshop: <br>
 +
[[Media:arduino_basics_workshop.pdf]]
 +
 +
 +
[[Category:Arduino]]

Latest revision as of 10:03, 18 April 2023

What is an Arduino

The Arduino board
The Arduino IDE

From the Wikipedia article on Arduino we read[1]:

Arduino is an open-source computer hardware and software company, project and user community that designs and manufactures kits for building digital devices and interactive objects that can sense and control the physical world. Arduino boards may be purchased preassembled, or as do-it-yourself kits; at the same time, the hardware design information is available for those who would like to assemble an Arduino from scratch.

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. These types of work are usually called Physical Computing.
Physical Computing creates interactive systems by using electronics. The purpose is to prototype new materials for designers and artists.

What makes an Arduino?

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.
In essence Arduino is just another μController development board. The main purpose of such a μController development board is to make it easy for developers to evaluate the functions of, or create a quick prototype with, a certain type of μController. μControllers come in al sorts of tastes and sizes hence there are many different flavours of μController development boards as well. Do, for example, a Google search on microcontroller development board. You will see an abundance of different different platforms and most likely you will find some Arduino flavours there as well.

A bit of Arduino history

The project is based on a family of microcontroller board designs manufactured primarily by SmartProjects in Italy, and also by several other vendors, using various 8-bit Atmel AVR microcontrollers or 32-bit Atmel ARM processors. These systems provide sets of digital and analog I/O pins that can be interfaced to various extension boards and other circuits. The boards feature serial communications interfaces, including USB on some models, for loading programs from personal computers. For programming the microcontrollers, the Arduino platform provides an integrated development environment (IDE) based on the Processing project, which includes support for C and C++ programming languages.

The first Arduino was introduced in 2005. The project leaders sought to provide an inexpensive and easy way for hobbyists, students, and professionals to create devices that interact with their environment using sensors and actuators. Common examples for beginner hobbyists include simple robots, thermostats and motion detectors.

What do you use Arduino for?

Arduino is involved in lots of works. Here are some examples:


The Arduino board

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 different kinds of pins, each of which is labeled on the board and used for different functions.
Board layout.PNG
In details:
Arduino-uno.png

Inputs and Outputs

μControllers like Arduino are optimized for control of general input and output. What are those two exactly?
Analog Input Pins ( we have six of them in the Uno): The area of pins under the ‘Analog In’ label (A0 through A5 on the UNO) are Analog In pins. These pins can read the signal from an analog sensor (like a temperature sensor) and convert it into a digital value that we can read.
Digital Input Pins (seven on the Uno): Across from the analog pins are the digital pins (0 through 13 on the UNO). These pins can be used for both digital input (like telling if a button is pushed) and digital output (like powering an LED).

Getting started on the Arduino board and software

Now that we have our board we should start by figuring put if our Arduino is all good or it is somehow damaged. To do this we are running a simple script on the board. You can download the Arduino software here.
To upload the sketch you can got to:

File ---> Examples ---> Basics --->Blink


You will see something like this:

/*
  Blink
  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 http://www.arduino.cc

  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
}

Arduino-LED-Overview.jpg

To make sure your board is connected you should check a couple of things

  • Make sure your board and port is selected

Port.png

  • Compile the sketch
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

Compile.png

  • Upload the sketch on the board

Upload.png

Example: Getting data from an input

The knob

Analogreadserial.png

 
/*
  AnalogReadSerial

  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.

  http://www.arduino.cc/en/Tutorial/AnalogReadSerial
*/

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// 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:
  Serial.println(sensorValue);
  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:

Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
 potValue = analogRead(potPin);
 Serial.println(potValue);
 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:

  Serial.begin(9600);
}

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

Notes

Here you will find a PDF with diagrams from the Arduino Basics Workshop:
Media:arduino_basics_workshop.pdf