3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Properduino - When an Engineer Gardens - Part 1 - Le Propergator Watering System

Step 4Use your Relays!

Use your Relays!
«
  • relay active.jpg
  • relay pcb bottom.jpg
  • relay pcb top.jpg
  • 19022009062.jpg
build a circuit like this one using most of the parts from step one
Include the LED so you know when the relay should be on
Make sure the relay extension cord IS NOT PLUGGED IN!!!
Write up a program that turns the relay on for 2 seconds when the character "R" is received over Serial and when a button on pin 12 is pulled HIGH, the relay turns on.
Make sure you have a button on pin 12 or comment that bit out =]
for some reason it returns numbers when you press a key that ins't R. I think its the DEC I put after it =/
It should look like this:

//Relay controller for water pump
//LMC

int relay = 10;
int button = 12;
int thirteen = 13;
int val;

void setup (){
pinMode(thirteen, OUTPUT); //start of setup basic cmds
digitalWrite(thirteen, HIGH); //debug light
delay(500); //WAITZ!!!
pinMode(relay, OUTPUT);
Serial.begin(19200);
Serial.println('Bonjour. Press R to turn relay on for 2 seconds');
digitalWrite(thirteen, LOW); //End of setup cmds
delay(500); // end of setup cmds

}

void loop(){

if (Serial.available()) {

val = Serial.read();
if (val=='R'){
digitalWrite(thirteen, HIGH);
digitalWrite(relay, HIGH);
delay(2000);
digitalWrite(relay, LOW);
digitalWrite(thirteen, LOW);
} else {
Serial.print("You pressed:");
Serial.print(val, DEC);
Serial.println(". Press R for Relay, Any other key will do nothing");
}

}

if (digitalRead(button) == HIGH){
digitalWrite(thirteen, HIGH);
digitalWrite(relay, HIGH);
delay(2000);
digitalWrite(relay, LOW);
digitalWrite(thirteen, LOW);
}

delay(500);
}

Upload it to your board
Open your serial monitor
Send some R's

You should hear the relay clicking over and the LED should light up.
If not, youve put the transistor in wrong and you now need to redo it all =]
You can now see why I didn't put the transistors and all that in the box =]
Sorry the picture is a duplicate of the first step.

« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
4
Followers
1
Author:grahamslawson