Problème codage carte arduino pour portail automatique coulissant
Bonjour a tous,
Suite a un codage avec les pieds, je sollicite votre aide pour m'aider a résoudre certain problème dans le code.
Mon projet est de contrôler grace au System Arduino un portail automatique avec une télécommande infrarouge.
Mon systeme prend en compte des fin de course appelé fdcO et fdcF, des photocellules appelés photo, un moteur de portail et une lampe tout cela manœuvré par des relais.
Si vous avez des liens ou de la documentation ou des cours et tutoriels Arduino sur des systeme du même genre ou autre, exemple radio commander je suis preneur.
Par avance , merci pour votre aide
le code ci joint:
Code:
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
| #include <IRremote.h>
int moteurO = 7;
int moteurF = 10;
int fdcO = 11;
int fdcF = 12;
int lampe = 13;
int photo = 8;
int receptionIr = 2; //La sortie du signal du récepteur Infrarouge (patte de gauche pour ce modéle) est connecté a la broche 2
IRrecv irrecv(receptionIr); //Initialisation de la récepteion du réceptur Infrarouge
decode_results resultat; //Stock le code reçus dans resultat
void setup()
{
irrecv.enableIRIn(); //Activation de la réception
pinMode(moteurO,OUTPUT); //Declaration de relais en sortie
irrecv.enableIRIn(); //Activation de la réception
pinMode(moteurF,OUTPUT); //Declaration de relais en sortie
irrecv.enableIRIn(); //Activation de la réception
pinMode(lampe,OUTPUT); //Declaration de relais en sortie
irrecv.enableIRIn(); //Activation de la réception
pinMode(photo,OUTPUT); //Declaration de relais en sortie
irrecv.enableIRIn(); //Activation de la réception
pinMode(fdcO,OUTPUT); //Declaration de relais en sortie
irrecv.enableIRIn(); //Activation de la réception
pinMode(fdcF,OUTPUT); //Declaration de relais en sortie
}
void loop()
{
if (irrecv.decode(&resultat)) //Si il y a reception d'un code qui est stocké dans resulat
{
if (resultat.value==0xFF30CF) //Si le code reçus vaut le code du bouton que vous avez programmés (ici c'est 0xFF30CF qui est égale au bouton 1 de ma télécommande
{
digitalWrite(moteurO,HIGH); // déclaration si moteur ouverture actif moteur fermeture inactif
moteurO= 1;
digitalWrite(moteurF,LOW);
moteurF = 0;
digitalWrite(moteurF,HIGH); // déclaration si moteur fermeture actif moteur ouverture inactif
moteurF = 1;
digitalWrite(moteurO,LOW);
moteurO = 0;
}
{
do // faire...
{
digitalWrite(moteurO,HIGH);
moteurO=1;
} while (fdcO==1);
{
if (moteurO==1)
{
digitalWrite(fdcO,LOW);
fdcO = 0;
delay(15);
}
do // faire...
{
digitalWrite(moteurF,HIGH);
moteurF=1;
} while (photo==1);
{
if (resultat.value==0xFF18E7) //Si le code reçus vaut le code du bouton que vous avez programmés (ici c'est 0xFF18E7 qui est égale au bouton 2 de ma télécommande)
{
do // faire...
{
digitalWrite(moteurF,HIGH);
moteurF=1;
} while (fdcF==1);
}
}
}
}
}//Fin du if
irrecv.resume();
} |