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-30 19:42] – 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š | ||
- | * Discussion on A403 wallpainting | ||
===== 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. |
- | As we 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 21: | 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 ===== | ||
- | {{ : | ||
+ | {{ : | ||
==== Arduino Ecosystem ==== | ==== Arduino Ecosystem ==== | ||
- | Arduino is phenomenon of last few years, quickly gaining popularity in many fileds. It originated somewhere in DIY community as easily | + | Arduino is a phenomenon of last few years, quickly gaining popularity in many fields. It originated somewhere in DIY community as easily |
- | Today There is huge selection of boards, starting from basic UNO, litle bit more advanced Leonardo, up to Arduino MEGA. On the other side, if you are interested in smaller sizes, there is Arduino micro, mini and nano, some that small, that there is no space for usb connectivity. Also, if you want to keep up with latest | + | Today There is huge selection of boards, starting from basic UNO, a little |
- | Also open source design of Arduino is by many viewed as perfect point to start with own modifications, | + | Also open source design of Arduino is by many viewed as the perfect point to start with own modifications, |
- | Concerning | + | Concerning |
==== 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 86: | 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 107: | 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 === | === 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. | 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 posibilities | + | 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 |
- | Every sensor (save he more complicated ones) has basically three connections, | + | 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 inicialized | + | Next is serial output, which can be used either for debugging or logging values. Output needs to be initialized |
<code C> | <code C> | ||
Line 144: | Line 141: | ||
</ | </ | ||
- | {{ :public:crocs: | + | {{ :public:openlab: |
<note important> | <note important> | ||
Line 151: | Line 147: | ||
==== Ideas, where to get them ==== | ==== Ideas, where to get them ==== | ||
- | As stated previously, 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: | + | As stated previously, |
* Arduino Started Kit (book of 15 tutorials together with Arduino board and parts you will need) | * 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:// | * Other official Arduino Examples and already finished projects http:// | ||
Line 158: | Line 154: | ||
==== What to buy ==== | ==== What to buy ==== | ||
- | You will need something to start with, either you already have some electronics, | + | You will need something to start with, either you already have some electronics, |
=== Essential === | === Essential === | ||
Line 183: | Line 179: | ||
===== JeeNodes ===== | ===== JeeNodes ===== | ||
- | Jeenodes are special purpose boards (Arduino based) for WSN networks. Because of these facts, there is limited number of pins, and some other limitations, | + | 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, | + | First connections, |
- | + | ||
- | {{ : | + | |
+ | {{ : | ||
And now the other part, small change in source code: | And now the other part, small change in source code: | ||
Line 201: | Line 196: | ||
void loop() { | void loop() { | ||
- | digitalWrite(ledPin, | + | digitalWrite(ledPin, |
- | delay(1000); | + | delay(1000); |
- | digitalWrite(ledPin, | + | digitalWrite(ledPin, |
- | delay(1000); | + | delay(1000); |
} | } | ||
</ | </ |