[Partage] Boutons Poussoirs

Bonjour
Je suis en train de tester simpleBouton.h et un tutoriel sur la machien à état qui répond à mes attentes: action quand le bouton est appuyé (et non relâché) Merci à son auteur !

Peux-ton faire un callback avec cette librairie pour faire fonctionner ce code ?

void simpleclick()//http://forum.arduino.cc/index.php?topic=470879.0
{
... // le code à exécuter quand on fait un click sur le bouton
}

void setup() {
  button.attachClick(simpleclick); // on associe le fonction callBack à l'appui sur le bouton
}


void loop() {
  button.tick();  // On vérifie l'état des boutons, ce qui déclenche les appels aux fonctions
}

A priori non car j'ai ce message

'class simpleBouton' has no member named 'attachClick'

Idem avec bouton_aller.attacher(clic);

Comment faire?

//essai state machine du 26/04
#include "simpleBouton.h"
#include <AccelStepper.h>

#define FULLSTEP 4
#define HALFSTEP 8

#define motorPin1  8     // Blue   - 28BYJ48 pin 1
#define motorPin2  9     // Pink   - 28BYJ48 pin 2
#define motorPin3  10    // Yellow - 28BYJ48 pin 3
#define motorPin4  11    // Orange - 28BYJ48 pin 4

#define motorPin5  4     // Blue   - 28BYJ48 pin 1
#define motorPin6  5     // Pink   - 28BYJ48 pin 2
#define motorPin7  6     // Yellow - 28BYJ48 pin 3
#define motorPin8  7     // Orange - 28BYJ48 pin 4

// Define two motor objects
// The sequence 1-3-2-4 is required for proper sequencing of 28BYJ48
AccelStepper stepper_ar(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
AccelStepper stepper_camera(HALFSTEP, motorPin5, motorPin7, motorPin6, motorPin8); 


simpleBouton bouton_aller(2);
simpleBouton bouton_retour(3);

enum {DEMARRE, ALLER, RETOUR} etatCourant;

// ------------------------------------------------------
// Cette fonction installe l'état initial
// ------------------------------------------------------
void demarre()
{
stepper_ar.moveTo(500);//4096 = 2 tours
 stepper_ar.setSpeed(400);
 etatCourant = DEMARRE;
}


// ------------------------------------------------------
// La fonction de call back, appellée automatiquement quand on clique
// ------------------------------------------------------
void clic()
{
  switch (etatCourant) {
    case ARRET: // on était au repos et on a un appui, on allume la verte
      stepper_ar.moveTo(2000);//4096 = 2 tours
      stepper_ar.setSpeed(400);
      etatCourant = ALLER; // on note le nouvel état de notre système
      break;

    case ALLER: // on était led verte allumée et on a un appui, on allume la jaune
      stepper_ar.moveTo(-2000);//4096 = 2 tours
      stepper_ar.setSpeed(-400);
      etatCourant = RETOUR;// on note le nouvel état de notre système
      break;
  }
}


void setup() {

  bouton_aller.attachClick(clic); // on associe le fonction callBack à l'appui sur le bouton
    bouton_retour.attachClick(clic); // on associe le fonction callBack à l'appui sur le bouton
    
  arret();

stepper_ar.setMaxSpeed(700.0);
stepper_ar.setAcceleration(400.0);
stepper_camera.setMaxSpeed(700.0);
stepper_camera.setAcceleration(400.0); 
}



void loop() {
  bouton_aller.actualiser();
  bouton_retour.actualiser();

  stepper_ar.run();
stepper_camera.run();
}

Merci beaucoup !