Control a relay with the Arduino
Mit einem kleinen Steuerstrom größere Verbraucher schalten
You need this
1-channel relay module - 5 V, switches up to 250 V / 10 A
1,72 € *Item no. F23107168About the product — 1-channel relay module - 5 V, switches up to 250 V / 10 A
Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
11,12 € *Item no. F23107480About the product — Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
830-point Breadboard - solderless breadboard for Arduino
2,90 € *Item no. FUN-1010553About the product — 830-point Breadboard - solderless breadboard for Arduino
Breadboard Cables Male-to-Male - 40 Pieces, 20 cm
1,74 € *Item no. FUN-1010558About the product — Breadboard Cables Male-to-Male - 40 Pieces, 20 cm
LED 5 mm - 100 Pieces, 5 Colors, 2 V
1,97 € *Item no. F23107316About the product — LED 5 mm - 100 Pieces, 5 Colors, 2 V
Resistor Assortment 100 Pieces - 5 Values 100 Ω to 10 kΩ, 0.5 W
1,72 € *Item no. F23107216About the product — Resistor Assortment 100 Pieces - 5 Values 100 Ω to 10 kΩ, 0.5 W
All 6 parts together 21,17 € *Ready to ship immediately · Delivery time: 1-3 business days
* All prices include statutory VAT, plus shipping costs.
Choose a microcontroller
Pins, schematic, and sketch in the steps change with your selection. It remains saved.
How a relay works
Wire and program
int RELAIS = 7;
void setup()
{
pinMode(RELAIS, OUTPUT);
}
void loop()
{
delay(2000);
// Switch relay
digitalWrite(RELAIS, HIGH);
delay(2000);
digitalWrite(RELAIS, LOW);
}Download: sketch-for-the-arduino-uno.ino
Board in the Arduino IDEArduino Uno
You don’t need an additional board package for this. The UNO is included in the Arduino IDE by default.
int RELAIS = D1;
void setup()
{
pinMode(RELAIS, OUTPUT);
}
void loop()
{
delay(2000);
// Switch relay
digitalWrite(RELAIS, HIGH);
delay(2000);
digitalWrite(RELAIS, LOW);
}Download: sketch-for-the-wemos-d1-mini.ino
Board in the Arduino IDELOLIN(WEMOS) D1 R2 & mini
The ESP8266 board manager must be installed for this. Add it once via the Arduino IDE settings.
int RELAY = 19;
void setup()
{
pinMode(RELAY, OUTPUT);
}
void loop()
{
delay(2000);
// Switch relay
digitalWrite(RELAY, HIGH);
delay(2000);
digitalWrite(RELAY, LOW);
}Download: sketch-for-the-esp32-wroom.ino
Board in the Arduino IDEESP32 Dev Module
The ESP32 board manager must be installed for this. You add it once via the Arduino IDE settings.