for(headPos = 0; headPos <180; headPos += 1)
head.write(pos);
delay(10);
for(headPos = 180; headPos >= 1; headPos-=1)
{
head.write(headPos);
delay(10);
I'd say that you're probably missing some "}" braces in there.
Or they're misplaced, which is more likely if this code is compiling
void ReadSensor () {
for(headPos = 0; headPos <180; headPos += 1) {
head.write(pos);
delay(10);
// You may want to do stuff here
}
for(headPos = 180; headPos >= 1; headPos-=1) {
head.write(headPos);
delay(10);
value = analogRead(0);
Serial.println(value);
if (value > treshold) {
turn();
} else {
move();
}
}
}