Aller au contenu


Photo
- - - - -

Arduino to Atem

Arduino atem

27 réponses à ce sujet

#21 vins86

vins86

    Nouveau membre

  • Membres
  • 27 messages

Posté 28 juillet 2018 - 11:00

Bonsoir,

 

Je me permet de revenir. Mon projet avance bien. Maintenant je suis confronté à un problème et sans réponse.

 

J'essaye de faire fonctionner le keypad, mais impossible. Tous les potentiomètres fonctionnent, mais pas les boutons.

 

Les différents numéros de pin sont bon.

#include <Wire.h>
#include <Keypad.h>
#include <Firmata.h>

#define BITSB 8
#define TOLERANCE 10
#define  Data0       32          //15
#define  Data1       30          //16
#define  Data2       28          //17
#define  Data3       24          //19
#define  Data4       23          //
#define  Data5       27          //
#define  Data6       31          //
#define  Data7       35          //
#define  W0          40          //
#define  W1          38          //
#define  W2          36          //
#define  W3          34          //
#define  AnalRead    33          //5
#define  AnalConv    29          //7
#define  LEDwrite    26          //18
#define  buttread    22          //20
#define  Display     25           //9

#define ON 1
#define OFF 0

int DecoderPins[] = {40, 38, 36, 34};
int BlinkCount = 0;
int BlinkStatus = 0;
byte AnalogPreviousValues [] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};


// Keypad setup
//
const byte ROWS = 8;
const byte COLS  = 10;
char keys[ROWS][COLS] = {
  {'1', '9', 'h', 'p', 'x', 'G', 'O', 'W', '$', '>'},
  {'2', 'a', 'i', 'q', 'y', 'H', 'P', 'X', '%', '?'},
  {'3', 'b', 'j', 'r', 'A', 'I', 'Q', 'Y', '^', '/'},
  {'4', 'c', 'k', 's', 'B', 'J', 'R', 'Z', '&', '-'},
  {'5', 'd', 'l', 't', 'C', 'K', 'S', '~', '*', '['},
  {'6', 'e', 'm', 'u', 'D', 'L', 'T', '!', '(', ']'},
  {'7', 'f', 'n', 'v', 'E', 'M', 'U', '@', ')', ';'},
  {'8', 'g', 'o', 'w', 'F', 'N', 'V', '#', '<', '+'}
};
byte rowPins[ROWS] = {32, 30, 28, 24, 23, 27, 31, 35};
byte colPins[COLS] = {2, 3, 4, 5, 6, 8, 9, 10, 11, 12}; //not actually using these pins, just binary conversion to drive encoder

//BCD to drive decoder pins for LED and Keyboard row select
byte BCD[16][4] = {{0, 0, 0, 0},
  {1, 0, 0, 0},
  {0, 1, 0, 0},
  {1, 1, 0, 0},
  {0, 0, 1, 0},
  {1, 0, 1, 0},
  {0, 1, 1, 0},
  {1, 1, 1, 0},
  {0, 0, 0, 1},
  {1, 0, 0, 1},
  {0, 1, 0, 1},
  {1, 1, 0, 1},
  {0, 0, 1, 1},
  {1, 0, 1, 1},
  {0, 1, 1, 1},
  {1, 1, 1, 1}
}; //BCD code

int bussLEDs[] =    {8, 9, 10, 11, 12, 13, 14, 15, 34, 35};
int previewLEDs[] = {16, 17, 18, 19, 20, 21, 22, 23, 32, 33};
int programLEDs [] = {24, 25, 26, 27, 28, 29, 30, 31, 36, 37};
int patternLEDs[] = {68, 69, 66, 65, 64, 76, 77,74, 73, 72};

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void keypadEvent(KeypadEvent key) {
  String echoMsg;
  String action;
  switch (keypad.getState()) {
    case PRESSED: {
        action = "Down,";
        echoMsg = action + key;
        Firmata.sendString(echoMsg.c_str());
        break;
      }
    case HOLD: {
        action = "Hold,";
        echoMsg = action + key;
        Firmata.sendString(echoMsg.c_str());
        break;
      }
  }
}

//Led status array
#define LedBITSB 8            // number of bits per byte, used for code clarity
#define LedDATABITS 80
const int arrayLen = (int)((LedDATABITS - 1) / LedBITSB) + 1;
//byte LEDArray[arrayLen];        // for GVG100, length is 10 and that could hold 80 values
int LEDArray[LedDATABITS];
int BlinkLEDArray[LedDATABITS];

