need HELP with Sharp ir sensor and writing code

Hey y'all I'm reviewing all of the message boards online but still I'm totally clueless and don't even really know how to begin this whole process of writing the code for this project:

Using the Sharp ir sensor I would like to gradually increase the pull of an electromagnet as an object moves closer to the sensor. can anyone help me begin this process??

i know its a lot to ask for help from scratch but none of this is getting through to me.

I'm guessing I will need to use the if() statement to say if an object is 80 cm from the sensor, electromagnet is at 0lb pull and as the object moves closer, the electromagnets pull will increase respectively.

I'm almost sure of the hardware setup as far as the arduino, sharp, electromagnet, tip 120, resistors and power source are concerned ... I just need help understanding the syntax of the code.

thanks so much for any help you can give.

If you know how to do it with if statements then do it that way. You could use nested if statements with 'else if'