A relay is a simple electromechanical switch made up of an electromagnet and a set of contacts. Relays are quite common in home appliances where there is an electronic control turning on something like a motor or a light. Relays are amazingly simple devices. There are four parts in every relay:
- Electromagnet
- Armature that can be attracted by the electromagnet
- Spring
- Set of electrical contacts
It is therefore connected to output pins of the microcontroller and used to turn on/off high-power devices such as motors, transformers, heaters, bulbs, etc. When a current flows through the coil, the relay is operated by an electromagnet to open or close one or many sets of contacts.
Circuit Setup |
DEFINE OSC 20 ' using 20MHz clock oscillator
@ device hs_osc
relay VAR PORTD.3 'declare ports
sw1 VAR PORTA.4
TRISA=1
TRISD=0
loop:
If (sw1=1) Then
High relay
Pause 1000
Else
Low relay
Pause 1000
End If
GoTo loop
End
No comments:
Post a Comment