Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
public:crocs:arduino [2014-10-26 13:58] mukroppublic:openlab:autumn2014:arduino [2015-02-10 20:18] – images moved to openlab namespace lnemec
Line 1: Line 1:
-====== OpenLab 2014/05 | Hands on Arduino ======+====== OpenLab 2014/07 | Hands on Arduino ======
  
   * Date: 31. 10. 2014   * Date: 31. 10. 2014
Line 5: Line 5:
   * Cake: we will see...   * Cake: we will see...
   * Cake by: Mirek Jaroš   * Cake by: Mirek Jaroš
 +  * Discussion on A403 wallpainting
 +
 +===== 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. 
 +
 +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.
  
-[Lukas, please add short description of what you expect us to be doing. 1-2 sentences.] 
 ===== What to prepare ===== ===== What to prepare =====
  
Line 18: Line 24:
  
 ===== Arduino Theory ===== ===== Arduino Theory =====
-{{ :public:crocs:arduino:arduinos.png?direct&500}} + 
-Arduinos come in many different flavours, from basic UNO to MEGA, or specialized one's, for example arduino robot. Also there are many shields, which can add specific functionality to your arduino, for example GSM of WIFI shields. These become usefull, when you are building a diet control machine, that will publish tweet every time you open door to your fridge. Also there is wide range of sensors, so you can measure almost everything, from light and humidity to methane concentration.+{{ :public:openlab:arduinos.png?direct&500}} 
 + 
 +==== Arduino Ecosystem ==== 
 + 
 +Arduino is phenomenon of last few years, quickly gaining popularity in many fileds. It originated somewhere in DIY community as easily managable microcontroller with Open-Source designthat was accesible to everyone. With this huge succes, family of official Arduino board quickly grew, as well as all other products, that were somehow Arduino related.  
 + 
 +Today There is huge selection of boards, starting from basic UNO, litle bit more advanced Leonardo, up to Arduino MEGA. On the other sideif 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 developement, you can try out Arduino Yún or soon comming Arduino Tre. There is also market for special purpose microcontrolers, like wearable electronics, which can be designed using Arduino LillyPad and conductive thread.  
 + 
 +Also open source design of Arduino is by many viewed as 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 accesoris, there are many shields, which can add specific functionality to your arduino, for example GSM of WIFI shields. These become usefull, when you are building a diet control machine, that will publish tweet every time you open door to your fridge. Also there is wide range of sensors, so you can measure almost everything, from light and humidity to methane concentration.
  
 ==== How to connect everything together ==== ==== How to connect everything together ====
Line 94: Line 110:
  
 <note important>When connecting LED, remember that LEDs are like all other diodes, so electricity flows in one direction only. The longer lead is positive (anode) needs to be connected to power and shorter leg (cathode) to ground.</note>  <note important>When connecting LED, remember that LEDs are like all other diodes, so electricity flows in one direction only. The longer lead is positive (anode) needs to be connected to power and shorter leg (cathode) to ground.</note> 
-<note warning>LEDs are not capable of handling arduino's 5V power, so resistor is required. Usually one which has 220Ω is used, but in this case it is not necessary to be exact, so you can use 200Ω or 300Ω as well and it will slightly affect brightness of LED, but nothing more.</note>+<note warning>LEDs are not capable of handling arduino's 5V power, so resistor is required. Usually one which has 220Ω is used, but in this case it is not necessary to be exact, so you can use 200Ω or 300Ω as well and it will slightly affect brightness of LED, but nothing more. Generally more resistance does no harm, less resistance could burn the LED.</note> 
 + 
 +{{ :public:openlab:led_blink.png?direct&700 |}} 
 +=== 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 posibilities what to use as a source of input, you can choose from whatever is avaiable, rotary potentiometer, light resistor (changes resistivity based on light) or any other option you choose.  
 + 
 +Every sensor (save he more complicated ones) has basically three connections, power (Arduino's 5V), ground and output. Output is connected to analog input pin, in case of image below, two options are illustrated, one light resistor (with another 10KΩ resistor for better results) and one rotary potentiometer, both produce analog values from 0 to 1023, while read with analogRead function.  
 + 
 +Next is serial output, which can be used either for debugging or logging values. Output needs to be inicialized in setup phase with following ''Serial.begin(9600);'' where 9600 means frequency in bauds. Then you can use ''Serial.println("text");'' anywhere in code. This messages can be captured, if you open Serial monitor from IDE (shortcut CTRL+Shift+M) and select same frequency as previously.  
 + 
 +<code C> 
 +int sensorPin = A0;    // select the input pin for the potentiometer 
 +int sensorValue = 0;  // variable to store the value 
 + 
 +void setup() { 
 +  //initialize both pin and Serial 
 +  pinMode(sensorPin, INPUT);     
 +  Serial.begin(9600); 
 +
 + 
 +void loop() { 
 +  // read the value 
 +  sensorValue = analogRead(sensorPin);     
 +  //print value on serial 
 +  Serial.println(sensorValue);     
 +  //wait 
 +  delay(1000);                   
 +
 +</code> 
 + 
 +{{ :public:openlab:arduino_analog.png?direct&700 |}} 
 +<note important>Image shows two possible options, connected to pins A0 and A1, code shows reading input only from A0.</note> 
 + 
 +===== How to continue ===== 
 + 
 +==== 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: 
 +  * 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://arduino.cc/ 
 +  * Makezine videos, or paper issue: http://makezine.com/category/electronics/arduino/  
 +  * many other, just search for "Arduino Ideas"  
 + 
 +==== What to buy ==== 
 +You will need something to start with, either you already have some electronics, and you just need ome jump start into it, or you are starting from scratch. Either way, there are many ways to spend your budget, so here comes list of essential parts and tools and also list of nice things to have, but which you can do without.   
 + 
 +=== 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 limited number of pins, and some other limitations, but for our cause they will be more than sufficient and only few changes has to be made.  
 + 
 +First connections, following image shows how to connect JeeNode, LED and resistor together, especially which ports to use, since they are not as nicely labelled as other Arduino boards.  
 + 
 +{{ :public:openlab:jeenode_led.png?direct&500|}} 
 + 
 +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, OUTPUT); 
 +
 + 
 +void loop() {   
 +  digitalWrite(ledPin, HIGH);   
 +  delay(1000);               
 +  digitalWrite(ledPin, LOW);    
 +  delay(1000);               
 +
 +</code> 
 + 
 +Other projects are changed acordingly. 
 + 
 + 
 + 
  
-{{ :public:crocs:arduino:led_blink.png?direct&700 |}}