![]() In addition to these basic components, some relays may also include additional features, such as LED indicators, protection diodes, snubber circuits, or other components to enhance their performance and reliability. The coil is connected to a control circuit, while the contacts are connected to the load. Terminals: The terminals provide a means of connecting the relay to external circuits. Frame: The frame provides mechanical support for the relay components and protects the relay from external damage.ĥ. It opens or closes the contacts, depending on the state of the coil.Ĥ. Armature: The armature is a movable component that is attracted by the magnetic field generated by the coil. When the coil is energized, the magnetic field attracts a movable armature, which opens or closes the contacts.ģ. Contacts: The contacts are the switching elements of the relay and can be normally open (NO) or normally closed (NC). Coil: The coil generates a magnetic field when an electrical current is passed through it, which is used to open or close the switch contacts.Ģ. The construction of a single-channel relay typically consists of the following components:ġ. Remember to check the annotations on the PCB or the datasheet before making the connections Single Channel Relay Module Parts NOTE: - In a few generic versions of the relays, the pin sequence could be different. NO is normally open unless you activate the relay which then connects it to the COM terminal NC - terminal is connected to the COM terminal by default unless you activate the relay which breaks the connection IN - This pin is also called the control pin because it is used to control the output of the relay.ĬOM - is connected to the device you intend to connect. VCC - this pin provides power to the module In this blog, we will explore how a relay works, how to interface a single-channel relay with an Arduino Uno, and demonstrate a simple example of how to use the 5v relay module to control a lamp. By using an Arduino Uno and a single-channel relay module, you can control high-voltage or high-power devices, such as lights, motors, and appliances, from your computer or mobile device. The entire circuit is powered at 5V (use a 5V Arduino board).A single-channel relay is an electronic switch that can be controlled by a low-power electrical signal, such as the output from an Arduino microcontroller. You must pay attention to mains voltages that can be controlled by the relay. * * Arduino powered light/dark activated switch * Copyright (C) 2017 One Transistor * Licensed under GNU General Public License v3 */ #include // Pins for photoresistor, relay and encoder const int sensorPin = A3 // A3 const int relayPin = 4 // D4 const int encoderA = 2 // D2 const int encoderB = 5 // D5 const int modeSwitchPin = 3 // D3 // Change that will be considered significant in read value const int valueThreshold = 20 const int rotaryEncoderStep = 10 int sensorValue = 0 volatile unsigned int sensorThreshold = 512 volatile byte modeSwitch = 0 // 0 = always off, 1 = always on, 2 and 3 = dark or light activated switch void setup ( ) I recommend using the sketch from GitHub because this is more often updated. The photoresistor should look to outdoor lighting, while the relay will turn on indoor lights. Otherwise the switch will run an endless loop of turning on and off the light. If you will build this to turn on the light in a room, make sure the light you turn on does not get to the photoresistor. If the value is rather constant, the relay is activated or not on pin D4. The analog value from photoresistor is sampled on pin A3 twice in 0.5 seconds. The rotary encoder and its switch are connected to D2 respectively D3 pins and use interrupts to change program variables. I designed this using a Nano board, but if you want a standalone device, there is no need for USB port, so you should use the smaller Pro Mini board. The threshold and mode of operation are stored inside MCU EEPROM and these variables are restored when powering up the device.Īrduino light/dark switch with rotary encoder The rotary encoder allows changing the switching threshold (rotation) and cycling through the four modes of operation: always off, always on, light activated relay and dark activated relay. Depending on this value and the user configurable threshold and mode of operation, the relay is activated or not by a digital output of the MCU. ![]() The output voltage from a divider formed by a photoresistor and a fixed resistor is read by an analog input pin of the microcontroller (MCU).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |