IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Arduino Discussion :

Wordclock français avec arduino nano


Sujet :

Arduino

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    bricoleur retraité
    Inscrit en
    Janvier 2024
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : Suisse

    Informations professionnelles :
    Activité : bricoleur retraité

    Informations forums :
    Inscription : Janvier 2024
    Messages : 28
    Par défaut
    Super merci beaucoup, je teste et je vous redit si ça fonctionne

  2. #2
    Membre averti
    Homme Profil pro
    bricoleur retraité
    Inscrit en
    Janvier 2024
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : Suisse

    Informations professionnelles :
    Activité : bricoleur retraité

    Informations forums :
    Inscription : Janvier 2024
    Messages : 28
    Par défaut
    Super merci beaucoup, j'ai toujours le problème du debut lors ce que je rajoute les lignes suivante (carte Nano)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    if (digitalRead(hours_switch) == LOW) {
        hours_offset++;
      }
     
      if (digitalRead(minutes_switch) == LOW) {
        minutes_offset++;
      }

  3. #3
    Membre averti
    Homme Profil pro
    bricoleur retraité
    Inscrit en
    Janvier 2024
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : Suisse

    Informations professionnelles :
    Activité : bricoleur retraité

    Informations forums :
    Inscription : Janvier 2024
    Messages : 28
    Par défaut
    Bonsoir, je n'arrive toujours pas a modifier l'heure et les minutes.
    Je suis en trains d'essayer plusieurs auto pour comprendre le fonctionnement des boutons
    Encore merci de votre aide et une bonne soirée

  4. #4
    Expert confirmé

    Homme Profil pro
    mad scientist :)
    Inscrit en
    Septembre 2019
    Messages
    2 914
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : mad scientist :)

    Informations forums :
    Inscription : Septembre 2019
    Messages : 2 914
    Par défaut
    comment avez vous câblé le bouton ?
    avez vous mis INPUT ou INPUT_PULLUP ?

  5. #5
    Membre averti
    Homme Profil pro
    bricoleur retraité
    Inscrit en
    Janvier 2024
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : Suisse

    Informations professionnelles :
    Activité : bricoleur retraité

    Informations forums :
    Inscription : Janvier 2024
    Messages : 28
    Par défaut
    Bonjour, j'ai branché un bouton sur la borne A6 et l'autre sur la borne A7 et contact avec le GND et j'ai essayé avec les deux possibilités INPUT ou INPUT_PULLUP

  6. #6
    Expert confirmé

    Homme Profil pro
    mad scientist :)
    Inscrit en
    Septembre 2019
    Messages
    2 914
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : mad scientist :)

    Informations forums :
    Inscription : Septembre 2019
    Messages : 2 914
    Par défaut
    Citation Envoyé par Cloclo2400 Voir le message
    Bonjour, j'ai branché un bouton sur la borne A6 et l'autre sur la borne A7 et contact avec le GND et j'ai essayé avec les deux possibilités INPUT ou INPUT_PULLUP

    Si vous avez un Arduino nano les pins A6 et A7 ne peuvent servir que d'entrée analogique. prenez d'autres pins

  7. #7
    Expert confirmé

    Homme Profil pro
    mad scientist :)
    Inscrit en
    Septembre 2019
    Messages
    2 914
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : mad scientist :)

    Informations forums :
    Inscription : Septembre 2019
    Messages : 2 914
    Par défaut
    postez votre code et expliquez exactement le circuit et son alim

  8. #8
    Membre averti
    Homme Profil pro
    bricoleur retraité
    Inscrit en
    Janvier 2024
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : Suisse

    Informations professionnelles :
    Activité : bricoleur retraité

    Informations forums :
    Inscription : Janvier 2024
    Messages : 28
    Par défaut
    Bonjour, je répond avec un peu de retard, Ci-dessous le programme qui fonctionne bien mais je n'arrive pas a modifier l'heure et minutes avec les boutons.
    Pour les boutons j'ai branché sur une borne le CND et l'autre sur la carte arduino (5 et 6) et je ne sait pas ci ce branchement est correcte , faut-il mettre une résistance branché sur le 5v ?




    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    #include <Adafruit_NeoPixel.h>
    #include "RTClib.h"
     
    #define RGBLEDPIN 6
    #define N_LEDS 120
     
    int hours_switch = 5;
    int minutes_switch = 6;
    int hours_offset = 0;
    int minutes_offset = 0;
    int the_hours = 0;
    int the_minutes = 0;
    bool pm = false;
     
    // initialisation module RTC
    RTC_DS3231 rtc;
     
    // initialisation NeoPixel
    Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, RGBLEDPIN, NEO_GRB + NEO_KHZ800);
     
    // luminosité
    int the_brightness = 50;
     
    // couleurs
    uint32_t color_white = strip.Color(255, 255, 255);
     
    // tableau des mots
    int words[31][15] = {
     
      {0, 1, 3, 4, 5}, // #0 / IL EST
     
      {7, 8, 9}, // #1 / UNE
      {11, 12, 13, 14}, // #2 / DEUX
      {25, 26, 27, 28, 29}, // #3 / TROIS
      {19, 20, 21, 22, 23, 24}, // #4 / QUATRE
      {15, 16, 17, 18}, // #5 / CINQ
      {30, 31, 32}, // #6 / SIX
      {35, 36, 37, 38}, // #7 / SEPT
      {41, 42, 43, 44}, // #8 / HUIT
      {56, 57, 58, 59}, // #9 / NEUF
      {51, 52, 53}, // #10 / DIX
      {45, 46, 47, 48}, // #11 / ONZE
     
      {61, 62, 63, 64, 65}, // #12 / HEURE
      {61, 62, 63, 64, 65, 66}, // #13 / HEURES
     
      {86, 87, 88, 89}, // #14 / MIDI
      {68, 69, 70, 71, 72, 73}, // #15 / MINUIT
     
      {100, 101, 102, 103}, // #16 / CINQ (2)
      {90, 91, 92}, // #17 / DIX (2)
      {83, 84, 110, 111, 112, 113, 114}, // #18 / ET QUART
      {94, 95, 96, 97, 98}, // #19 / VINGT
      {94, 95, 96, 97, 98, 99, 100, 101, 102, 103}, // #20 / VINGT CINQ
      {83, 84, 115, 116, 117, 118, 119}, // #21 / ET DEMIE
      {78, 79, 80, 81, 82, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103}, // #22 / MOINS VINGT-CINQ
      {78, 79, 80, 81, 82, 94, 95, 96, 97, 98}, // #23 / MOINS VINGT
      {75, 76, 78, 79, 80, 81, 82, 110, 111, 112, 113, 114}, // #24 / MOINS LE QUART
      {78, 79, 80, 81, 82, 90, 91, 92}, // #25 / MOINS DIX
      {78, 79, 80, 81, 82, 100, 101, 102, 103}, // #26 / MOINS CINQ
     
      {108}, // #27 / 1 POINT
      {107, 108}, // #28 / 2 POINTS
      {106, 107, 108}, // #29 / 3 POINTS
      {105, 106, 107, 108} // #30 / 4 POINTS
     
    };
     
    void setup() {
     
      Serial.begin(9600);
     
      if (!rtc.begin()) {
        Serial.println("Couldn't find RTC");
        Serial.flush();
        abort();
      }
     
      if (rtc.lostPower()) {
        Serial.println("RTC lost power, let's set the time!");
        rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
      }
     
      pinMode(hours_switch, INPUT_PULLUP);
      pinMode(minutes_switch, INPUT_PULLUP);
     
      strip.begin();
      strip.show();
     
      strip.setBrightness(the_brightness);
     
    }
     
    void loop() {
     
     if (digitalRead(hours_switch) == LOW) {
       hours_offset++;
      }
     
     if (digitalRead(minutes_switch) == LOW) {
       minutes_offset++;
     }
     
      strip.clear();
     
      int what_time_is_it[5] = {};
      what_time_is_it[0] = 0; // IL EST
     
      DateTime now = rtc.now();
     
      the_hours = now.hour();
      the_minutes = now.minute();
     
      the_hours += hours_offset;
      the_minutes += minutes_offset;
     
      while (the_minutes > 59) {
        the_minutes -= 60;
        the_hours++;
      }
     
      while (the_hours > 23) {
        the_hours -= 24;
      }
     
      if (the_minutes >= 5 && the_minutes < 10) {
        what_time_is_it[3] = 16; // CINQ (2)
      }
      else if (the_minutes >= 10 && the_minutes < 15) {
        what_time_is_it[3] = 17; // DIX (2)
      }
      else if (the_minutes >= 15 && the_minutes < 20) {
        what_time_is_it[3] = 18; // ET QUART
      }
      else if (the_minutes >= 20 && the_minutes < 25) {
        what_time_is_it[3] = 19; // VINGT
      }
      else if (the_minutes >= 25 && the_minutes < 30) {
        what_time_is_it[3] = 20; // VINGT-CINQ
      }
      else if (the_minutes >= 30 && the_minutes < 35) {
        what_time_is_it[3] = 21; // ET DEMIE
      }
      else if (the_minutes >= 35 && the_minutes < 40) {
        what_time_is_it[3] = 22; // MOINS VINGT-CINQ
      }
      else if (the_minutes >= 40 && the_minutes < 45) {
        what_time_is_it[3] = 23; // MOINS VINGT
      }
      else if (the_minutes >= 45 && the_minutes < 50) {
        what_time_is_it[3] = 24; // MOINS LE QUART
      }
      else if (the_minutes >= 50 && the_minutes < 55) {
        what_time_is_it[3] = 25; // MOINS DIX
      }
      else if (the_minutes >= 55) {
        what_time_is_it[3] = 26; // MOINS CINQ
      }
     
      if (the_minutes >= 35) {
        the_hours++;
      }
     
      if (the_hours > 12) {
        the_hours -= 12;
        pm = true;
      }
      else {
        pm = false;
      }
     
      int the_minutes_last_digit = the_minutes % 10;
     
      switch (the_minutes_last_digit) {
     
        case 1:
        case 6:
          what_time_is_it[4] = 27; // 1 POINT
          break;
     
        case 2:
        case 7:
          what_time_is_it[4] = 28; // 2 POINTS
          break;
     
        case 3:
        case 8:
          what_time_is_it[4] = 29; // 3 POINTS
          break;
     
        case 4:
        case 9:
          what_time_is_it[4] = 30; // 4 POINTS
          break;
     
      }
     
      if (the_hours == 12 && !pm) {
        what_time_is_it[1] = 14; // MIDI
      }
      else if (the_hours == 0 || (the_hours == 12 && pm)) {
        what_time_is_it[1] = 15; // MINUIT
      }
      else {
        what_time_is_it[1] = the_hours;
      }
     
      if (the_hours == 1) {
        what_time_is_it[2] = 12; // HEURE
      }
      else if (the_hours > 1 && the_hours < 12) {
        what_time_is_it[2] = 13; // HEURES
      }
     
      int m = sizeof(words[0]) / sizeof(words[0][0]);
      int n = sizeof(what_time_is_it) / sizeof(what_time_is_it[0]);
     
      for(int j = 0; j < n; j++) {
        for(int i = 0; i < m; i++) {
          strip.setPixelColor(words[what_time_is_it[j]][i], color_white);
        }
      }
     
      strip.show();
     
      delay(500);
     
    }

  9. #9
    Expert confirmé

    Homme Profil pro
    mad scientist :)
    Inscrit en
    Septembre 2019
    Messages
    2 914
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : mad scientist :)

    Informations forums :
    Inscription : Septembre 2019
    Messages : 2 914
    Par défaut
    non pas besoin de résistance en plus car vous avez mis INPUT_PULLUP

    si vous tenez le bouton enfoncé, 2 fois par seconde vous allez augmenter hours_offset ou minutes_offset

    pour voir si vos boutons fonctionnent, vous pouvez extraire le code des boutons

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    const byte hours_switch = 5;
    const byte minutes_switch = 6;
     
    int hours_offset = 0;
    int minutes_offset = 0;
     
     
    void setup() {
      pinMode(hours_switch, INPUT_PULLUP);
      pinMode(minutes_switch, INPUT_PULLUP);
      Serial.begin(115200);
    }
     
    void loop() {
     
      if (digitalRead(hours_switch) == LOW) {
        hours_offset++;
        Serial.print("hours_offset = "); Serial.println(hours_offset); 
      }
     
      if (digitalRead(minutes_switch) == LOW) {
        minutes_offset++;
        Serial.print("minutes_offset = "); Serial.println(minutes_offset); 
      }
     
      delay(500);
     
    }
    ouvrez le terminal série à 115200 bauds et appuyez sur les boutons (ou tenez les appuyés) pour voir les variables évoluées.

    Notez bien qu'elles ne font qu'augmenter... (et au bout d'un moment elles passeront en négatif lors de l'overflow)

  10. #10
    Membre averti
    Homme Profil pro
    bricoleur retraité
    Inscrit en
    Janvier 2024
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : Suisse

    Informations professionnelles :
    Activité : bricoleur retraité

    Informations forums :
    Inscription : Janvier 2024
    Messages : 28
    Par défaut
    Super tout fonctionne comme prévu, un grand merci pour votre aide
    Salutations et une bonne année 2024

+ Répondre à la discussion
Cette discussion est résolue.
Page 2 sur 2 PremièrePremière 12

Discussions similaires

  1. Réponses: 0
    Dernier message: 16/08/2022, 19h05
  2. Réponses: 2
    Dernier message: 04/05/2021, 09h58
  3. Thermocouple avec Arduino Nano v3.0
    Par redui dans le forum Arduino
    Réponses: 13
    Dernier message: 13/12/2016, 12h23
  4. Bug communication serie avec arduino (busy)
    Par Invité dans le forum MATLAB
    Réponses: 2
    Dernier message: 09/07/2012, 09h39
  5. Besoin D'aide Avec TSX NANO
    Par Pedrox dans le forum Automation
    Réponses: 1
    Dernier message: 17/06/2010, 21h40

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo