Relay

A relay can be used to switch higher power devices such as motors and solenoids. If desired, the relay can be powered by a separate power supply, so, for instance, 12V solenoids can be controlled by the microcontroller.

Related Commands:

Print Page

Share

Schematic

PCB

Activate a Relay

The following program will activate a FET or Darlington transistor connected to output B.1, which in turn will activate the relay, for a second every five seconds.

Code Example:
main: 	high B.1 	; Switch on output B.1 
	pause 1000 	; Wait 1 second 
	low B.1 	; Switch off output B.1 
	pause 5000 	; Wait 5 seconds 
	goto main 	; Loop back to start
Copy Code Submit an Example

Create Module

Bill of Materials

DescriptionCodeQty
Miniature 6V Relay SPDT REL001 1 Buy Now
BCX38C Darlington driver transistor TRT002 1 Buy Now
1k resistor (pack 100) RES1K 1 Buy Now
1N4001 diode RES041 1 Buy Now

Simulation

No Image Selected

Submit Your Own Code!

You must be logged in to submit code examples. Login now.

Comments

  • Login to leave a comment.