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 55 56 57 58 59 60
|
/**definitions des capteurs**/
#define chat_int (0x01)
#define chat_ext (0x02)
#define battant_ferm (0x04)
#define battant_ouv_ext (0x08)
#define battant_ouv_int (0x10)
/**Constantes de commandes moteur**/
#define ouv_int (0xFE)
#define ouv_ext (0xFD)
#define ferm_int (0xFB)
#define ferm_ext (0xF7)
#define arreter_moteur (0xFF)
/**Inclusions des fichiers **/
#include <io8535v.h>
#include <macros.h>
/**Déclarations des Fonctions**/
void Initports ();
/**Programme Principal**/
void main()
{
Initports(); /*Initialisation des ports*/
while(1)
{
if ((chat_ext & PINA)== chat_ext) /*chat détecté coté extérieur ?*/
{
do PORTB = ouv_int; /*ouvrir le battant coté intérieur*/
while ((battant_ouv_int & PINA)!= battant_ouv_int); /*battant ouvert coté intérieur ?*/
do PORTB = arreter_moteur; /*arrêter moteur*/
while (((chat_ext | chat_int) & PINA) != 0x00); /*chat détecté ?*/
do
PORTB = ferm_int; /*fermer le battant coté intérieur*/
while ((battant_ferm & PINA)!= battant_ferm); /*battant fermé ?*/
PORTB = arreter_moteur; /*arrêter moteur*/
}
else if (( chat_int & PINA) == chat_int) /*chat détecté coté intérieur ?*/
{
do PORTB = ouv_ext; /*ouvrir le battant coté extérieur*/
while ((battant_ouv_ext & PINA)!= battant_ouv_ext); /*battant ouvert coté extérieur ?*/
do PORTB = arreter_moteur; /*arrêter moteur*/
while (((chat_ext | chat_int) & PINA) != 0x00); /*chat détecté ?*/
do PORTB = ferm_ext; /*fermer le battant coté intérieur*/
while ((battant_ferm & PINA)!= battant_ferm); /*battant fermé*/
PORTB = arreter_moteur; /*arrêter moteur*/
}
else PORTB = arreter_moteur; /*arrêter moteur*/
}
}
/**Fonction initialiser ports**/
void Initports ()
{
DDRA=0x00; /*PORT A en entrée*/
DDRB=0xFF; /*port B en Sortie*/
PORTB=arreter_moteur; /*arrêter moteur*/
} |
Partager