void initLEDarray() {
  for (int i = 0; i < LedDATABITS; i++) {
    LEDArray[i] = 0;
  }
}
void initBlinkLEDarray() {
  for (int i = 0; i < LedDATABITS; i++) {
    BlinkLEDArray[i] = 0;
  }
}

void stringCallback(char *myString)
{

  String lcdString = String(myString);
  int Line1Index = lcdString.indexOf(',');
  int Line2Index = lcdString.indexOf(',', Line1Index + 1); // more than one comma?

  String Line1 = lcdString.substring(0, Line1Index);
  String Line2 = lcdString.substring(Line1Index + 1);
  // update led
  int LEDSelRow = 0;
  LEDSelRow = Line2.toInt() / 8; //find row number - this rounds automatically
  //SelectLedRow(LEDSelRow);
  int LedSelCol = 0;
  LedSelCol = (Line2.toInt() % 8); //use MOD to find bit position
  digitalWrite(buttread, HIGH);
  switch (Line1.toInt())
  {
    case 0:
      {
        //set all off
        initBlinkLEDarray();
        WriteData();
        digitalWrite(Data0, LOW);
        digitalWrite(Data1, LOW);
        digitalWrite(Data2, LOW);
        digitalWrite(Data3, LOW);
        digitalWrite(Data4, LOW);
        digitalWrite(Data5, LOW);
        digitalWrite(Data6, LOW);
        digitalWrite(Data7, LOW);
        for (int number = 0; number <= 11; number ++)
        {
          DecoderOut(number);
        }
        break;
      }
    case 1:
      {
        //set LED off
        LEDArray[Line2.toInt()] = 0;
        WriteData();
        for (int i = 0; i < 8; i++) {
          digitalWrite(rowPins[i] , LEDArray[(LEDSelRow * 8) + i]);
        }
        delay(1);
        DecoderOut(LEDSelRow);
        delay(1);
        break;
      }
    case 2:
      {
        //Set LED On
        LEDArray[Line2.toInt()] = 1;
        WriteData();
        for (int i = 0; i < 8; i++) {
          digitalWrite(rowPins[i] , LEDArray[(LEDSelRow * 8) + i]);
        }
        delay(1);
        DecoderOut(LEDSelRow);
        delay(1);
        break;
      }
    case 3:
      {
        //set LED blink off
        BlinkLEDArray[Line2.toInt()] = 0;
        LEDArray[Line2.toInt()] = 0;
        break;
      }
    case 4:
      {
        //set LED blink on
        BlinkLEDArray[Line2.toInt()] = 1;
        break;
      }
    case 5:
      {
        //set all KeyBus leds to blink (1) or no blink (0)
        if (BlinkStatus == 1) {
          //leds are already on so update blinking and set state off
          blinkLEDs();
          BlinkStatus = 0;
        }
        for (int i = 0; i < 10; i++) {
          BlinkLEDArray[bussLEDs[i]] = Line2.toInt();
        }
        break;
      }
    case 6:
      {
        //turn off all led and bling state for specified program, preview or keybus
        //if(BlinkStatus == 1){
        //leds are already on so update blinking and set state off
        //blinkLEDs();
        //BlinkStatus = 0;
        //}
        for (int i = 0; i < 10; i++) {
          if (Line2 == "program") {
            BlinkLEDArray[programLEDs[i]] = 0;
            LEDArray[programLEDs[i]] = 0;
            WriteData();
            for (int j = 0; j < 8; j++) {
              digitalWrite(rowPins[j] , LEDArray[(0) + j]);
            }
            DecoderOut(0);
            for (int j = 0; j < 8; j++) {
              digitalWrite(rowPins[j] , LEDArray[(8) + j]);
            }
            DecoderOut(1);
            for (int j = 0; j < 8; j++) {
              digitalWrite(rowPins[j] , LEDArray[(32) + j]);
            }
            DecoderOut(4);
          }
          if (Line2 == "preview") {
            BlinkLEDArray[previewLEDs[i]] = 0;
            LEDArray[previewLEDs[i]] = 0;
            WriteData();
            for (int j = 0; j < 8; j++) {
              digitalWrite(rowPins[j] , LEDArray[(0) + j]);
            }
            DecoderOut(0);
            for (int j = 0; j < 8; j++) {
              digitalWrite(rowPins[j] , LEDArray[(32) + j]);
            }
            DecoderOut(4);
          }
          if (Line2 == "keybus") {
            BlinkLEDArray[bussLEDs[i]] = 0;
            LEDArray[bussLEDs[i]] = 0;
            WriteData();
            for (int j = 0; j < 8; j++) {
              digitalWrite(rowPins[j] , LEDArray[(8) + j]);
            }
            DecoderOut(1);
            for (int j = 0; j < 8; j++) {
              digitalWrite(rowPins[j] , LEDArray[(24) + j]);
            }
            DecoderOut(3);
            for (int j = 0; j < 8; j++) {
              digitalWrite(rowPins[j] , LEDArray[(48) + j]);
            }
            DecoderOut(6);
          }
          if (Line2 == "patterns") {
            BlinkLEDArray[patternLEDs[i]] = 0;
            LEDArray[patternLEDs[i]] = 0;
            WriteData();
            for (int j = 0; j < 8; j++) {
              digitalWrite(rowPins[j] , LEDArray[(64) + j]);
            }
            DecoderOut(8);
            for (int j = 0; j < 8; j++) {
              digitalWrite(rowPins[j] , LEDArray[(72) + j]);
            }
            DecoderOut(9);
          }
        }
        break;
      }
    case 7:
      {
        //Set Pattern Control leds
        //0 = all off, 1= all blink
        if (BlinkStatus == 1) {
          //leds are already on so update blinking and set state off
          blinkLEDs();
          BlinkStatus = 0;
        }
        for (int i = 0; i < 10; i++) {
          BlinkLEDArray[patternLEDs[i]] = Line2.toInt();
          if (Line2.toInt() == 0) {
            //if turning off blink, also turning off leds alltogether
            LEDArray[patternLEDs[i]] = 0;
          }
        }
        break;
      }
    case 9:
      {
        readAnalogValues();
        break;
      }
  }
}
void SetDataBit(int bit) {
  switch (bit)
  {
    case 0:
      {
        digitalWrite(Data0, HIGH);
        digitalWrite(Data1, LOW);
        digitalWrite(Data2, LOW);
        digitalWrite(Data3, LOW);
        digitalWrite(Data4, LOW);
        digitalWrite(Data5, LOW);
        digitalWrite(Data6, LOW);
        digitalWrite(Data7, LOW);
        break;
      }
    case 1:
      {
        digitalWrite(Data0, LOW);
        digitalWrite(Data1, HIGH);
        digitalWrite(Data2, LOW);
        digitalWrite(Data3, LOW);
        digitalWrite(Data4, LOW);
        digitalWrite(Data5, LOW);
        digitalWrite(Data6, LOW);
        digitalWrite(Data7, LOW);
        break;
      }
    case 2:
      {
        digitalWrite(Data0, LOW);
        digitalWrite(Data1, LOW);
        digitalWrite(Data2, HIGH);
        digitalWrite(Data3, LOW);
        digitalWrite(Data4, LOW);
        digitalWrite(Data5, LOW);
        digitalWrite(Data6, LOW);
        digitalWrite(Data7, LOW);
        break;
      }
    case 3:
      {
        digitalWrite(Data0, LOW);
        digitalWrite(Data1, LOW);
        digitalWrite(Data2, LOW);
        digitalWrite(Data3, HIGH);
        digitalWrite(Data4, LOW);
        digitalWrite(Data5, LOW);
        digitalWrite(Data6, LOW);
        digitalWrite(Data7, LOW);
        break;
      }
    case 4:
      {
        digitalWrite(Data0, LOW);
        digitalWrite(Data1, LOW);
        digitalWrite(Data2, LOW);
        digitalWrite(Data3, LOW);
        digitalWrite(Data4, HIGH);
        digitalWrite(Data5, LOW);
        digitalWrite(Data6, LOW);
        digitalWrite(Data7, LOW);
        break;
      }
    case 5:
      {
        digitalWrite(Data0, LOW);
        digitalWrite(Data1, LOW);
        digitalWrite(Data2, LOW);
        digitalWrite(Data3, LOW);
        digitalWrite(Data4, LOW);
        digitalWrite(Data5, HIGH);
        digitalWrite(Data6, LOW);
        digitalWrite(Data7, LOW);
        break;
      }
    case 6:
      {
        digitalWrite(Data0, LOW);
        digitalWrite(Data1, LOW);
        digitalWrite(Data2, LOW);
        digitalWrite(Data3, LOW);
        digitalWrite(Data4, LOW);
        digitalWrite(Data5, LOW);
        digitalWrite(Data6, HIGH);
        digitalWrite(Data7, LOW);
        break;
      }
    case 7:
      {
        digitalWrite(Data0, LOW);
        digitalWrite(Data1, LOW);
        digitalWrite(Data2, LOW);
        digitalWrite(Data3, LOW);
        digitalWrite(Data4, LOW);
        digitalWrite(Data5, LOW);
        digitalWrite(Data6, LOW);
        digitalWrite(Data7, HIGH);
        break;
      }
  }
}

