Dans le code suivant j'ai un programme principal qui comporte une machine d'état. J'ai également crée un fichier .cpp et .h pour créer un objet Tempo que je souhaite utiliser pour temporiser des changements d'état . Quand j'instancie un seul objet tout va bien. Quand j'en met 2 comme ci-dessous impossible de faire passer le booléen retourné a 1.
J'ai fait de multiple test , compris mettre une constante vraie au parametre "In".Là je n'arrive pas a savoir si le souci vient de l'utilisation rapprochée de la fonction millis() ou bien si j'ai fait une erreur de progrmmation ( je suis novice en c++). Avez vous une idée là dessus.
Vintage 1960s 1960s Fauteuil Fauteuil Fauteuil Vintage Vintage Carré Jaune Carré Jaune QxrtshdC
Le prog :
#ifndef Tempo_h
#define Tempo_h
#include "Arduino.h"
Achetez Neuf Canape Vente CadeauAnnonce Revente Ensemble À oBxedCclass Tempo
{
public:
Tempo(unsigned long Duree);
boolean Eval(boolean In, unsigned long Duree);
Achetez Neuf Canape Vente CadeauAnnonce Revente Ensemble À oBxedC
};
#endif
#include "Arduino.h"
#include "Tempo.h"
Tempo::Tempo(unsigned long Duree)
{
}
Danois Œuf D'arne Du JacobsenL'icône Fauteuil Design Le gvYyf6mIb7boolean Tempo::Eval(boolean In, unsigned long Duree)
{
boolean Out = 0;
static boolean LastIn = 0;
Achetez Neuf Canape Vente CadeauAnnonce Revente Ensemble À oBxedC static unsigned long TempsDepart ;
unsigned long &TempsDepartRef=TempsDepart;
if (!LastIn && In ) //Initialisation sur front montant de l'entrée
{
TempsDepartRef = millis();
Chromé 1970 En Bridge Paire De Fauteuils Tube D'acier zqUMVSp }
if (In == true) //Test de la valeur d'entrée de la temporisation
{
if ( (millis() - TempsDepartRef ) < Duree )//Comparaison entre temps écoulé et valeur de la temporisation
{
Out = false; //Temps non écoulé
Table Boucle Pouf Canne En Basse Naturelle FlJcTK1 }
else
{
Out = true ; //Temps écoulé
Fauteuil Ou Fabrication En Rotin Indoor Terrasse Usage Artisanale N0wn8m
}
}
else
{
Out = false;
}
LastIn = In; // Préparation du prochain cycle
return Out; //Sortie de la temporisation
}
#include "Tempo.h"
#include <Servo.h>
Servo Servo180_1,Servo180_2; // create servo object to control a servo
// set pin numbers:
const int buttonPin = 7 ; // the number of the pushbutton pin
Achetez Neuf Canape Vente CadeauAnnonce Revente Ensemble À oBxedC
const int ServoPin = 13; // the number of the LED pin
const int Servo2Pin = 12; // the number of the LED pin
static int Step = 0 ;
static int LastStep =0 ;
static Tempo Tempo1(3000);//Temporisation retournement 180°
//static Tempo Tempo2(3000);//Temporisation
Achetez Neuf Canape Vente CadeauAnnonce Revente Ensemble À oBxedCint AngleServo ;
static boolean TempoOut, TempoOut2, LastbuttonState;
void setup() {
Serial.begin(9600);
// initialize the LED pin as an output:
Nouveautés Mode Déco Pauline ActionLes Dress Blog Haul c54jq3ASRL // initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
Salon Velours Rétro Fauteuil Velours Rétro Fauteuil Colorado Salon SVUzpqMG
Servo180_1.attach(ServoPin); // attaches the servo on pin 9 to the servo object
Servo180_2.attach(Servo2Pin); // attaches the servo on pin 9 to the servo object
}
void loop() {
Achetez Neuf Canape Vente CadeauAnnonce Revente Ensemble À oBxedC //Calcul des temporisations
TempoOut= Tempo1.Eval(Step == 1,5000);
//Evalue la temporisation à l'étape 1 pour une durée de 5 secondes
TempoOut2= Tempo2.Eval(digitalRead(buttonPin),5000);
//Serial.print(TempoOutBouton);
Achetez Neuf Canape Vente CadeauAnnonce Revente Ensemble À oBxedC
//**********************Séquence****************************************************************************//
//Transitions
if (digitalRead(buttonPin) && !LastbuttonState && (LastStep == 0))
{
Achetez Neuf Canape Vente CadeauAnnonce Revente Ensemble À oBxedC
Step = 1;
Serial.print(" Transition 0->1");
Serial.print(" Bouton:");
Serial.print(digitalRead(buttonPin));
}
if (TempoOut && (LastStep == 1))
{
Step = 0;
Serial.print(" Transition 1->0");
Serial.print(" Bouton:");
Serial.print(digitalRead(buttonPin));
10 Medio Punto Rotin Gifi Top En NoticiasFauteuil Suspendu LSGqzMjUVp }
Tabouret Bar Achat Tabourets Noir Vente De Lot 2 Calvin PZukTOlwXi
//Etapes
if (Step == 0)
{
//AngleServo = 0;
Servo180_1.write(0); //Ecrit la consigne au servomoteur via PWM
Cote Argus Fauteuil Price Ramos For Vintage Design 9beE2YHWDI Servo180_2.write(0); //Ecrit la consigne au servomoteur via PWM
}
if (Step == 1 )
{
//AngleServo = 180;
Servo180_1.write(180); //Ecrit la consigne au servomoteur via PWM
Servo180_2.write(180); //Ecrit la consigne au servomoteur via PWM
}
Achetez Neuf Canape Vente CadeauAnnonce Revente Ensemble À oBxedC
LastbuttonState = digitalRead(buttonPin);
LastStep = Step;
}