![Arduino සිංහලෙන් - IV](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhZhYljZfiku6dD8cHlUkDB15fQ1YejAonN50RzK8jba6Yz2FXnD64m40WU5cHURfP_js2FcGYKSVZzLCe0jQerKjyN5smfixuFdZwzeDPeEZyQb-x6GywIWbqBZSiz_XzzN0P7vO06j4/w700/isxyf%252Ckabf.k.uq.png)
Arduino වැඩසටහන් සැකැස්ම
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhZhYljZfiku6dD8cHlUkDB15fQ1YejAonN50RzK8jba6Yz2FXnD64m40WU5cHURfP_js2FcGYKSVZzLCe0jQerKjyN5smfixuFdZwzeDPeEZyQb-x6GywIWbqBZSiz_XzzN0P7vO06j4/s400/isxyf%252Ckabf.k.uq.png)
Arduino යනු විවෘත නිදහස් මෘදුකාංගයකි. Arduino පාරිභාෂික වැඩසටහන් හඳුන්වන්නේ Sketch ලෙසය.
Arduino වැඩසටහනක් ප්රධාන කොටස් තුනකින් සමන්විත වේ. ඒවා නම් Structure, Values (variables and constants), සහ Functions වේ.
Arduino වැඩසටහනක් ප්රධාන කොටස් තුනකින් සමන්විත වේ. ඒවා නම් Structure, Values (variables and constants), සහ Functions වේ.
1. Structure
මෘදුකාංගයේ Structure එක ප්රධාන functions(ශ්රිත ) දෙකකින් යුක්තය.* Setup( ) function - Sketch හි ආරම්භය මෙයයි.
* Loop( ) function - Setup( ) function එක නිර්මාණය කිරීමෙන් පසුව වැඩසටහන ක්රියාත්මක වීමට හා ප්රතිචාර දැක්වීමට මෙන්ම Arduino පුවරුව පාලනය කිරීමට යොදාගනී.
Data types
Arduino වල දත්ත ස්වරූප C වලට සමාන වේ. දත්ත ගබඩා වන ආකාරය සහ යෙදෙන විදිය මෙහිදී ප්රධාන ලෙස දැක්වේ. Arduino වල භාවිතා වන දත්ත ස්වරූප පහත දැක්වේ.
- void Boolean char
- Unsigned
- char
- byte int Unsigned int word
- long
- Unsigned
- long
- short float double array
- String-char
- array
- String-object
void - ශ්රිත අත්හිටුවීම සඳහා මෙය යොදාගනී. ශ්රිතයට නැවත දැක්වීම සඳහා තොරතුරු නැතිබව මින් හඟවයි.
Void Loop ( )
{
// rest of the code
}
Boolean - සත්ය හෝ අසත්ය බව (True/False) දැක්වෙන දත්ත ගබඩා කිරීමට යොදාගනී. සෑම Boolean විචල්යක්ම (variable)එක byte එකක් මතකයෙන් ලබාගනී.
boolean val = false ; // declaration of variable with type boolean and initialize
it with false
boolean state = true ; // declaration of variable with type boolean and
initialize it with false
Char - character එකක් හෙවත් ගුණාංගයක් මතකය තුල එක byte එකකින් ගබඩා කිරීමට යොදාගන්නා දත්ත ස්වරූපය මෙය වේ. character එකක් ලියන විට ' ' තුලද,characters කිහිපයක් ලියනවිට " " තුලද ලියනු ලැබේ.
ASCII වටිනාකම් වලින් characters ලියනවිට මෙය වැදගත් වේ. මක් නිසාද යත් characters ගබඩා වී ඇත්තේ අංක ලෙසය. ASCII වටිනාකම් බලාගැනීමට මෙය යොදාගන්න.
Char chr_a = ‘a’ ;//declaration of variable with type char and initialize it
with character a
Char chr_c = 97 ;//declaration of variable with type char and initialize it
with character 97
Unsigned char - මතකයෙන් එක byte එකක් අයත් කරගන්නා 0-255 දක්වා වූ අගයන්ගෙන් සමන්විත දත්ත වර්ගය වේ.
Unsigned Char chr_y = 121 ; // declaration of variable with type Unsigned
char and initialize it with character y
byte - 0-255 දක්වා වූ 8-බිටු අංක සහිත දත්ත ගබඩා වීම මෙහිදී සිදුවේ.
byte m = 25 ;//declaration of variable with type byte and initialize it with
25
int - int යනු Integers හෙවත් පූර්ණ සංඛ්යා වේ. 16 බිටු වටිනාකම් සහිත දත්ත මෙහිදී ගබඩා වේ. මෙහි සංඛ්යා පරාසය වන්නේ -32,768 සිට 32,767 දක්වා වේ.
int counter = 32 ;// declaration of variable with type int and initialize it with
32
Unsigned int - මෙහිදී ගබඩා වන්නේ byte දෙකෙහි ධන පූර්ණ සංඛ්යා අගයන් වේ.
Unsigned int counter= 60 ; // declaration of variable with type unsigned int and
initialize it with 60
Word - බිටු 16 ක අංක ගබඩා වේ.
word w = 1000 ;//declaration of variable with type word and initialize it with
1000
Long - බිටු 32 ක දිගු විචල්යයන් ගබඩා කිරීම සඳහා යොදාගන්නා දත්ත වර්ගය මෙය වේ. එහි පරාසය 2,147,483,648 සිට 2,147,483,647 අතර වේ.
Long velocity= 102346 ;//declaration of variable with type Long and initialize
it with 102346
unsigned long - unsigned long හි විචල්යය දත්ත ලෙස ගබඩා කරන්නේ ධන ඉලක්කම් පමණක් වේ. ඍණ සංඛ්යා ඇතුලත් නොවේ.
Unsigned Long velocity = 101006 ;// declaration of variable with type Unsigned
Long and initialize it with 101006
Short - Short එකක් යනු බිටු 16 ක දත්ත වර්ගයකි. මෙහි දත්ත පරාසය වන්නේ -32,768 - 32,768 දක්වා වේ.
short val= 13 ;//declaration of variable with type short and initialize it with
13
float - දශමය සංඛ්යා ආකාරය floating-point අංක ලෙස හැඳින්වේ. floating-point අංක වල විශාලත්වය 3.4028235E+38 වන අතර,කුඩාම අගය 3.4028235E+38 වේ.
float num = 1.352;//declaration of variable with type float and initialize it
with 1.352
double - බිටු 4 හෝ බිටු 8 ප්රමාණයන්ගෙන් යුක්ත float මෙන්ම දශමය සංඛ්යා ආකාරය මෙමඟින් නිරූපණය කරයි.
double num = 45.352 ;// declaration of variable with type double and initialize
it with 45.352