I am just starting out using relays, I do not have one yet. But, it will need to handle 12 V and .17 amps. I am trying to write the code for this before I have the sensor. My goal is to switch something on and off according to the readings of an ADXL345 accelerometer. Can anyone help me write the code for this/ offer any suggestions to help me get started.
You can use an LED (with the usual current-limiting resistor).
If you have a "bare" relay you'll need a relay driver circuit because the Arduino can't put-out enough current to directly-drive a relay coil. Or there are relay boards with built-in drivers.
What will the relay be switching? Which Arduino are you using?
A relay is just a switch. A switch that you turn on and off by sending it a digital HIGH or LOW, basically the same way you turn an LED on or off.
The example Blink switch shows the basics of this.
You are probably best to start with a relay module like this
These have some additional electronic components built in that protect the signal sending device from electrical nasties that can damage it.
I guess this:
... means you will compare the accelerometer reading to some threshold and operate the relay accordingly?
If you don't have the accelerometer yet, you could use random to generate some pretend values and test your thinking while you wait for the sensor to arrive.