Hey, this looks very similar to my question here, which was about driving a similar relay board with the same relay on it.
I used a 2N2222 transistor with a 2.2k resistor connected to its base pin. This is sufficient to drive either the relay on its own, or the input pin on this board, from 3.3V.
Put the other end of the resistor on a Spark Core digital pin, and connect the transistor’s emitter pin to ground.
You’ll have one pin left on the transistor, the collector. When Spark Core digital pin is on, this collector pin will pull to ground.
If you just care about the module, connect “IN” to the collector and you’re done. The module itself can then be connected to the Spark Core’s Vin pin (which will be the required 5V if you’re using USB power), with the third connection to Gnd.
If you want to do away with the module altogether and use raw components, the connections are one side of the coil to Vin (5V) and the other side to the transistor’s collector pin. You’ll also need a flyback diode in this arrangement (I had a 1N4004 handy) which goes across the two coil pins, with its bar end on the one that goes to Vin.
With either arrangement, you don’t need to change your code, the pin can be used as OUTPUT and when you write a 1, that means “on.”
Note, you do need the relay itself (or the module if you’re using that) connected to 5V as I described — the coils in this particular model do not fire reliably at 3.3V.
…Your optoisolator should be fine to sink the current on IN with the module (the onboard PNP transistors base current), but I had trouble finding one that could sink the coil current when moving to raw components.
Here’s the datasheet for that relay: https://www.ghielectronics.com/downloads/man/20084141716341001RelayX1.pdf