void initFirmata()
{
  // Uncomment to save a couple of seconds by disabling the startup blink sequence.
  Firmata.setFirmwareVersion(FIRMATA_FIRMWARE_MAJOR_VERSION, FIRMATA_FIRMWARE_MINOR_VERSION);
  Firmata.attach(STRING_DATA, stringCallback);
  Firmata.disableBlinkVersion();
  Firmata.begin(57600);
}


void setup() {

  initLEDarray();
  initBlinkLEDarray();
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  pinMode(AnalRead, OUTPUT);
  digitalWrite(AnalRead, HIGH);
  pinMode(AnalConv, OUTPUT);
  digitalWrite(AnalConv, HIGH);
  pinMode(LEDwrite, OUTPUT);
  digitalWrite(LEDwrite, HIGH);
  pinMode(buttread, OUTPUT);
  digitalWrite(buttread, HIGH);
  pinMode(Display, OUTPUT);
  digitalWrite(Display, HIGH);
  pinMode(W0, OUTPUT);
  pinMode(W1, OUTPUT);
  pinMode(W2, OUTPUT);
  pinMode(W3, OUTPUT);

  //turn off all lamps

  WriteData();
  digitalWrite(Data0, LOW);
  digitalWrite(Data1, LOW);
  digitalWrite(Data2, LOW);
  digitalWrite(Data3, LOW);
  digitalWrite(Data4, LOW);
  digitalWrite(Data5, LOW);
  digitalWrite(Data6, LOW);
  digitalWrite(Data7, LOW);


  for (int number = 0; number <= 11; number ++)
  {
    DecoderOut(number);
  }

  //set initial analog values in array
  ReadData();
  for (int pot = 0; pot < 15; pot++)
  {
    byte currentPotValue = AnalogIn(pot);
    AnalogPreviousValues[pot] = currentPotValue;
  }
  initFirmata();
  delay(10);
  //READY FOR KEYBOARD
  keypad.addEventListener(keypadEvent);
}

