Using a Relay and a sensor at the same time

Hello,
I am need to Arduino and need help. Is it possible to use both an accelerometer, ADXL345, as well as a relay and if so how would I do that and what would the code look like? What is the best relay to use? Also, do I need a bread board or can I connect everything I need to the Arduino board itself?
Any advice would be greatly appreciated!

Yes, it's quite possible to do many things at the same time with an Arduino.
Start here:
Overview | Multi-tasking the Arduino - Part 1 | Adafruit Learning System

To do what?

You should not power the relay with the Arduino so you will likely need more than just the Arduino.
There are many ways to connect things. It is probably best if you provide a much more detailed description of your project.

Yes

Well it would consist of code to read the ADXL345 that comes with the library for that part, and a digital write to turn the relay on and off. There is no need to use the multi-tasking techniques with something so simple.

I assume you want to turn the relay on or off depending on the readings you get from the ADXL345. You do that with an "if" statement.

There is no such thing as a "BEST" relay, but if we knew more we could advise against getting a rubbish one. Your problems are more with the hardware than the software. Especially what you are switching on with the relay.

Thank you for your feedback. You were correct in your assumption that "I assume you want to turn the relay on or off depending on the readings you get from the ADXL345. You do that with an "if" statement." I wasn't really sure where to start at all for incorporating the readings from the accelerometer back into the code, so I suppose I have not tried anything yet. But I have found the library to read the measurements from the accelerometer. But after that I am not sure what the next step would be. Thank you very much for your help so far.

There are hundreds of different ways how this can be realised.

Nobody here wants to write down a 100 pages tutorial to cover all aspects that might be a question to you.
Simply post your code just as is and ask a specific question.
Even if you post the testcode that comes with the library this is much better than just the generalised question

describe in more detail what you have done so far and ask a specific question

In this way you create a tutorial that is 100% matched to your project.

best regards Stefan

It would be to take the reading and use an “if” statement to compare the reading you got with the reading you need to reach before you want to turn your relay on. Look up how an if statement works in the reference page under the Help menu in the IDE.

But you have to first know when you want the relay to turn on and off. We can’t help on that because only you know what the project is supposed to do. That is because you haven’t said what you want to do to us. So we can only speak in general terms unless we know more about your project.