Stap 9: Programmeren (Arduino)
VOID Setup {}
Serial.begin(9600);
pinMode(4,OUTPUT);
pinMode(8,OUTPUT);
}
void loop {}
digitalWrite(4,HIGH);
int d=analogRead(A5);
digitalWrite(4,LOW);
digitalWrite(8,HIGH);
int r=analogRead(A0);
digitalWrite(8,LOW);
int minimale = 400;
int. maximum = 800;
Serial.println(d);
Serial.println(r);
foreward tilt
if(d>maximum) {}
Serial.println('0');
}
else {}
Serial.println('1');
}
delay(12.5);
naar achteren kantelen
if(d<minimum) {}
Serial.println('2');
}
else {}
Serial.println('3');
}
delay(12.5);
linker tilt
if(r<minimum) {}
Serial.println('4');
}
else {}
Serial.println('5');
}
delay(12.5);
juiste tilt
if(r>maximum) {}
Serial.println('6');
}
else {}
Serial.println('7');
}
delay(12.5);
}