void loop() {
  WriteData();
  while (Firmata.available()) {
    Firmata.processInput();
  }
  readAnalogValues();
  delay(50);
  keypad.getKeys();
  //serial.update();
  //delay(10);
  BlinkCount ++;
  if (BlinkCount > 6)
  {
    blinkLEDs();
    BlinkCount = 0;
    if (BlinkStatus == 0) {
      BlinkStatus = 1;
    }
    else {
      BlinkStatus = 0;
    }
  }
}

void ReadData() {
  pinMode(Data0, INPUT_PULLUP);
  pinMode(Data1, INPUT_PULLUP);
  pinMode(Data2, INPUT_PULLUP);
  pinMode(Data3, INPUT_PULLUP);
  pinMode(Data4, INPUT_PULLUP);
  pinMode(Data5, INPUT_PULLUP);
  pinMode(Data6, INPUT_PULLUP);
  pinMode(Data7, INPUT_PULLUP);
}

void WriteData() {
  pinMode(Data0, OUTPUT);
  pinMode(Data1, OUTPUT);
  pinMode(Data2, OUTPUT);
  pinMode(Data3, OUTPUT);
  pinMode(Data4, OUTPUT);
  pinMode(Data5, OUTPUT);
  pinMode(Data6, OUTPUT);
  pinMode(Data7, OUTPUT);
}
void DecoderOut(byte number)
{
  for (int i = 0; i < 4; i ++)
  {

    digitalWrite(DecoderPins[i], BCD[number][i]);
  }
  delay(2);
  digitalWrite(LEDwrite, LOW);
  delay(2);
  digitalWrite(LEDwrite, HIGH);

}
void SelectLedRow(byte number)
{
  for (int i = 0; i <= 4; i ++)
  {
    if (bitRead(number, 1) == 1) {
      digitalWrite(DecoderPins[i], HIGH);
    } else {
      digitalWrite(DecoderPins[i], LOW);
    }
  }
}
void setLight(int pin, byte val) {
  byte arrayElem = int((pin) / BITSB);             // which element of the ledArray is pin in
  byte byteElem  = (pin - (arrayElem * BITSB));  // and which bit in that byte is the pin
  //LEDArray[arrayElem] |= (val << byteElem);          // zero vals require a two-step process,
  //if(val == 0) {                                     // first we set them to a one and then
  //  ledArray[arrayElem] ^= (1 << byteElem);          // toggle them
  //}
  byte temp1 = LEDArray[arrayElem];
  bitWrite(temp1, byteElem, val);
  LEDArray[arrayElem] = temp1;
}
void blinkLEDs()
{
  for (int i = 0; i < LedDATABITS; i++) {
    if (BlinkLEDArray[i] == 1) {
      if (BlinkStatus == 1) {
        LEDArray[i] = 0;
      }
      else {
        LEDArray[i] = 1;
      }
      int LEDSelRow = 0;
      LEDSelRow = i / 8; //find row number - this rounds automatically
      //SelectLedRow(LEDSelRow);
      int LedSelCol = 0;
      LedSelCol = (i % 8); //use MOD to find bit position
      digitalWrite(buttread, HIGH);
      WriteData();
      for (int i = 0; i < 8; i++) {
        digitalWrite(rowPins[i] , LEDArray[(LEDSelRow * 8) + i]);
      }
      delay(1);
      DecoderOut(LEDSelRow);

    }
  }
}
void readAnalogValues()
{
  int AnalogCurrentValues [14];
  ReadData();
  for (int pot = 0; pot < 15; pot++)
  {
    //int area = AnalogIn(pot);
    //if new value <> old value, send itto serial
    byte currentPotValue = AnalogIn(pot);
    int diff = abs(currentPotValue - AnalogPreviousValues[pot]);
    //need high res for t-bar so don't care about jitter
    if ((pot == 2) && (diff > 0)) {
      AnalogPreviousValues[pot] = currentPotValue;
      String action = "Pot";
      String echoMsg = action + pot + ',' + currentPotValue;
      Firmata.sendString(echoMsg.c_str());
    }
    if ((pot != 2) && (diff > 1))
    {
      AnalogPreviousValues[pot] = currentPotValue;
      String action = "Pot";
      String echoMsg = action + pot + ',' + currentPotValue;
      Firmata.sendString(echoMsg.c_str());
    }
  }
}
byte AnalogIn(int number)
{
  for (int i = 0; i < 4; i ++)
  {
    digitalWrite(DecoderPins[i], BCD[number][i]);
  }
  delay(1);
  digitalWrite(AnalConv, LOW);
  delay(1);
  digitalWrite(AnalConv, HIGH);
  delay(1);
  digitalWrite(AnalRead, LOW);
  //read all 8 bits and write value to array of the pot number
  byte inByte = 0;
  for (int r = 0; r < 8; r++)
  {
    bitWrite(inByte, r, digitalRead(rowPins[r]));
  }
  digitalWrite(AnalRead, HIGH);
  //return value as int
  return inByte;
}

