Re: HELP with some basic (I think) electronics
It should work but be careful to keep the wiring short, especially the one to GND on the Arduino.
It works like this:
The Arduino itself cannot provide enough switching power to drive the relay so it uses the transistor as a current booster. Think of the transistor as a simple on/off switch, when off it doesn't conduct so it looks like a switch in the 'off' position. When conducting it almost (not 100% efficient unfortunately) shorts out the middle and right pins (called 'collector' and 'emitter' pins respectively) so it looks like a switch in the 'on' position. Whether it conducts or not is decided by current flowing into the left pin which is called the 'base' connection. The Arduino either provides that current to turn the transistor switch on, or is doesn't provide it to turn the transistor off. The important point is the transistor itself needs very little current to operate it while still being able to switch quite a large current, easily enough to operate the relay.
The diode across the relay coil is important. I'm over simplifying things but think of a diode as a device that only conducts current in one direction. It is wired across the relay coil in a way that does NOT conduct during relay operation. This may seem pointless, it just sits there doing nothing but there is a good reason for it being there. A relay coil is basically lots of turns of wire around an iron core to make an electro-magnet. When current flows it creates a magnetic field that pulls the switch mechanism inside the relay and makes the contacts open or close but when the current is turned off, that magnetic field collapses rapidly and gets converted back to a voltage across the coil connections. The polarity of the voltage is the opposite of the voltage that created the field and the diode sees it in the direction it wants to conduct in. As it conducts, it protects the transistor from excessive voltage.
I would offer a word of caution: it will work just fine if your Arduino is powered from 5V but if you have one that runs on 3.3V you might have to drop the resistor value or else the transistor may not fully switch on. [for the tech minded - it's a Darlington type with Vbe of around 2.5V]
Brian.