This may be quite a simple question, but one that I myself cannot work out.I wish to use an LDR as a beam break detector and alarm, and to do this I need to compare one value against another. The code I have so far for this is as follows:

if ((differenceVariable^2) > 50) {For the record ^2 doesn't raise differenceVariable to the power of 2. ^ is a bitwise XOR. If you want to square a value, you need to use pow(): http://arduino.cc/en/Reference/Pow

Quote

(is there a sqrt function or similar for arduino?)

If you look at the Reference page (http://www.arduino.cc/en/Reference/HomePage), you will see a section on Math. One of the operators is sqrt().