Après son fonctionnement, je ferais le ménage dans la classe.

 

En espérant, que ma demande ne soit pas trop complexe.

 

Dans l'attente de vous lire.

 

Cordialement,

 

Vincent D.



#22 Mike118

Mike118

    Staff Robot Maker

  • Administrateur
  • PipPipPipPipPip
  • 8 112 messages
  • Gender:Male
  • Location:Anglet
  • Interests:Robotique, Entrepreneuriat, Innovation, Programmation, Résolution de problème, Recherche de solutions, Mécanique, Electronique, Créer, Concevoir

Posté 29 juillet 2018 - 03:16

avant de se plonger dans le code pour comprendre ce qui est fait peux tu explicité : 

 

Qu'est ce que c'est censé faire quand tu changes les valeurs digitales / qu'est ce que ça fait de différent par rapport à ce que c'est censé faire ? 


Si mon commentaire vous a plus laissez nous un avis  !  :thank_you:

Nouveau sur Robot Maker ? 

Jetez un oeil aux blogs, aux tutoriels, aux ouvrages, au robotscope  aux articles,  à la boutique  et aux différents services disponible !
En attendant qu'une bibliothèque de fichiers 3D soit mise en place n'hésitez pas à demander si vous avez besoin du fichier 3D d'un des produits de la boutique... On l'a peut être ! 

 

Les réalisations de Mike118  

 

 

 


#23 vins86

vins86

    Nouveau membre

  • Membres
  • 27 messages

Posté 29 juillet 2018 - 05:59

Bonjour Mike,

 

Quand j'appuie sur un  bouton le keypad ne me retourne pas de valeur et ne fonctionne pas du tout, j'ai l'impression.

 

Même, en faisant juste ceci:

#include <Keypad.h>

