It seem s you want to control something. Why not try
If ( digitalRead ( sensorval) == HIGH )
{
digitalWrite ( motorpin , LOW );
}
Else
{
digitalWrite ( motorpin, HIGH );
Never the less, NIck Gammon is expert; post your code.
BTW, take some advice as I was given: go to TOOLS and select AUTOFORMAT, place your parenthesis at the beginning of the next line,
Another thing that happens sometimes (but not here) is that the "=" (which assigns a value) is used instead of "==" (which tests for a condition). But you got that.
As a total aside - here is a cute while loop little exercise i just bumped into.
button is a user defined function and BUTTON1 is an integer. This while loop cycle through each time and continues to cycle by testing the or (||) until button() returns 0 for all three.