Arduino Program
Arduino Program
1. void setup()
2. {
3. Serial.begin(9600);
4. }
5. void loop() {
6. int a = 5; // initialization of values to the variables a and b
7. int b = 4;
8. int c;
9. c = myAddfunction(a, b); // c will now contains the value 9
10. Serial.println(c); // to print the resulted value
11. delay(1000); // time delay of 1 second or 1000 milliseconds
12. }
13. int myAddfunction(int i, int j)
14. {
15. int sum;
16. sum = i + j;
17. return sum;
18. }
2)Local Variables
1. void setup()
2. {
3. Serial.begin(9600);
4. }
5. void loop()
6. {
7. int x = 3;
8. int b = 4;
9. int sum = 0;
10. sum = x + b;
11. Serial.println(sum);
12. }
4)Fined Large no
1. int a = 6; // initiaization of values to variables a and b
2. int b = 4;
3. void setup()
4. {
5. Serial.begin(9600);
6. }
7. void loop()
8. {
9. if (a > b )
10. {
11. Serial.println( " a is greater than b ");
12. }
13. if (b > a )
14. {
15. Serial.println( " b is greater than a ");
16. }
17. }
5)Print 1 to 10 no
1. int i;
2. void setup ( )
3. {
4. Serial.begin(9600);
5. for ( i = 1 ; i < =10 ; i ++ )
6. {
7. Serial.println( i);
8. }
9. }
10. void loop ( ) {
11. }