The command IF - ELSE Create Arduino

       Basically IF-ELSE is a development of the IF. ELSE means the conditions that are not in accordance with the conditions in the IF. In other words, ELSE means "if not". Consider the following two statements:

Main;
  If (Now == at 10 o'clock){

     eat;
 }

 If (now == at 10 o'clock){
       Eat;
 }IF else{
      Main;
 }


     In rows 1 to 5, and Main will continue to be executed. If the current is equal to 10 hours, it is done while Spot Main. So the two activities or statements to be executed.

Unlike the rows 8 to 12, if 10 hours Spot, if not at 10, Main. That's IF-ELSE logic.

Here is a Sketch 2.2 is a modified version of Sketch 2.1 with the addition and removal ELSE reduction process:
// Free Tutorial IOISALMAN
// www.IOISALMAN.com 

    // Pin 8 For LED
    const int pinLED = 8;

    void setup() {
        // pin LED as output
       pinMode(pinLED, OUTPUT);
   }

   // the start time delay 1000 | 1 Second
   int timeDelay = 1000;

   void loop() {

       /* if the time delay is worth less equal to 0
           then the LED will stay there for 3 second and
           then the value is reset to 1000 timedelay
        */
       if(timeDelay <= 100){
         delay(3000);
         timeDelay = 1000;
       }else{
         // timeDelay value minus 100 if the time delay > 100
         timeDelay = timeDelay - 100;
       }

       //Turning on and off the LEDs over time Delay
       digitalWrite(pinLED, HIGH);
       delay(timeDelay);
       digitalWrite(pinLED, LOW);
       delay(timeDelay);
   }
        In Sketch above, if timeDelay worth less equal to 100, then the LED will be still for 3 seconds and then the value will timeDelay reset to 1000, otherwise it will be a reduction in the timeDelay many as 100. Note, peroses reset and reductions never performed together. Please try and check the results!


After speaking about the IF and IF-ELSE, we will mebahas of While. While one model looping with certain characteristics. For more details, please go to the following discussion.

Subscribe to receive free email updates:

0 Response to "The command IF - ELSE Create Arduino"

Post a Comment