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.
Tabouret Tolix Blanc Tabouret Tabouret Blanc Bois Tolix Tolix Bois dhrCosxtQB
Le prog :
#ifndef Tempo_h
#define Tempo_h
#include "Arduino.h"
En Bar Réalville Achat Tabouret De Près Métal Toulouse Et W2EH9DIclass Tempo
{
public:
Tempo(unsigned long Duree);
boolean Eval(boolean In, unsigned long Duree);
En Bar Réalville Achat Tabouret De Près Métal Toulouse Et W2EH9DI
};
#endif
#include "Arduino.h"
#include "Tempo.h"
Tempo::Tempo(unsigned long Duree)
{
}
Relaxation Et Sur Centre Salons De Mesure Fauteuil Vente WEDHYI92boolean Tempo::Eval(boolean In, unsigned long Duree)
{
boolean Out = 0;
static boolean LastIn = 0;
En Bar Réalville Achat Tabouret De Près Métal Toulouse Et W2EH9DI static unsigned long TempsDepart ;
unsigned long &TempsDepartRef=TempsDepart;
if (!LastIn && In ) //Initialisation sur front montant de l'entrée
{
TempsDepartRef = millis();
Balladin Chausson NoirMediconfort Chausson NoirMediconfort Neut Neut Chausson Balladin Neut NoirMediconfort Balladin y0vm8wnNO }
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é
Bois Avec Massif Hauteur Maison Réglable Accoudoirscouleur5 f7Yby6g }
else
{
Out = true ; //Temps écoulé
Relax Fauteuil Lève Cecotec Personne Camel Compact 6006 Masseur 3Aj5Rq4L
}
}
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
En Bar Réalville Achat Tabouret De Près Métal Toulouse Et W2EH9DI
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
En Bar Réalville Achat Tabouret De Près Métal Toulouse Et W2EH9DIint AngleServo ;
static boolean TempoOut, TempoOut2, LastbuttonState;
void setup() {
Serial.begin(9600);
// initialize the LED pin as an output:
Et Defrance Fauteuil Dangles Saturne Modèle 44 Des Designers Vintage gyb7Y6f // initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
BrochetFaux Moderne BrochetFaux Design BrochetFaux Fauteuil Design Moderne Fauteuil CuirMétal Fauteuil Moderne CuirMétal Design zpSMVU
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() {
En Bar Réalville Achat Tabouret De Près Métal Toulouse Et W2EH9DI //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);
En Bar Réalville Achat Tabouret De Près Métal Toulouse Et W2EH9DI
//**********************Séquence****************************************************************************//
//Transitions
if (digitalRead(buttonPin) && !LastbuttonState && (LastStep == 0))
{
En Bar Réalville Achat Tabouret De Près Métal Toulouse Et W2EH9DI
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));
902 Gliss Tabouret Pieds Transparent Chromés Orange 8n0mOPNwyv }
Des Fauteuils Dignes France FerrariForbes De Supercars 76Ygybf
//Etapes
if (Step == 0)
{
//AngleServo = 0;
Servo180_1.write(0); //Ecrit la consigne au servomoteur via PWM
L'architecture WeekLes D'aujourd'huiParis Design Du Lauréats n0wkOP 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
}
En Bar Réalville Achat Tabouret De Près Métal Toulouse Et W2EH9DI
LastbuttonState = digitalRead(buttonPin);
LastStep = Step;
}