POTENTIOMETER AS ANGLE SENSOR
Tasks:
- Add the potentiometer to the shaft of barrier gate. You can follow the instrucions in the video.
{#fig:pot_sen}
- Test the potentiometer values with next program:
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println(analogRead(A3));
delay(100);
}
- Change the functions for lifting and lowering the barrier gate to use potenciometer readings instead of switch and time controlled movement.
[+] void setup() {
[+] void loop() {
[+] void manualGateControll(){
[+] void stopTheGate(){
[-] void moveGateUp() {
int gate_orientation = analogRead(POTENTIOMETER_PIN);
while (gate_orientation < 750){
digitalWrite(MOTOR_PIN_1, HIGH);
digitalWrite(MOTOR_PIN_2, LOW);
gate_orientation = analogRead(POTENTIOMETER_PIN);
}
stopTheGate();
}
[+] void moveGateDown() {
- Advanced: Calculate the angle of barrier gate from the analog readings of potenciometer.
Questions:
- What is the value of the angle sensor when the barrier gate is in the upper orientation...
- ... and in lower orientation.
Summary:
<++>
<++>
Issues:
<++>
<++>