const byte ROWS = 8;
const byte COLS  = 10;
char keys[ROWS][COLS] = {
  {'1','9','h','p','x','G','O','W','$','>'},
  {'2','a','i','q','y','H','P','X','%','?'},
  {'3','b','j','r','A','I','Q','Y','^','/'},
  {'4','c','k','s','B','J','R','Z','&','-'},
  {'5','d','l','t','C','K','S','~','*','['},
  {'6','e','m','u','D','L','T','!','(',']'},
  {'7','f','n','v','E','M','U','@',')',';'},
  {'8','g','o','w','F','N','V','#','<','+'}
};
byte rowPins[ROWS] = {32,30,28,24,23,27,31,35};
byte colPins[COLS] = {1,3,4,5,6,8,9,10,11,12}; //not actually using these pins, just binary conversion to drive encoder

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void keypadEvent(KeypadEvent key){
    String echoMsg; 
    String action;    
    switch (keypad.getState()){
      case PRESSED:{
        action = "Down,";
        echoMsg = action+key;
        Serial.println(key);
        break;
      }
      case HOLD:{
        action = "Hold,";
        echoMsg = action+key;
        Serial.println(key);
        break;
      }
    }
}

void setup(){
  Serial.begin(9600);
}

void loop(){
  char key = keypad.getKey();

  if (key != NO_KEY){
    Serial.println(key);
  }
} 

Cordialement,

 

Vincent D



#24 Mike118

Mike118

    Staff Robot Maker

  • Administrateur
  • PipPipPipPipPip
  • 8 112 messages
  • Gender:Male
  • Location:Anglet
  • Interests:Robotique, Entrepreneuriat, Innovation, Programmation, Résolution de problème, Recherche de solutions, Mécanique, Electronique, Créer, Concevoir

Posté 30 juillet 2018 - 04:07

Comment est câblé le key pad ? 

 

Si tu remplace le : 

 

if (key != NO_KEY){
Serial.println(key);
}

 

par 

 

 

if (key != NO_KEY){

Serial.println(key);
}

else {

Serial.println("No key");

}

 

tu obtiens bien l'arduino qui te spam avec " No key " ? 


Si mon commentaire vous a plus laissez nous un avis  !  :thank_you:

Nouveau sur Robot Maker ? 

Jetez un oeil aux blogs, aux tutoriels, aux ouvrages, au robotscope  aux articles,  à la boutique  et aux différents services disponible !
En attendant qu'une bibliothèque de fichiers 3D soit mise en place n'hésitez pas à demander si vous avez besoin du fichier 3D d'un des produits de la boutique... On l'a peut être ! 

 

Les réalisations de Mike118  

 

 

 


#25 vins86

vins86

    Nouveau membre

  • Membres
  • 27 messages

Posté 03 août 2018 - 04:31

Bonjour, 

 

Après un moment d'absence, me revoilà.

 

Déjà, je souhaiterais vous informer que mon projet avance très bien, je récupère les touches avec un programme un sale.

 

Je souhaite maintenant, découper le projet en plusieurs classes; pour les potentiomètres, j'ai eu aucun problème.

 

Mais encore un problème au niveau du keypad.

 

Voici les erreurs:

Detecting libraries used...
"C:\Users\DPCLive\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR   "-IC:\Users\DPCLive\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\DPCLive\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "C:\Users\DPCLive\AppData\Local\Temp\arduino_build_975374\sketch\GVG100.ino.cpp" -o "nul"
"C:\Users\DPCLive\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR   "-IC:\Users\DPCLive\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\DPCLive\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "-IC:\Users\DPCLive\Documents\Arduino\libraries\Keypad" "C:\Users\DPCLive\AppData\Local\Temp\arduino_build_975374\sketch\GVG100.ino.cpp" -o "nul"
"C:\Users\DPCLive\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR   "-IC:\Users\DPCLive\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\DPCLive\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "-IC:\Users\DPCLive\Documents\Arduino\libraries\Keypad" "-IC:\Users\DPCLive\Documents\Arduino\libraries\Potentiometre" "C:\Users\DPCLive\AppData\Local\Temp\arduino_build_975374\sketch\GVG100.ino.cpp" -o "nul"
"C:\Users\DPCLive\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR   "-IC:\Users\DPCLive\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\DPCLive\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "-IC:\Users\DPCLive\Documents\Arduino\libraries\Keypad" "-IC:\Users\DPCLive\Documents\Arduino\libraries\Potentiometre" "-IC:\Users\DPCLive\Documents\Arduino\libraries\Touche" "C:\Users\DPCLive\AppData\Local\Temp\arduino_build_975374\sketch\GVG100.ino.cpp" -o "nul"
Using cached library dependencies for file: C:\Users\DPCLive\Documents\Arduino\libraries\Keypad\Keypad.cpp
Using cached library dependencies for file: C:\Users\DPCLive\Documents\Arduino\libraries\Keypad\utility\Key.cpp
UsCompiling libraries...
Compiling library "Keypad"
Utilisation du fichier déjà compilé : C:\Users\DPCLive\AppData\Local\Temp\arduino_build_975374\libraries\Keypad\Keypad.cpp.o
Utilisation du fichier déjà compilé : C:\Users\DPCLive\AppData\Local\Temp\arduino_build_975374\libraries\Keypad\utility\Key.cpp.o
Compiling library "Potentiometre"
Utilisation du fichier déjà compilé : C:\Users\DPCLive\AppData\Local\Temp\arduino_build_975374\libraries\Potentiometre\Potentiometre.cpp.o
Compiling library "Touche"
"C:\Users\DPCLive\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR   "-IC:\Users\DPCLive\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\DPCLive\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "-IC:\Users\DPCLive\Documents\Arduino\libraries\Keypad" "-IC:\Users\DPCLive\Documents\Arduino\libraries\Potentiometre" "-IC:\Users\DPCLive\Documents\Arduino\libraries\Touche" "C:\Users\DPCLive\Documents\Arduino\libraries\Touche\Touche.cpp" -o "C:\Users\DPCLive\AppData\Local\Temp\arduino_build_975374\libraries\Touche\Touche.cpp.o"
In file included from C:\Users\DPCLive\Documents\Arduino\libraries\Touche\Touche.cpp:12:0:

