Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to simulate GPIO input (pressed button) ? #8

Closed
Lecrapouille opened this issue Jul 1, 2022 · 1 comment
Closed

A way to simulate GPIO input (pressed button) ? #8

Lecrapouille opened this issue Jul 1, 2022 · 1 comment

Comments

@Lecrapouille
Copy link

How to simulate this kind of code ?

bool bp_on;
void setup() {
  pinMode(3, INPUT);
}

void loop() {
  bp_on = digitalRead(3);
}

Currently, it just displays:

pinMode pin 3 set to : INPU
pinMode pin 4 set to : INPU

But no interaction possible to simulate button pressed.

By the way, typo at https://github.com/marcmerlin/ArduinoOnPc-FastLED-GFX-LEDMatrix/blob/master/src/cores/arduino/wiring_digital.cpp#L19 should be INPUT (no INPU).

Full ino code:

bool bp_on;                  // variable associee au bouton poussoire on
bool bp_off;                 // variable associee au bouton poussoire off
enum Etat { MARCHE, ARRET }; // Declaration des etats possibles
Etat etatCourant;            // variable associee à l'etat courant

void setup()
{
    pinMode(3, INPUT);    // La pin 3 est definie comme une entree (bouton poussoire)
    pinMode(4, INPUT);    // La pin 4 est definie comme une entree (bouton poussoire)
    etatCourant = MARCHE; // Etat initial
}

void loop()
{
    // Mise a jour des entrees
    bp_on = digitalRead(3);
    bp_off = digitalRead(4);

    // Gestion de l'evolution des etats
    switch (etatCourant)
    {
    case MARCHE:
        // Action etat Marche
        //...

        // Transition vers l'etat ARRET
        if (bp_off) {
            etatCourant = ARRET;
        }
        break;

    case ARRET :
        // Action etat Arret
        //...

        //Transition vers l'etat MARCHE
        if (bp_on) {
            etatCourant = MARCHE;
        }
        break;
    }
}
@marcmerlin
Copy link
Owner

Good question, this part of the code I did not write and I don't use, it was forked from https://github.com/ChrisMicro/ArduinoOnPc
I suggest you ask file the issue in https://github.com/ChrisMicro/ArduinoOnPc , sorry that I can't help with this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants