Uploading the relay test sketch to the Arduino

The following sketch will turn the relay on and off every 5 seconds:

/* Gardening system
* Lets water our plants on time
* Relay test
*/

#define RELAY_OUTPUT 9

int i = 0;

void setup() {
// put your setup code here, to run once:
pinMode(RELAY_OUTPUT, OUTPUT); // Set the pin to digital output mode
}

void loop() {
// put your main code here, to run repeatedly:
if(i == 0) {
i = 1;
digitalWrite(RELAY_OUTPUT,HIGH);
} else {
i = 0;
digitalWrite(RELAY_OUTPUT,LOW);
}

delay(5000);
}

Upload this sketch to the Arduino Pro Mini using the FTDI cable with the Arduino IDE and once the sketch is uploaded, use a multimeter to check that the relay connects the circuit every 5 seconds.

Ensure that the pump power is switched off before uploading this sketch or you may risk damaging your pump without water when the relay switches the pump on every 5 seconds.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.19.29.89