C:\Users\DPCLive\Documents\Arduino\libraries\Touche\Touche.cpp:15:36: error: 'keys' was not declared in this scope

 Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, 8, 10);

                                    ^

C:\Users\DPCLive\Documents\Arduino\libraries\Keypad/Keypad.h:78:31: note: in definition of macro 'makeKeymap'

 #define makeKeymap(x) ((char*)x)

                               ^

C:\Users\DPCLive\Documents\Arduino\libraries\Touche\Touche.cpp:15:43: error: 'rowPins' was not declared in this scope

 Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, 8, 10);

                                           ^

C:\Users\DPCLive\Documents\Arduino\libraries\Touche\Touche.cpp:15:52: error: 'colPins' was not declared in this scope

 Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, 8, 10);

                                                    ^

C:\Users\DPCLive\Documents\Arduino\libraries\Touche\Touche.cpp: In member function 'void Touche::Init()':

C:\Users\DPCLive\Documents\Arduino\libraries\Touche\Touche.cpp:32:37: error: invalid use of non-static member function

  keypad.addEventListener(keypadEvent);

                                     ^

Utilisation de la bibliothèque Keypad prise dans le dossier : C:\Users\DPCLive\Documents\Arduino\libraries\Keypad (legacy)
Utilisation de la bibliothèque Potentiometre prise dans le dossier : C:\Users\DPCLive\Documents\Arduino\libraries\Potentiometre (legacy)
Utilisation de la bibliothèque Touche prise dans le dossier : C:\Users\DPCLive\Documents\Arduino\libraries\Touche (legacy)
exit status 1
Erreur de compilation pour la carte Arduino/Genuino Mega or Mega 2560

Voici le fichier Touche.cpp : 


#if defined(ARDUINO) && ARDUINO >= 100
  #include "Arduino.h"
#else
  #include "WProgram.h"
#endif


#include <Keypad.h>
#include <Touche.h>

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, 8, 10);

Touche::Touche(){}
void Touche::Init(){
  
  pinMode(LEDwrite, OUTPUT);
  digitalWrite(LEDwrite, HIGH);
  pinMode(buttread, OUTPUT);
  digitalWrite(buttread, HIGH);
  pinMode(W0, OUTPUT);
  pinMode(W1, OUTPUT);
  pinMode(W2, OUTPUT);
  pinMode(W3, OUTPUT);
    for(int number =0;number<=11; number ++)
    {
      DecoderOut(number);
    }
	keypad.addEventListener(keypadEvent);
}

void Touche::keypadEvent(KeypadEvent key){
    String echoMsg; 
    String action;    
    switch (keypad.getState()){
      case PRESSED:{
        action = "Down,";
        echoMsg = action+key;
        //Firmata.sendString(echoMsg.c_str());
        break;
      }
      case HOLD:{
        action = "Hold,";
        echoMsg = action+key;
        //Firmata.sendString(echoMsg.c_str());
        break;
      }
    }
}

void Touche::DecoderOut(byte number)
{
	  for(int i =0;i<4; i ++)
		{

			digitalWrite(DecoderPins[i],BCD[number][i]);
		}
      delay(2);
      digitalWrite(LEDwrite, LOW);
      delay(2);
      digitalWrite(LEDwrite, HIGH);
    
}

