Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
public:crocs:arduino [2014-10-26 21:56] – [OpenLab 2014/07 | Hands on Arduino] What to expect lnemec | public:openlab:autumn2014:arduino [2016-12-01 14:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== OpenLab 2014/07 | Hands on Arduino ====== | ====== OpenLab 2014/07 | Hands on Arduino ====== | ||
- | * Date: 31. 10. 2014 | + | * Date: 31. 10. 2014 && 11.3.2016 |
* Workshop by: Lukáš Němec | * Workshop by: Lukáš Němec | ||
* Cake: we will see... | * Cake: we will see... | ||
- | * Cake by: Mirek Jaroš | ||
===== What to expect ===== | ===== What to expect ===== | ||
- | Introduction to microcontroller programming, focused mainly on Arduino platform. We will start with basics, what to expect from Arduino and what is Arduino capable of with some examples. Then theoretic part, how to connect everything together and mainly how to write programs. Thus everything from using basic C skills to Arduino specific functions. | + | Introduction to microcontroller programming focused mainly on Arduino platform. We will start with basics, what to expect from Arduino and what is Arduino capable of with some examples. Then theoretic part, how to connect everything together and mainly how to write programs. Thus everything from using basic C skills to Arduino-specific functions. |
- | When we will learn enough of theoretic background, you will get your hands on Arduino boards and you will have chance to program your own blinking LED or something similar, depending on your time, skill and enthusiasm. | + | As we learn enough of theoretic background, you will get your hands on Arduino boards and you will have a chance to program your own blinking LED or something similar, depending on your time, skill and enthusiasm. |
===== What to prepare ===== | ===== What to prepare ===== | ||
Line 20: | Line 19: | ||
- Google and own imagination ;-) | - Google and own imagination ;-) | ||
| | ||
- | There will be supply of leds, resistors, some sensors (light, temperature, | + | There will be a supply of LEDs, resistors, some sensors (light, temperature, |
===== Arduino Theory ===== | ===== Arduino Theory ===== | ||
- | {{ :public:crocs: | + | |
- | Arduinos come in many different flavours, from basic UNO to MEGA, or specialized one's, for example | + | {{ :public:openlab: |
+ | |||
+ | ==== Arduino Ecosystem ==== | ||
+ | |||
+ | Arduino is a phenomenon of last few years, quickly gaining popularity | ||
+ | |||
+ | Today There is huge selection of boards, starting | ||
+ | |||
+ | Also open source design of Arduino is by many viewed as the perfect point to start with own modifications, for example, Jeenodes - Arduino based WSN modules. Also, there is wide range of unofficial boards, that just take open source design, and sell it under different name with cheaper price (Funduino, Robotino etc. usually called Arduino compatible HW) | ||
+ | |||
+ | Concerning accessories, | ||
==== How to connect everything together ==== | ==== How to connect everything together ==== | ||
- | Every arduino | + | Every Arduino |
===Digital pins=== | ===Digital pins=== | ||
- | Use digital signal, thus input and output has only two possible values. These are 1 and 0, or in practical view, 5V or nothing. Digital pins can be also used to read data, but again only two states, so ideal choice for switches. To make things little bit more tricky, some digital pins have pulse-width modulation (PWM) enabeled | + | Use digital signal, thus input and output has only two possible values. These are 1 and 0, or in practical view, 5V or nothing. Digital pins can be also used to read data, but again only two states, so ideal choice for switches. To make things little bit more tricky, some digital pins have pulse-width modulation (PWM) enabled |
===Analog pins=== | ===Analog pins=== | ||
- | Analog pins are used for analog read, when we need more precise value than just binary 0 or 1. Output | + | Analog pins are used for analog read when we need more precise value than just binary 0 or 1. The output |
=== Power and special pins === | === Power and special pins === | ||
- | Last category of pins are power pins, these are ground pins, 5V and 3.5V pins. Connect these to power breadboard power lines or components directly, as needed. | + | The last category of pins are power pins, these are ground pins, 5V, and 3.5V pins. Connect these to power breadboard power lines or components directly, as needed. |
- | All other pins are used for special purposes, like reset pin or in case of smaller or older versions of arduino | + | All other pins are used for special purposes, like reset pin or in a case of smaller or older versions of Arduino |
<note important> | <note important> | ||
==== How to upload code ==== | ==== How to upload code ==== | ||
- | Recomended | + | Recommended |
- | - Connect | + | - Connect |
- Start Arduino IDE | - Start Arduino IDE | ||
- Select Tools - Board Type (mostly Arduino UNO) | - Select Tools - Board Type (mostly Arduino UNO) | ||
- | - Select Tools - Serial Port (there will be usually only one, when only one arduino | + | - Select Tools - Serial Port (there will be usually only one when only one Arduino |
- Write your code or open some example sketches (or load some saved sketches) | - Write your code or open some example sketches (or load some saved sketches) | ||
- | - Do all the wiring (can be done as first step or as last) | + | - Do all the wiring (can be done as the first step or as last) |
- Press Ctrl + R to compile | - Press Ctrl + R to compile | ||
- | - Press Ctrl + U to upload code to your arduino | + | - Press Ctrl + U to upload code to your Arduino |
- Optionally repeat while fixing bugs or adding features (two names for the same thing) | - Optionally repeat while fixing bugs or adding features (two names for the same thing) | ||
Line 75: | Line 84: | ||
=== Blinking LED === | === Blinking LED === | ||
- | Now for some code, that actually does something | + | Now for some code, that actually does something |
<code C> | <code C> | ||
//global constant for more comprehensible code, you can use just number, | //global constant for more comprehensible code, you can use just number, | ||
- | //this way it is just more user friendly when handling multiple pins | + | //this way it is just more user-friendly when handling multiple pins |
int ledPin = 13; | int ledPin = 13; | ||
Line 96: | Line 105: | ||
</ | </ | ||
- | This code also requires some basic assembly, LED needs to be connected to arduino, it is recomended | + | This code also requires some basic assembly, LED needs to be connected to Arduino, it is recommended |
<note important> | <note important> | ||
- | <note warning> | + | <note warning> |
+ | |||
+ | {{ : | ||
+ | === Sensors, Analog input and Serial monitor === | ||
+ | |||
+ | Next example will show, how to read values from sensors and how to obtain debugging information from Arduino board. | ||
+ | |||
+ | In order to receive value from sensor, we have to use analog input pins (Arduino UNO has range from A0 to A5) and read values with analogRead function. There are many possibilities what to use as a source of input, you can choose from whatever is available, rotary potentiometer, | ||
+ | |||
+ | Every sensor (save the more complicated ones) has basically three connections, | ||
+ | |||
+ | Next is serial output, which can be used either for debugging or logging values. Output needs to be initialized in setup phase with following '' | ||
+ | |||
+ | <code C> | ||
+ | int sensorPin = A0; // select the input pin for the potentiometer | ||
+ | int sensorValue = 0; // variable to store the value | ||
+ | |||
+ | void setup() { | ||
+ | // | ||
+ | pinMode(sensorPin, | ||
+ | Serial.begin(9600); | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | // read the value | ||
+ | sensorValue = analogRead(sensorPin); | ||
+ | //print value on serial | ||
+ | Serial.println(sensorValue); | ||
+ | //wait | ||
+ | delay(1000); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | {{ : | ||
+ | <note important> | ||
+ | |||
+ | ===== How to continue ===== | ||
+ | |||
+ | ==== Ideas, where to get them ==== | ||
+ | As stated previously, the idea is begining of everything, thus, you need ideas what to do with Arduino. Hopefully, you can come up with many of your own, but if you need some inspiration boost, following might help: | ||
+ | * Arduino Started Kit (book of 15 tutorials together with Arduino board and parts you will need) | ||
+ | * Other official Arduino Examples and already finished projects http:// | ||
+ | * Makezine videos, or paper issue: http:// | ||
+ | * many other, just search for " | ||
+ | |||
+ | ==== What to buy ==== | ||
+ | You will need something to start with, either you already have some electronics, | ||
+ | |||
+ | === Essential === | ||
+ | |||
+ | * Arduino Board | ||
+ | * some basic electronic parts (LEDs, resistors) | ||
+ | * breadboard | ||
+ | * jumper wires | ||
+ | |||
+ | === Nice to have === | ||
+ | |||
+ | * variety of sensors | ||
+ | * All other usefull parts (depending on project this can be servo motors of Liquid crystal display etc.) | ||
+ | * multimeter | ||
+ | * sothering iron (when you want to make project permanent) | ||
+ | * more Arduino boards (more projects at once becomes easier) | ||
+ | |||
+ | |||
+ | ==== Where to buy ==== | ||
+ | * Official Arduino strore - arduino.cc, based in Italy, sells Arduino boards, shields, sensors | ||
+ | * GM electronics - gme.cz, overpriced Arduinos, but nice for small parts like LEDs, based in Brno, so ideal if you are missing just one part to complete project | ||
+ | * dealExreme.com - dx.com, china based, cheap, not original Arduinos, but Funduinos etc. (so called Arduino compatible parts), takes about 4 weeks to arrive, ideal for stocking up on parts of budget buys of boards | ||
+ | |||
+ | ===== JeeNodes ===== | ||
+ | |||
+ | Jeenodes are special purpose boards (Arduino based) for WSN networks. Because of these facts, there is a limited number of pins and some other limitations, | ||
+ | |||
+ | First connections, | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | And now the other part, small change in source code: | ||
+ | |||
+ | <code C> | ||
+ | //pin placement is changed to 4 | ||
+ | int ledPin = 4; | ||
+ | |||
+ | void setup() { | ||
+ | pinMode(ledPin, | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | digitalWrite(ledPin, | ||
+ | delay(1000); | ||
+ | digitalWrite(ledPin, | ||
+ | delay(1000); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Other projects are changed acordingly. | ||
+ | |||
+ | |||
+ | |||
- | {{ : | ||