BARRIER GATE CONSTRUCTION
Tasks:
- Construct the barrier gate according to video instructions.
{#fig:gate_const}
- Connect the motor to digital outputs D7 and D6,
- declare meaningful constants for output pins,
- write a function
setIOpins()
for settig output pins and - include it in setup() function.
- Write 3 time controlled functions for essential control of the barrier gate :
moveGateUp();
moveGateDown();
stopTheGate();
and test this actions in setup() function.
- Put this action of lifting and lowering the gate in For-loop and repeat it several times (e.g. 15 times).
Some sample code can be found in next example:
const int MOTOR_PIN_1 = 7;
const int MOTOR_PIN_2 = 6;
[-] void setup() {
pinMode(MOTOR_PIN_1, OUTPUT); //declaration of I/O pins
pinMode(MOTOR_PIN_2, OUTPUT);
moveGateUp(); // Lift the barrier.
delay(3000); // Wait a bit...
moveGateDown(); // Lower the barrier.
}
[+] void loop() {
[+] void stopTheGate(){
[-] void moveGateUp() {
digitalWrite(MOTOR_PIN_1, HIGH);
digitalWrite(MOTOR_PIN_2, LOW);
delay(1000);
stopTheGate();
}
[+] void moveGateDown() {
Questions:
- What is the time for raising and lowering the barrier? Compare it to your colleague’s value.
- What is the disadvantage of time controlled loop?
Summary
<++>
<++>
Issues:
<++>
<++>