-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathporte.cpp
54 lines (45 loc) · 927 Bytes
/
porte.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
Fonctions gérant l'ouverture et la fermeture du robot principal
Auteurs : Jeremy et Aurélien
Derniere modif : 22/07/2012
*/
#include <arduino.h> // pour la fonction micros()
#include <Servo.h>
#include "porte.h"
static Servo servoLeft;
static Servo servoRight;
static int pos = 0;
static unsigned long tpsPrec = 0;
void ouvrirPorte()//la fonction qui ouvre les portes.
{
pos = POS_FIN;
}
void fermerPorte()//la fonction qui ferme les portes.
{
pos = POS_INIT;
}
// a ajouter a l'initialisation
void initialisation()
{
// ajout des pins au programme
servoLeft.attach(SERVOMOTOR_LEFT);
servoRight.attach(SERVOMOTOR_RIGHT);
}
// a ajouter a l'update
void update()
{
tpsPrec = micros();
servoLeft.write(pos-120);
servoRight.write(180-pos+90);
}
bool fini()
{
if (micros() - tpsPrec < DELAI)
{
return false;
}
else
{
return true;
}
}