לימוד ארדואינו : תרגול 6 , קורס C506 הרצאה 1 – 7
רשום המ יהיה הפלט הבא של התוכנית – ללא להריץ במחשב !
שאלה 1
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 |
void setup() { // put your setup code here, to run once: int t=28; int h =78; int m=3400; int p=5; Serial.begin(9600); Serial.println("start"); if (t==20) { Serial.println("temp is 20"); } if (m<3400) { Serial.println("motor low "); } } void loop() { // put your main code here, to run repeatedly: } |
שאלה 2
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 |
void setup() { // put your setup code here, to run once: int t=28; int h =78; int m=3400; int p=5; Serial.begin(9600); Serial.println("start"); if (t==28) { Serial.println("temp is 20"); } if (m<=3400) { Serial.println("motor low "); } } void loop() { // put your main code here, to run repeatedly: } |
שאלה 3
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 |
void setup() { // put your setup code here, to run once: int t=28; int h =78; int m=3400; int p=5; Serial.begin(9600); Serial.println("start"); if (t>28) { Serial.println("temp is low"); } if (m==3400) { Serial.println("motor low "); } } void loop() { // put your main code here, to run repeatedly: } |
שאלה 4
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 |
void setup() { // put your setup code here, to run once: int t=-10; int h =78; int m=3500; int p=5; Serial.begin(9600); Serial.println("start"); if (t>28) { Serial.println("temp is high"); } else { Serial.println("temp is low"); } if (m>3400) { Serial.println("motor low "); } else { Serial.println("motor high "); } } void loop() { // put your main code here, to run repeatedly: } |
שאלה 5
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 |
void setup() { // put your setup code here, to run once: int t=29; int h =78; int m=30000; int p=5; Serial.begin(9600); Serial.println("start"); if (t>28) { Serial.println("temp is high"); } else { Serial.println("temp is low"); } if (m>3400) { Serial.println("motor low "); } else { Serial.println("motor high "); } } void loop() { // put your main code here, to run repeatedly: } |
שאלה 6
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 |
void setup() { // put your setup code here, to run once: int t=29; int h =78; int m=30000; int p=5; Serial.begin(9600); Serial.println("start"); if (t>28) { Serial.println("temp is high"); } else { Serial.println("temp is low"); } if (m>3400) { Serial.println("motor low "); } else { Serial.println("motor high "); } if (p>=4) { Serial.println("pressure is high"); } else { Serial.println("pressure is low"); } } void loop() { // put your main code here, to run repeatedly: } |
שאלה 7
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 |
void setup() { // put your setup code here, to run once: int t=-3; int h =78; int m=38000; int p=1; Serial.begin(9600); Serial.println("start"); if (t>28) { Serial.println("temp is high"); } else { Serial.println("temp is low"); } if (m>3400) { Serial.println("motor low "); } else { Serial.println("motor high "); } if (p>=4) { Serial.println("pressure is high"); } else { Serial.println("pressure is low"); } } void loop() { // put your main code here, to run repeatedly: } |
שאלה 8
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 |
void setup() { // put your setup code here, to run once: int t=-3; int h =78; int m=38000; int p=1; Serial.begin(9600); Serial.println("start"); if ( (t>28) || (p==1) ) { Serial.println("case 1"); } if ( (t!=28) || (p==1) ) // != שונה { Serial.println("case 2"); if ( (t<28) || (p>1) ) // != שונה { Serial.println("case 3"); } } } void loop() { // put your main code here, to run repeatedly: } |
שאלה 9
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 |
void setup() { // put your setup code here, to run once: int t=29; int h =78; int m=38000; int p=1; Serial.begin(9600); Serial.println("start"); if ( (t>28) || (p==1) ) { Serial.println("case 1"); } if ( (t!=28) || (p==1) ) // != שונה { Serial.println("case 2"); if ( (t<28) || (p>1) ) // != שונה { Serial.println("case 3"); } } } void loop() { // put your main code here, to run repeatedly: } |
שאלה 10
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 |
void setup() { // put your setup code here, to run once: int t=27; int h =78; int m=38000; int p=2; Serial.begin(9600); Serial.println("start"); if ( (t>28) || (p==1) ) { Serial.println("case 1"); } if ( (t!=28) || (p==1) ) // != שונה { Serial.println("case 2"); if ( (t<28) || (p>1) ) // != שונה { Serial.println("case 3"); } } } void loop() { // put your main code here, to run repeatedly: } |