Controlling 220v using arduino relay board
Sumber : http://browse-tutorials.com/tutorial/controlling-220v-using-arduino-relay-board
This guide shows how to control 220 / 230 V using relay board. This is
very general relay board, you can find it in ebay, amazon and even in
some local stores. This is a general board 5v relay that can control
250V AC, 125V AC, 30V DC or 28V DC. I live in Europe so my household
electricity runs on 230V which fits nicely in the 250V limit. The board
relay says it is up to 10A, but I wouldn't use that much on it. In this
example I am trying to switch a lamp or if to be more exact a household
socket that runs on 230V and you can put any item you have in your home
to work on it. My board has 2 relays, but in this example I am going to
use just 1 relay. You can modify the code on what ever amount of relays
your controller can bare. Relay boards are available with 1, 2, 4, 8 and
even 16 relays. The amount of relays you control is not restricted to
the amount of Arduino pins. You have use shift registers to control more
relays if Arduino doesn't have enough pins for your setup.
Controlling 220v using Arduino relay board
Source code viewer
#define RELAY_ON 0 #define RELAY_OFF 1 #define RELAY_1 2 void setup() { // Set pin as output. pinMode(RELAY_1, OUTPUT); // Initialize relay one as off so that on reset it would be off by default digitalWrite(RELAY_1, RELAY_OFF); }
void loop() { // Turn on and wait 3 seconds. digitalWrite(RELAY_1, RELAY_ON; delay(3000); // Turn off and wait 3 seconds. digitalWrite(RELAY_1, RELAY_OFF); delay(3000); }
Komentar
Posting Komentar