Et le fichier .h :

/*
Copyright 2018 Vincent DESREUMAUX
*/


/**
  Version 1.0.0
**/


#ifndef Touche_h
#define Touche_h

#if defined(ARDUINO) && ARDUINO >= 100
  #include "Arduino.h"
#else
  #include "WProgram.h"
#endif


#define BITSB 8
#define TOLERANCE 10
#define  Data0       32          //15
#define  Data1       30          //16
#define  Data2       28          //17
#define  Data3       24          //19
#define  Data4       23          //
#define  Data5       27          //
#define  Data6       31          //
#define  Data7       35          //
#define  W0          40          //
#define  W1          38          //
#define  W2          36          //
#define  W3          34          //
#define  AnalRead    33          //5
#define  AnalConv    29          //7
#define  LEDwrite    26          //18
#define  buttread    22          //20
#define  Display     25           //9


class Touche
{
	public:
	  int numTouche;
	  int valeurTouche;
	
	private:
	  int DecoderPins[4] = {40,38,36,34};
		byte BCD[16][4] = {{0, 0, 0, 0},
	  {1, 0, 0, 0},
	  {0, 1, 0, 0},
	  {1, 1, 0, 0},
	  {0, 0, 1, 0},
	  {1, 0, 1, 0},
	  {0, 1, 1, 0},
	  {1, 1, 1, 0},
	  {0, 0, 0, 1},
	  {1, 0, 0, 1},
	  {0, 1, 0, 1},
	  {1, 1, 0, 1},
	  {0, 0, 1, 1},
	  {1, 0, 1, 1},
	  {0, 1, 1, 1},
	  {1, 1, 1, 1}
	}; //BCD code
	
	char keys[8][10] = {
	  {'1','9','h','p','x','G','O','W','$','>'},
	  {'2','a','i','q','y','H','P','X','%','?'},
	  {'3','b','j','r','A','I','Q','Y','^','/'},
	  {'4','c','k','s','B','J','R','Z','&','-'},
	  {'5','d','l','t','C','K','S','~','*','['},
	  {'6','e','m','u','D','L','T','!','(',']'},
	  {'7','f','n','v','E','M','U','@',')',';'},
	  {'8','g','o','w','F','N','V','#','<','+'}
	};
	
	byte rowPins[8] = {32,30,28,24,23,27,31,35};
	byte colPins[10] = {2,3,4,5,6,8,9,10,11,12}; //not actually using these pins, just binary conversion to drive encoder


  public:
    Touche();
	void Init();
	void keypadEvent(KeypadEvent key);
	void DecoderOut(byte number);
	
/********************************
 * General Getter/Setter methods
 ********************************/
	public:
	int getNumTouche();
	void setNumTouche(int pnumTouche);
	int getValeurTouche();
	void setValeurTouche(int pvaleurTouche);
	
	
};

#endif


En espérant que vous puissiez m'aiguiller dans ces erreurs.

 

Cordialement,

 

Vincent D



#26 vins86

vins86

    Nouveau membre

  • Membres
  • 27 messages

Posté 04 août 2018 - 08:17

Du coup, problème résolu. tout fonctionne à la perfection.



#27 Mike118

Mike118

    Staff Robot Maker

  • Administrateur
  • PipPipPipPipPip
  • 8 112 messages
  • Gender:Male
  • Location:Anglet
  • Interests:Robotique, Entrepreneuriat, Innovation, Programmation, Résolution de problème, Recherche de solutions, Mécanique, Electronique, Créer, Concevoir

Posté 04 août 2018 - 10:55

Quel était le problème du coup ? 


Si mon commentaire vous a plus laissez nous un avis  !  :thank_you:

Nouveau sur Robot Maker ? 

Jetez un oeil aux blogs, aux tutoriels, aux ouvrages, au robotscope  aux articles,  à la boutique  et aux différents services disponible !
En attendant qu'une bibliothèque de fichiers 3D soit mise en place n'hésitez pas à demander si vous avez besoin du fichier 3D d'un des produits de la boutique... On l'a peut être ! 

 

Les réalisations de Mike118  

 

 

 


#28 vins86

vins86

    Nouveau membre

  • Membres
  • 27 messages

Posté 04 août 2018 - 03:04

J'ai mis toutes les variables dans le fichier cpp. et plus d'erreur.





Répondre à ce sujet



  



0 utilisateur(s) li(sen)t ce sujet

0 members, 0 guests, 0 anonymous users