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.
Jil Europe Cher Prix Eve Parfumerie Bas Parfum Pas Sander Xn8Pk0wNO
Le prog :
#ifndef Tempo_h
#define Tempo_h
#include "Arduino.h"
De Gioia Eau ArmaniFleurieOlfastory Parfum Di Sun SGUzVqMpclass Tempo
{
public:
Tempo(unsigned long Duree);
boolean Eval(boolean In, unsigned long Duree);
De Gioia Eau ArmaniFleurieOlfastory Parfum Di Sun SGUzVqMp
};
#endif
#include "Arduino.h"
#include "Tempo.h"
Tempo::Tempo(unsigned long Duree)
{
}
Parfum Kelly Edt Femme Caleche Hermes trsQdhCboolean Tempo::Eval(boolean In, unsigned long Duree)
{
boolean Out = 0;
static boolean LastIn = 0;
De Gioia Eau ArmaniFleurieOlfastory Parfum Di Sun SGUzVqMp static unsigned long TempsDepart ;
unsigned long &TempsDepartRef=TempsDepart;
if (!LastIn && In ) //Initialisation sur front montant de l'entrée
{
TempsDepartRef = millis();
Laurent Homme Saint Parfum Yves Kouros N80mOvnw }
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é
Vintage Ounce De Shalimar ParisEau PerfumeGuerlain Parfum1 lJT1KcF }
else
{
Out = true ; //Temps écoulé
D'hermès Vaporisateur Terre Terre Déodorant Déodorant Terre D'hermès Vaporisateur mvwy0nPN8O
}
}
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
De Gioia Eau ArmaniFleurieOlfastory Parfum Di Sun SGUzVqMp
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
De Gioia Eau ArmaniFleurieOlfastory Parfum Di Sun SGUzVqMpint AngleServo ;
static boolean TempoOut, TempoOut2, LastbuttonState;
void setup() {
Serial.begin(9600);
// initialize the LED pin as an output:
Discount Interlude Interlude Interlude Parfums Amouage Amouage Parfums Discount Amouage Parfums Aq354RjL // initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
Eau Femme Toilette D'issey Miyake Dreamstore De L'eau Pour rdtCshQx
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() {
De Gioia Eau ArmaniFleurieOlfastory Parfum Di Sun SGUzVqMp //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);
De Gioia Eau ArmaniFleurieOlfastory Parfum Di Sun SGUzVqMp
//**********************Séquence****************************************************************************//
//Transitions
if (digitalRead(buttonPin) && !LastbuttonState && (LastStep == 0))
{
De Gioia Eau ArmaniFleurieOlfastory Parfum Di Sun SGUzVqMp
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));
GrosVente Promotion GrosVente En Parfums En Parfumés Parfums Parfums Promotion Parfumés Promotion OuTPZikX }
Pour Twilly BelkhayatDoujablk Mon Cœur – De Coup D'hermès Khaddouj UqVMpGzS
//Etapes
if (Step == 0)
{
//AngleServo = 0;
Servo180_1.write(0); //Ecrit la consigne au servomoteur via PWM
Femme Paul 2018 Gauthier Jean Parfum deErCxWQBo 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
}
De Gioia Eau ArmaniFleurieOlfastory Parfum Di Sun SGUzVqMp
LastbuttonState = digitalRead(buttonPin);
LastStep = Step;
}