assurance-tunnel
assurance-tunnel
assurance-tunnel
assurance-tunnel

Arduino multi. bouton



  • Bonjours,

    J'aimerais utiliser un Arduino pour changer mes scenes sur Isadora, mais j'ai un soucis dans la communication entre Arduino et Isadora, les premières valeur des boutons fonctionne mais après 5, 6 cela ne va plus!

    Arduino

    int analogPin1 = A0;
    int analogPin2 = A1;
    int analogPin3 = A2;
    int analogPin4 = A3;
    int analogPin5 = A4;
    int analogPin6 = A5;
    int analogPin7 = A6;
    int analogPin8 = A7;
    int ldrVal = 0; 
    int threshold = 800; 
    void setup() 
    { 
      Serial.begin(9600); 
      pinMode(2, INPUT);
      pinMode(3, INPUT);
      pinMode(4, INPUT);
      pinMode(5, INPUT);
      pinMode(6, INPUT);
      pinMode(7, INPUT);
      pinMode(8, INPUT);
      pinMode(9, INPUT);
      pinMode(10, INPUT);
      pinMode(11, INPUT);
      pinMode(12, INPUT);
      pinMode(13, INPUT);
    } 
    void loop() { 
      //Analog 0 (Num 4)
      ldrVal = analogRead(analogPin1); 
      if ( ldrVal < threshold ) 
      { 
      Serial.println ("4"); 
        delay(100);
      }
        //Analog 1 (Num 7)
        ldrVal = analogRead(analogPin2); 
      if ( ldrVal < threshold ) 
      { 
      Serial.println ("7"); 
        delay(100);
      }
      //Analog 2 (Num *)
      ldrVal = analogRead(analogPin3); 
      if ( ldrVal < threshold ) 
      { 
      Serial.println ("10"); 
        delay(100);
      }
        //Analog 3  (Num 5)
        ldrVal = analogRead(analogPin4); 
      if ( ldrVal < threshold ) 
      { 
      Serial.println ("5"); 
        delay(100);
      }
      //Analog 4 (Num 2)
      ldrVal = analogRead(analogPin5); 
      if ( ldrVal < threshold ) 
      { 
      Serial.println ("2"); 
        delay(100);
      }
        //Analog 5 (Num 0)
        ldrVal = analogRead(analogPin6); 
      if ( ldrVal < threshold ) 
      { 
      Serial.println ("11"); 
        delay(100);
      }
      //Analog 6 (Num 8)
      ldrVal = analogRead(analogPin7); 
      if ( ldrVal < threshold ) 
      { 
      Serial.println ("8"); 
        delay(100);
      }
        //Analog 7 (Num #)
        ldrVal = analogRead(analogPin8); 
      if ( ldrVal < threshold ) 
      { 
      Serial.println ("12"); 
        delay(100);
      }
    
    //Digital 2 (Telephone)
    

    int buttonState2 = digitalRead(2);

    if (buttonState2 == LOW)
    {
    Serial.println ("20");
    delay(100);
    }
    //Digital 3 (Touche A)
    int buttonState3 = digitalRead(3);

    if (buttonState3 == LOW)
    {
    Serial.println ("18");
    delay(100);
    }
    //Digital 4 (Touche Service)
    int buttonState4 = digitalRead(4);

    if (buttonState4 == LOW)
    {
    Serial.println ("16");
    delay(100);
    }
    //Digital 5 (Touche B)
    int buttonState5 = digitalRead(5);

    if (buttonState5 == LOW)
    {
    Serial.println ("19");
    delay(100);
    }
    //Digital 6 (Touche Belgacom)
    int buttonState6 = digitalRead(6);

    if (buttonState6 == LOW)
    {
    Serial.println ("15");
    delay(100);
    }
    //Digital 7 (Touche Proton)
    int buttonState7 = digitalRead(7);

    if (buttonState7 == LOW)
    {
    Serial.println ("17");
    delay(100);
    }
    //Digital 8 (Home)
    int buttonState8 = digitalRead(8);

    if (buttonState8 == LOW)
    {
    Serial.println ("13");
    delay(100);
    }
    //Digital 9 (Num 9)
    int buttonState9 = digitalRead(9);

    if (buttonState9 == LOW)
    {
    Serial.println ("9");
    delay(100);
    }
    //Digital 10 (Num 1)
    int buttonState10 = digitalRead(10);

    if (buttonState10 == LOW)
    {
    Serial.println ("1");
    delay(100);
    }
    //Digital 11 (Num 6)
    int buttonState11 = digitalRead(11);

    if (buttonState11 == LOW)
    {
    Serial.println ("6");
    delay(100);
    }
    //Digital 12 (Num 3)
    int buttonState12 = digitalRead(12);

    if (buttonState12 == LOW)
    {
    Serial.println ("3");
    delay(100);
    }
    //Digital 13 (Touche STOP)
    int buttonState13 = digitalRead(13);

    if (buttonState13 == LOW)
    {
    Serial.println ("14");
    delay(100);
    }
    }

    Isadora "Serial In Watcher - Binary"


    "1"
    value : integer = 4 digits

    Voila si quelque peut m'aider.

    Merci.


  • Beta Gold

    Hi,

    Is it not working after 5,6 messages, or are buttons 5,6 and higher not working?

    If you open the monitor window, is there serial data coming in?


  • Tech Staff

    @djoul123 said:

    Bonjours,

    J'aimerais utiliser un Arduino pour changer mes scenes sur Isadora, mais j'ai un soucis dans la communication entre Arduino et Isadora, les premières valeur des boutons fonctionne mais après 5, 6 cela ne va plus!

    Voila si quelque peut m'aider.

    Merci.

     Rough translation for my own benefit (and anyone else's): 

    Hello,

    I would like to use an Arduino to change my scenes on Isadora, but I have a problem in the communication between Arduino and Isadora, the first value of the buttons works but after 5, 6 it does not go anymore!

    Voila if any can help me.

    Thank you.


  • Beta Gold

    Hey @djoul123 ,

    c'est mieux de poster en anglais sur le forum pour avoir plus de réponses et que ce soit plus facile pour tout le monde de comprendre ;)

    You're reassigning your ldrVal integer each time, maybe that could cause a problem, it would be better to create an array of integer to handle that.

    I haven't be using arduino for some time, so beware of syntax errors from my side :)

    int ldrVal[8];
    int buttonState[11]; // it was working how you did, but easier like that and you should declare everything all your variable at the beginning
    void loop(){
    for(int i = 0; i < 12; i++){
    if( ldrVal[i]> threshold){
    Serial.println(String(i)); //since you seem to want to send strings...
    delay(100);
    }

    You can do the same with buttonState to make the code easier to read



  • Hi

    Do you use any pull up/down resistors for buttons, how are they wired? Which Arduino board are you using?



  • @djoul123

    what specific arduino board do you use ? analog pins could be used as digital inputs, in your sketch you use 20 inputs.

    in isadora you use a filter inside of your serial in watcher // the 4 byte length message need to have a "1" to start with,

    i think it is better to use a text based serial in watcher since you send a carriage return with each println already.

    attached you will find an izzy file

    best clemens

    arduino_multi_buttons.izz



  • @djoul123

    in your arduino code you cycle through your 20 pin readings always with a 0,1 s delay

    that means you have to wait at least 2 seconds till the program will be again asking for the status of the button you just pushed.

    I would recommend that you have a look how a keyboard matrix is setup, there should be plenty of infos on the arduino forum. That way you have a snappy arduino code to interact with isadora.