Project Five – Relay Control

Introduction

In this project we will demonstrate using the relay . Using the button , button one will turn the relay on, and button two turns it off. As noted earlier, the relay can handle a peak voltage capability of 250V at 10 amps.
Even though you may be capable with low voltages and microelectronics, if you are not qualified for working with mains voltages, consult a licensed electrician to complete the work.
Connect the Twin Button to the D1/D2 input jack.
The Twin Button Grove’s red button uses the D1 connector to send a signal to the Arduino’s D1 digital input, and the green button uses the D2 connector to send a signal to the Arduino’s D2 digital input.
Connect the Relay to the D6/D7 input jack.
The Arduino’s D6 pin sends a signal to the Relay on the D1 connector. The Relay Grove’s red light indicates whether the relay is on or off, and the relay makes a clicking sound when it switches.
Now upload the following Arduino sketch:
// Project Five - Relay Control // void setup() { pinMode(1, INPUT); pinMode(2, INPUT); pinMode(6, OUTPUT); } void loop() { if (digitalRead(1)==HIGH) { digitalWrite(6, HIGH); delay(100); } if (digitalRead(2)==HIGH) { digitalWrite(6, LOW); } }
When using this with an XBee Carrier, please be aware that you should set output 16 low to ensure that the mosfet on the XBee carrier provides enough power to reliably pull in the relay
The reason for the delay function after setting the relay high or low is to allow the sketch to pause – in doing so ignoring the buttons for one tenth of a second. This is more commonly known as ‘software de-bouncing”. Although doing so may not seem necessary in this particular example, doing so is a good habit to start with.

Help us make it better

Thank you for choosing Seeed. A couple of months ago we initiated a project to improve our documentation system. What you are looking at now is the first edition of the new documentation system. Comparing to the old one, here is the progresses that we made:
  • Replaced the old documentation system with a new one that was developed from Mkdocs, a more widely used and cooler tool to develop documentation system.
  • Integrated the documentation system with our official website, now you can go to Bazaar and other section like Forum and Community more conveniently.
  • Reviewed and rewrote documents for hundreds of products for the system’s first edition, and will continue migrate documents from old wiki to the new one.
An easy-to-use instruction is as important as the product itself. We are expecting this new system will improve your experience when using Seeed’s products. However since this is the first edition, there are still many things need to improve, if you have any suggestions or findings, you are most welcome to submit the amended version as our contributor or give us suggestions in the survey below, Please don’t forget to leave your email address so that we can reply.
Happy hacking