לימוד ארדואינו : שיעור 11 – פונקציות – קורס C506
בהרצאה זאת נילמד שימוש בשפת סי , מה זה פונקציה ואיך לכוב קוד תוכנה בסביבת ארדואינו בשימוש בפונקיות
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
// www.robotronix.co.il // לימוד שפת סי , בסביבת ארדואינו קורס C506 // רובוטרוניקס מפתחת תוכנה ואלקטרוניקה - משדרים כרטיסים אלקטרונים // קורסים למהנדסים , בתי ספר , ונוער int a,b,c; void setup() { // put your setup code here, to run once: Serial.begin(9600); msg1(); Ver(); a=10; b=5; c = ADD(a,b); Serial.print("ADD : "); Serial.println(c); } void loop() { // put your main code here, to run repeatedly: delay(2000); } void Ver(void) { Serial.println(" Ver 1.0 "); } void msg1(void) { Serial.println(" Welcome to course c506 to learn c , functions "); } int ADD(int n1,int n2) { int n3; n3= (n1+n2); return (n3); // return values } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
// www.robotronix.co.il // לימוד שפת סי , בסביבת ארדואינו קורס C506 // רובוטרוניקס מפתחת תוכנה ואלקטרוניקה - משדרים כרטיסים אלקטרונים // קורסים למהנדסים , בתי ספר , ונוער int a,b,c; int IsAddOk=1; void setup() { // put your setup code here, to run once: Serial.begin(9600); msg1(); Ver(); a=10; b=5; c = ADD(a,b); if (IsAddOk==1) { // ADD IS O,K } Serial.print("ADD : "); Serial.println(c); } void loop() { // put your main code here, to run repeatedly: delay(2000); } void Ver(void) { Serial.println(" Ver 1.0 "); } void msg1(void) { Serial.println(" Welcome to course c506 to learn c , functions "); } int ADD(int n1,int n2) { int n3; if ( (n1==0) || (n2==0) ) { Serial.println(" Parameters must be biggers then zero "); IsAddOk=0; } n3= (n1+n2); return (n3); // return values } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
// www.robotronix.co.il // לימוד שפת סי , בסביבת ארדואינו קורס C506 // רובוטרוניקס מפתחת תוכנה ואלקטרוניקה - משדרים כרטיסים אלקטרונים // קורסים למהנדסים , בתי ספר , ונוער int a,b,c; int CheckPositive(float n) { if (n>=0) { Serial. println("Number is positive"); return(1); // true } else { Serial. println("Number is negative"); return(0); // false } } void setup() { // put your setup code here, to run once: Serial.begin(9600); if(CheckPositive(-100)) // 1==> true , 0 ==> false { Serial. println("return(1);"); } else { Serial. println("return(0);"); } } void loop() { // put your main code here, to run repeatedly: delay(2000); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
// www.robotronix.co.il // לימוד שפת סי , בסביבת ארדואינו קורס C506 // רובוטרוניקס מפתחת תוכנה ואלקטרוניקה - משדרים כרטיסים אלקטרונים // קורסים למהנדסים , בתי ספר , ונוער #include <stdio.h> #include <string.h> int a,b,c; // strstr void setup() { char email[100]; strcpy(email,"dev@robotronix.gov.il"); // put your setup code here, to run once: Serial.begin(9600); if(strstr(email,"co.il") || strstr(email,"gov.il") || strstr(email,"edu.il") || strstr(email,"edu.il")) // strstr >0 ==> true , 0 ==> false { Serial. println("email is from israel , o.k"); } else { Serial. println("Please enter email only from israel "); } } void loop() { // put your main code here, to run repeatedly: delay(2000); } |
לימוד ארדואינו : שיעור 11 – פונקציות – קורס C506 שפת C
פונקציות בשפת C