Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:arduino [2015/12/10 12:46] kaupo.raiden:arduino [2020/07/20 09:00] (current) – external edit 127.0.0.1
Line 12: Line 12:
 */ */
  
-====== Näide 1 Digital I/O ====== 
  
-===== Näide 1.1 Push down button to light up LED =====+====== References ====== 
 + 
 +[[http://itead-europe.com/pm/platform/shield/1602%20lcd%20shield/SCH_IM120417018_Arduino1602LCDShield.pdf|LCD Shield datasheet]]\\ 
 +[[http://www.sharpsma.com/webfm_send/1489|sharp 10-80cm analog distance sensor]] 
 + 
 +====== Example 1 Digital I/O ====== 
 + 
 +===== Example 1.1 Push down button to light up LED =====
  
 <code c> <code c>
-/* +
-Nimetus: Näide #1.1 Digitaalsed sisend-väljundid +
-Kirjeldus: Programm demonstreerib nupu ja LED-i kasutamist +
-Autor: Raivo Sell +
-Kuupäev: 15.01.2013 +
-*/+
 // Constants // Constants
 const int nupp = A0; // Viik kuhu on ühendatud nupp const int nupp = A0; // Viik kuhu on ühendatud nupp
Line 46: Line 47:
 </code> </code>
  
-===== Näide 1.2 On button push LED turns of for 1 second =====+===== Example 1.2 On button push LED turns of for 1 second =====
 <code c> <code c>
 // First part of code copy from example #1.1 // First part of code copy from example #1.1
Line 58: Line 59:
 </code> </code>
  
-===== Näide 1.3 LED turns on on button release =====+===== Example 1.3 LED turns on on button release =====
 <code c> <code c>
 // First part of code copy from example #1.1 // First part of code copy from example #1.1
Line 79: Line 80:
 0 %).*/ 0 %).*/
  
-====== Näide #2 Analog inputs ======+====== Example #2 Analog inputs ======
  
-===== Näide #2.1 When exceeding potentiometer threshold value the LED turns on =====+===== Example #2.1 When exceeding potentiometer threshold value the LED turns on =====
  
  
 <code c> <code c>
-/* 
-Nimetus: Näide #2.1 Analoog inputs 
-Kirjeldus: Programm demonstreerib analoogsisendi kasutamist 
-Autor: Raivo Sell 
-*/ 
  
 // Set threshold value at which the LED turns on // Set threshold value at which the LED turns on
 const int nivoo = 512;  const int nivoo = 512; 
  
-int pote_sisend = A1; // set potentiometer input pin +int pote_sisend = A0; // set potentiometer input pin 
-int led = A5; // set LED pin+int led = 13; // set LED pin
 int pote = 0; // integer variable to hold potentiometer value int pote = 0; // integer variable to hold potentiometer value
  
Line 110: Line 106:
 </code> </code>
  
-===== Näide #2.2 LED blinking speed depends on potentiometer value =====+===== Example #2.2 LED blinking speed depends on potentiometer value =====
  
  
 <code c> <code c>
-/* 
-Nimetus: Näide #2.2 Analoog sisendi teisendamine ajaks 
-Kirjeldus: Programm demonstreerib analoogsisendi kasutamist 
-Autor: David Cuartielles 
-Täiendused: Tom Igoe 
-Kohandused: Raivo Sell 
-OriginaalURL: http://arduino.cc/en/Tutorial/AnalogInput 
-*/ 
  
-int pote_sisend = A1; // set potentiometer pin +int pote_sisend = A0; // set potentiometer pin 
-int led = A5; // set LED pin+int led = 13; // set LED pin
 int pote = 0; // integer variable to hold potentiometer value int pote = 0; // integer variable to hold potentiometer value
  
Line 139: Line 127:
 </code> </code>
  
-===== Harjutus #2 =====+===== Task #2 =====
  
 Modify example program so that its possible to change LED brifgtness with potentiometer. Use delay functions. Modify example program so that its possible to change LED brifgtness with potentiometer. Use delay functions.
 /*Modifitseerida näiteprogrammi nii, et potentsiomeetriga määratakse LED-i heledus, kasutades selleks delay funktsioone.*/ /*Modifitseerida näiteprogrammi nii, et potentsiomeetriga määratakse LED-i heledus, kasutades selleks delay funktsioone.*/
  
-====== Näide #3 LCD ======+====== Example #3 LCD ======
  
-===== Näide #3.1 LCD using =====+Connect LCD shield to Arduino board. Before attaching remove all connections from the board. 
 + 
 +===== Example #3.1 LCD using =====
  
  
 <code c> <code c>
-/* 
-Nimetus: Näide #3.1 LCD kasutamine 
-Kirjeldus:Kasutab LiquidCrystal.h teeki ja ITEAD Studio 2x16 teksti laiendusplaati 
-Autor: Tom Igoe  
-Modifikatsioon: Raivo Sell 
-Kuupäev: 4.06.2014 
-Versioon: 1.0 
-*/ 
  
 #include <LiquidCrystal.h> // include needed libraries #include <LiquidCrystal.h> // include needed libraries
Line 178: Line 160:
 </code> </code>
  
-===== Näide #3.2 LCD and analog inputs =====+===== Example #3.2 LCD and analog inputs =====
  
 <code c> <code c>
-/* 
-Nimetus: Näide #3.2 LCD kasutamine analoogsisendiga 
-Kirjeldus:  
-          Kasutab LiquidCrystal.h teeki ja ITEAD Studio 2x16 teksti laiendusplaati 
-Autor: Tom Igoe  
-Modifikatsioon: Raivo Sell 
-Kuupäev: 4.06.2014 
-Versioon: 1.0 
-*/ 
  
 #include <LiquidCrystal.h> // include needed library #include <LiquidCrystal.h> // include needed library
Line 213: Line 186:
 </code> </code>
  
-===== Harjutus #3.1 =====+===== Task #3.1 =====
  
 Make a program that on button press changes LCD row. Potentiometer value has to be printed only on the new row.  Make a program that on button press changes LCD row. Potentiometer value has to be printed only on the new row. 
Line 220: Line 193:
  
  
-====== Näide Andurid ja LCD ======+====== Example Sensors and LCD ======
  
-===== Näide #4.1 Temperatuuri andur koos matemaatika teegiga =====+===== Example #4.1 Temperature sensor with math library =====
  
  
Line 247: Line 220:
 // Initsialiseerime LCD koos vastavate viikude ühendamisega // Initsialiseerime LCD koos vastavate viikude ühendamisega
 LiquidCrystal lcd(8, 9, 4, 5, 6, 7); LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
-int andur = A4; // määrame potentsiomeetri sisendviigu+int andur = A1; // set thermistor input pin
  
 void setup() { void setup() {
Line 306: Line 279:
 void loop()  void loop() 
  
-  // Read the input on analog pin and digital pin 10: +  // Read the input on analog pin and 3 
-  int AnalogSensorValue = analogRead(A0); +  int AnalogSensorValue = analogRead(A2); 
-  int DigitalSensorValue = digitalRead(10);+  int DigitalSensorValue = digitalRead(A3);
      
   Serial.println(AnalogSensorValue); // Print out the analog value   Serial.println(AnalogSensorValue); // Print out the analog value
Line 320: Line 293:
 ===== Harjutus #4.1 ===== ===== Harjutus #4.1 =====
 Modifitseerida programmi nii, et potentsiomeetriga määratakse temperatuuri nivoo, mis salvestatakse nupuga programmi mällu ja selle nivoo hilisemal ületamisel käivitatakse täiturmehhanism (milleks on LED). Modifitseerida programmi nii, et potentsiomeetriga määratakse temperatuuri nivoo, mis salvestatakse nupuga programmi mällu ja selle nivoo hilisemal ületamisel käivitatakse täiturmehhanism (milleks on LED).
 +**Extra:**
 +Kombineerida LED-i heleduse programm ja eelnev temperatuuri juhtimise programm, kus LED-i heledus sõltub sellest, kui palju nivootemperatuuri ületati (1 kraad: heledus 25 %, 2 kraadi: heledus 50 %, 3 kraadi: heledus 75 % ja 5 kraadi: heledus 10
  
 ===== Harjutus #4.2 ===== ===== Harjutus #4.2 =====
-Kombineerida LED-i heleduse programm ja eelnev temperatuuri juhtimise programm, kus LED-i heledus sõltub sellest, kui palju nivootemperatuuri ületati (1 kraad: heledus 25 %, 2 kraadi: heledus 50 %, 3 kraadi: heledus 75 % ja 5 kraadi: heledus 10+Modify distance sensor example so that it would print values on the LCD in centimeters (+-5cm accuracy). If no measureing tool is available then use the sensor datasheet graph.
  
 ====== Näide #5 Mootor ====== ====== Näide #5 Mootor ======
 +
 +Disconnect the LCD shield before using motors. Before disconnecting remove all connections from shield and Arduino board. 
  
 ===== Näide #5.1 Servomootor ===== ===== Näide #5.1 Servomootor =====
Line 377: Line 354:
  
 ===== Harjutus #5.1 ===== ===== Harjutus #5.1 =====
-Luua programm, mis võimaldab servomootori positsiooni muuta vastavalt nuppudega seadistatud suurusele.+Luua programm, mis võimaldab servomootori positsiooni muuta vastavalt analoog kaugusanduri väärtusele (kasutada map funktsiooni).
  
 ===== Harjutus #5.2 ===== ===== Harjutus #5.2 =====
-Luua programm, mis servomootori baasil ehitatud radariga ja fotoanduriga leiaks ruumist kõige eredama punkti. +Luua programm, mis servomootori baasil ehitatud radariga ja analoog kaugusanduriga leiaks ruumist lähima punkti (objekti otsimine tühjast ruumist).
  
 ====== Näide 6 Kommunikatsioon ====== ====== Näide 6 Kommunikatsioon ======
en/arduino.1449751617.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0