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:iot-open:programming_fundamentals_rtu:libraries [2018/02/07 10:03] Agrisniken:iot-open:programming_fundamentals_rtu:libraries [2020/07/20 09:00] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== Libraries ====== ====== Libraries ======
 +The opportunities of using Arduino can be extended by using additional libraries. Arduino IDE already contains many libraries that extend the functionality of the sketch in cases of working with hardware or manipulating with data. These libraries can be added to the sketch using //#include// statement. If a new library should be added to the sketch, it can be done by following the path - //Sketch->Import Library//. The instructions for installing additional library can be found following the link((https://www.arduino.cc/en/Guide/Libraries)). If necessary, it is also possible to create own library. The tutorial for writing own library can be found following the link((https://www.arduino.cc/en/Hacking/LibraryTutorial)).
  
-===== Math =====+As the example, //Math.h// library is viewed. The use of other libraries, like //Servo.h, LiquidCrystal.h, Wire.h, SPI.h, SmartEink.h, Stepper.h// is given in the examples of the sections //"Sensors and sensing"// and //"Drivers and driving"//
 + 
 + 
 +===== The Math library =====
 The //Math// library extends the functionality of code in terms of mathematics and is called //math.h//. This header file declares basic mathematics constants and functions. Before starting using it, it must be included in the code at the very beginning in the following way: The //Math// library extends the functionality of code in terms of mathematics and is called //math.h//. This header file declares basic mathematics constants and functions. Before starting using it, it must be included in the code at the very beginning in the following way:
  
Line 8: Line 12:
 </code> </code>
  
-The //Math// library includes such functions like //cos, sin, tan, exp, log, log10, pow, square,// etc.+The //Math// library includes multiple functions for manipulating floating point numbers, like //cos, sin, tan, exp, log, log10, pow, square,// etc. The full documentation of the library and functions it includes, can be found in the 
  
 +The following example shows, how the //Math.h// library is used in the sketch:
 +<code c>
 +#include <math.h>
  
-===== Random =====+const double pi 3.14; 
 +double x 3.0; 
 +double y 4.0; 
 + 
 +void setup() { 
 +  Serial.begin(9600); 
 +  Serial.println("cos(Pi) "); 
 +  Serial.print(cos(pi)); //cos function of PI 
 +   
 +  Serial.println("sin(Pi) "); 
 +  Serial.print(sin(pi)); //sin function of PI 
 +   
 +  Serial.println("pow(3, 4) "); 
 +  Serial.print(pow(3,4)); //3 raised to the power of 4 
 +
 + 
 +void loop() { 
 +
 +</code>
  
-===== Other libraries =====+In the given example, three mathematical functions are used - cosine (//cos//), sine (//sin//) and raising to the power (//pow//). The results are printed out to the Serial monitor. In this case functions are used in the //setup// part, so that they are executed only once on initialization.
  
-==== Adding and creating libraries ==== 
-==== Example of Servo library ==== 
-==== Example of Tone library ==== 
-==== Example of display libraries ==== 
  
  
en/iot-open/programming_fundamentals_rtu/libraries.1517997804.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