Page 36 - RoboGenius Pro C7
P. 36

STEP - 9   Connect the Negative Terminal of the Water Pump to GND on the Arduino (through
                               a resistor).
























                  Block based programming:

                   STEP - 10   Click the Code button to open the code editor.


                    STEP - 11   Click on the EDIT MODE dropdown button and select Blocks option.

                   STEP - 12   Click on the Create variable button in the Variables section and name it
                               soil_moisture.

                   STEP - 13   Drag and place the set soil_moisture to block from the Variables section into the
                               editor window.

                   STEP - 14   Drag and place the read analog  pin block from the Input section inside the set
                               soil_moisture to block and set it to pin A0.

                   STEP - 15   Drag and place the print to serial monitor block from the Output section and place
                               soil_moisture inside it to print the sensor’s value to the serial monitor.

                   STEP - 16   Drag and place the if then else block from the Control section. Place the comparison
                               block from the Math section and set it to <. Compare soil_moisture with 100.

                   STEP - 17   Inside the if (soil_moisture < 100) block, drag and place from the Output section:

                                   set pin 8 to HIGH (to turn ON the motor and water the plant).

                                   set pin 7 to HIGH (to turn ON the Red LED, indicating dry soil).


                                   set pin 6 to LOW (to turn OFF the Green LED).

                   STEP - 18   Inside the else block, drag and place from the Output section:

                                   set pin 8 to LOW (to turn OFF the motor).
                                   set pin 7 to LOW (to turn OFF the Red LED).

                                   set pin 6 to HIGH (to turn ON the Green LED, indicating wet soil).


                                 RoboGenius Pro - VII
                 34
   31   32   33   34   35   36   37   38   39   40   41