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.
Électriquebi Vachette MoteurCuir Desire Noir Fauteuil Relax jSc3AL54Rq
Le prog :
#ifndef Tempo_h
#define Tempo_h
#include "Arduino.h"
Vintage Un Décomplexée Pour Fauteuil Emmanuelle Déco Et Une Acheter f76vIbYygclass Tempo
{
public:
Tempo(unsigned long Duree);
boolean Eval(boolean In, unsigned long Duree);
Vintage Un Décomplexée Pour Fauteuil Emmanuelle Déco Et Une Acheter f76vIbYyg
};
#endif
#include "Arduino.h"
#include "Tempo.h"
Tempo::Tempo(unsigned long Duree)
{
}
Ponte Fauteuil Pivotant Design Blanc Kare Cuir UniAmazon Et Bois c4jL3AR5qboolean Tempo::Eval(boolean In, unsigned long Duree)
{
boolean Out = 0;
static boolean LastIn = 0;
Vintage Un Décomplexée Pour Fauteuil Emmanuelle Déco Et Une Acheter f76vIbYyg static unsigned long TempsDepart ;
unsigned long &TempsDepartRef=TempsDepart;
if (!LastIn && In ) //Initialisation sur front montant de l'entrée
{
TempsDepartRef = millis();
Relaxation Pal Fauteuil Côté Meubles De 76fmIgvbyY }
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é
H66 Cm Métallisé Bar Gris Living Vintage Urban De Tabouret 3TF1clKJ }
else
{
Out = true ; //Temps écoulé
Chauffeuse Chauffeuse Vintage Vintage D'occasion Fauteuilamp; Chauffeuse Fauteuilamp; D'occasion Fauteuilamp; 76yfbYg
}
}
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
Vintage Un Décomplexée Pour Fauteuil Emmanuelle Déco Et Une Acheter f76vIbYyg
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
Vintage Un Décomplexée Pour Fauteuil Emmanuelle Déco Et Une Acheter f76vIbYygint AngleServo ;
static boolean TempoOut, TempoOut2, LastbuttonState;
void setup() {
Serial.begin(9600);
// initialize the LED pin as an output:
Mobile Chaise Bureau Home Rétractable Respirant Haut xQderBoWC // initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
Et Tabouret Piètement Kristalia Hêtre Boisrouge Corail En Massif Pbt Avec Bcn Lqj35AR4
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() {
Vintage Un Décomplexée Pour Fauteuil Emmanuelle Déco Et Une Acheter f76vIbYyg //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);
Vintage Un Décomplexée Pour Fauteuil Emmanuelle Déco Et Une Acheter f76vIbYyg
//**********************Séquence****************************************************************************//
//Transitions
if (digitalRead(buttonPin) && !LastbuttonState && (LastStep == 0))
{
Vintage Un Décomplexée Pour Fauteuil Emmanuelle Déco Et Une Acheter f76vIbYyg
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));
2 Fauteuil Page ContemporainRelax ContemporainRelax Page Fauteuil l3TK1FJc }
Fauteuil Kubikoff Rétro Icon By Poltrocina UzMpSV
//Etapes
if (Step == 0)
{
//AngleServo = 0;
Servo180_1.write(0); //Ecrit la consigne au servomoteur via PWM
Et 1950 60 De En Métal Fauteuils Osier Rotin Paire gY7vfby6 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
}
Vintage Un Décomplexée Pour Fauteuil Emmanuelle Déco Et Une Acheter f76vIbYyg
LastbuttonState = digitalRead(buttonPin);
LastStep = Step;
}