Heavy loads: Communication
The next scheme is a bit of a test. What has become known about the use of transistors in exercise 3 to control the relay is combined. Relay - electrically controlled mechanical toggle switch. Inside a small plastic box is an electromagnet, which, when energized, makes the switch move (often with a very pleasant sound click).
You can buy relays that range in size from a quarter of the size of what's in the kit to ones as large as a refrigerator, each capable of switching a certain amount of current. They are very fun because they have one of the elements of physics.
While all the silicon we've played with so far is funny, sometimes you just want to plug in a hundred switches to control something lovely. Repeaters give you the opportunity to dream about it and then control it with your Arduino. We are now using today's technology to bring the past to life.
(Diode 1N4001 acts as a flyback diode, in other words, it is here to prevent a return to zero or the starting point after a sudden current influx when the current suddenly decreases or is suppressed).
COMPONENTS
- Diode (1N4001).
- Transistor P2N2222AG (TO92).
- Relay (SPDT). LED 5mm
- x 2 (e.g. yellow and red).
- 10 kOhm resistance (brown-black-orange).
- Resistance 330 ohms (orange-orange-brown) x 2.
- Connecting wire.
CIRCUIT DIAGRAM
CIRCUIT ASSEMBLY
CODE
You can find this code in CIRC-11-code-relay.js
var j5 = require("johnny-five");
var myBoard = new j5.Board();
myBoard.on("ready", function() {
var val = 0;
var relay = new j5.Relay(2);
this.loop(1000, function() {
if (val ^= 1) {
relay.on();
} else {
relay.on();
}
});
});
EMERGENCY REPAIR
No sound click
The transistor or coil part on the circuit does not work well. Make sure the transistor is inserted correctly .
Still not working
The relay turned on is for welding, not for use on a prototyping plate. Then you need to press well to make sure it works (and can come off on occasion).
CODE EXTENSION
Look at the Back-EMF trash
Replace the diode with an LED diode. You'll see her flash every time she "despises" the coil's voltage peak when it turns off.
Engine control
In exercise 3, we controlled the motor with a transistor. However, if you want to control a larger engine, then a relay is a good option. To do this, simply remove the red LED and connect the motor instead (consider bypassing the 330 ohm resistance).