Offline
Newbie
Karma: 0
Posts: 11
|
 |
« on: February 28, 2011, 11:29:29 am » |
est-il possible, de faire défiler du texte dans l'arduino ??? Si oui quoi ajouter dans la ligne ci dessous ?
void setup() { // variables initialization ulEndTime = 0; ulCurrentTime = 0; ulPreviousTime = 0; ulDuration = 0; ulUserAction = 0; ulPreviousRemainingTime = 0; bTimerIsRunning = false;
// display initialization lcd.init(); lcd.clear(); lcd.cursorTo(1, 0); lcd.printIn(" choisir duree");
Merci
|
|
|
|
« Last Edit: February 28, 2011, 11:34:28 am by F8FFP »
|
Logged
|
|
|
|
|
Celtic Kingdom
Offline
Sr. Member
Karma: 2
Posts: 455
hard oui no!!!
|
 |
« Reply #1 on: February 28, 2011, 12:12:07 pm » |
Bonjour F8FFP, Avec la librairie LiquidCrystalScroll ? ^.^ -> void loop() { // scroll 13 positions (string length) to the left // to move it offscreen left: for (int positionCounter = 0; positionCounter < 13; positionCounter++) { // scroll one position left: lcd.scrollDisplayLeft(); // wait a bit: delay(150); }
// scroll 29 positions (string length + display length) to the right // to move it offscreen right: for (int positionCounter = 0; positionCounter < 29; positionCounter++) { // scroll one position right: lcd.scrollDisplayRight(); // wait a bit: delay(150); } // scroll 16 positions (display length + string length) to the left // to move it back to center: for (int positionCounter = 0; positionCounter < 16; positionCounter++) { // scroll one position left: lcd.scrollDisplayLeft(); // wait a bit: delay(150); } // delay at the end of the full loop: delay(1000);
}
|
|
|
|
« Last Edit: February 28, 2011, 12:14:21 pm by ekaki »
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 11
|
 |
« Reply #2 on: February 28, 2011, 12:43:12 pm » |
Mon projet: minuterie pour la cuisine avec un message d'accueil défilant /le minuteur/ et faire clignoter une LED toutes les 15S dès la mise en route d'un programme de cuisson/ et insérer un buzzer pour signaler la fin du programme
j'ai entré ceci pour voir déjà côté texte dès la mise en route de l'ARDUINO:
#include <LCD4Bit_mod.h> // librairie à inclure pour prendre en charge l'afficheur LCD
LCD4Bit_mod lcd = LCD4Bit_mod(2); // déclaration d'un objet de type LCD void setup() // le setup s'effectue une seule fois à la mise sous tension { lcd.init(); // mise en marche du LCD lcd.clear(); // on efface l'écran des fois qu'il reste du chni lcd.printIn("Bonjour"); delay(5000); // attendre 5000 millisecondes lcd.clear(); // on efface l'écran à la fin }
void loop() // une fois le setup terminé, loop s'éffectue en boucle sans fin { // ne fait rien }
boucle void () { / / 13 positions de défilement (longueur de la chaîne) vers la gauche / / Pour déplacer hors de l'écran qu'il a laissé: pour (positionCounter int = 0; positionCounter <13; positionCounter + +) { / / Faire défiler d'une position de gauche: lcd.scrollDisplayLeft (); / / Attendre un peu: retard (150); }
/ / Faire défiler 29 postes (longueur de la chaîne + longueur d'affichage) à droite / / Pour déplacer ce droit hors de l'écran: pour (positionCounter int = 0; positionCounter <29; positionCounter + +) { / / Faire défiler une bonne position: lcd.scrollDisplayRight (); / / Attendre un peu: retard (150); } / / 16 positions de défilement (longueur d'affichage + longueur de chaîne) à gauche / / Pour le ramener au centre: pour (positionCounter int = 0; positionCounter <16; positionCounter + +) { / / Faire défiler d'une position de gauche: lcd.scrollDisplayLeft (); / / Attendre un peu: retard (150); } / / Délai à la fin de la boucle complète: retard (1000);
}
Il me donne ce message d'erreur
conversion before 'void'
et cette ligne est souligné
/ / 13 positions de défilement (longueur de la chaîne) vers la gauche
Je souhaite faire défiler le message d'accueil
Je précise aussi que je suis dans ma toute première configuration avec mon premier ARDUINO.
|
|
|
|
« Last Edit: February 28, 2011, 12:49:58 pm by F8FFP »
|
Logged
|
|
|
|
|
Ales
Offline
Edison Member
Karma: 8
Posts: 1802
Do or DIY
|
 |
« Reply #3 on: February 28, 2011, 01:08:06 pm » |
Ca bug parce qu'il y a un espace entre les deux /, et il ne reconnait pas une ligne de commentaire. Remplace les "/ /" par "//"
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 11
|
 |
« Reply #4 on: March 04, 2011, 09:33:59 am » |
Merci beaucoup !
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 11
|
 |
« Reply #5 on: March 04, 2011, 09:59:00 am » |
Mais je comprends pas comment rajouter une fonction comme par exemple un petit piezo pour envoyer un signal sonore dès le temps de cuisson terminé ou l'ajout d'une led qui clignote dès le le programme et lancé.
Je trouve plusieurs code selon ce que je souhaite ajouter à l'Arduino, mais voilà pour les ajouter dans le fichier de base de la minuterie sa se complique pour moi. j'ai toujours des erreurs d'indiquées.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 11
|
 |
« Reply #6 on: March 04, 2011, 10:33:00 am » |
J'ai donc fais comme ceci
#include <LCD4Bit_mod.h> #include <stdio.h>
#define SMALLSTEP 1 #define BIGSTEP 10 #define MINCONV 60000 #define NUM_KEYS 5
LCD4Bit_mod lcd = LCD4Bit_mod(2); bool bTimerIsRunning; unsigned long ulDuration; unsigned long ulUserAction; unsigned long ulCurrentTime; unsigned long ulPreviousTime; unsigned long ulEndTime; unsigned long ulPreviousRemainingTime; int adc_key_val[5] ={30, 150, 360, 535, 760 }; int adc_key_in; int key=-1; int oldkey=-1;
void setup() { // variables initialization ulEndTime = 0; ulCurrentTime = 0; ulPreviousTime = 0; ulDuration = 0; ulUserAction = 0; ulPreviousRemainingTime = 0; bTimerIsRunning = false;
// display initialization lcd.init(); lcd.clear(); lcd.cursorTo(1, 0); lcd.printIn(" Choisir duree "); } void loop() { error: 'void loop()' previously defined here // scroll 13 positions (string length) to the left // to move it offscreen left: for (int positionCounter = 0; positionCounter < 13; positionCounter++) { // scroll one position left: LCD4Bit_mod lcd = LCD4Bit_mod(2); // wait a bit: delay(150); }
// scroll 29 positions (string length + display length) to the right // to move it offscreen right: for (int positionCounter = 0; positionCounter < 29; positionCounter++) { // scroll one position right: LCD4Bit_mod lcd = LCD4Bit_mod(2); // wait a bit: delay(150); } // scroll 16 positions (display length + string length) to the left // to move it back to center: for (int positionCounter = 0; positionCounter < 16; positionCounter++) { // scroll one position left: LCD4Bit_mod lcd = LCD4Bit_mod(2); // wait a bit: delay(150); } // delay at the end of the full loop: delay(1000);
} void loop() { //récup valeur button delay(80); ulUserAction = GetButtonValue(0); switch (ulUserAction) { case 0 : // right button : +10min ulDuration += BIGSTEP; DisplayRemainingTime(ulDuration); break; case 1 : // up button : +1min ulDuration += SMALLSTEP; DisplayRemainingTime(ulDuration); break; case 2 : // down button : -1min if (ulDuration >= 1) { ulDuration -= SMALLSTEP; } else { ulDuration = 0; } DisplayRemainingTime(ulDuration); break; case 3 : // left button : -10min if (ulDuration >= BIGSTEP) { ulDuration -= BIGSTEP; } else { ulDuration = 0; } DisplayRemainingTime(ulDuration); break; case 4 : // select button if (ulDuration > 0) { bTimerIsRunning = true; ulEndTime = millis() + (ulDuration * MINCONV); } break; } delay(80); // no user action, process countdown if running if (bTimerIsRunning) { ulCurrentTime = millis(); if (ulCurrentTime-ulPreviousTime > 1000) { if (ulEndTime < ulCurrentTime) { // countdown ended DisplayEnd(); } else { // countdown still going DisplayRemainingTime((ulEndTime-ulCurrentTime)/MINCONV); } ulPreviousTime = ulCurrentTime; } } }
void DisplayRemainingTime(unsigned long ulRemainingTime) { if (ulPreviousRemainingTime != ulRemainingTime) { lcd.clear(); lcd.cursorTo(1, 0); lcd.printIn("Duree restante:"); char buffer[16]; sprintf(buffer,"%d minute(s)", ulRemainingTime); // %d pour les variables décimale. (int)temp = 3 et temp1 = 14 lcd.cursorTo(2, 0); lcd.printIn(buffer); ulPreviousRemainingTime = ulRemainingTime; } }
void DisplayEnd() { lcd.clear(); lcd.cursorTo(1, 0); lcd.printIn(" Duree atteinte"); lcd.cursorTo(2, 0); lcd.printIn("Appui sur RESET"); bTimerIsRunning = false; ulCurrentTime = 0; ulEndTime = 0; }
int GetButtonValue(int iAnalogSensor) { adc_key_in = analogRead(iAnalogSensor); //digitalWrite(13, HIGH); key = get_key(adc_key_in); // convert into key press if (key != oldkey) // if keypress is detected { delay(50); // wait for debounce time adc_key_in = analogRead(iAnalogSensor); // read the value from the sensor key = get_key(adc_key_in); // convert into key press if (key != oldkey) { oldkey = key; } } }
// Convert ADC value to key number int get_key(unsigned int input) { int k; for (k = 0; k < NUM_KEYS; k++) { if (input < adc_key_val[k]) { return k; } } if (k >= NUM_KEYS) { k = -1; // No valid key pressed } return k; }
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 44
Arduino rocks
|
 |
« Reply #7 on: March 04, 2011, 10:58:20 am » |
Bonjour,
tu as ce message car tu as 2 fonctions loop dans ton code, la fonction loop correspond à la fonction principale d'un programme Arduino (c'est l'équivalent de la fonction main en C standard) il ne peut y en avoir qu'une.
Serge
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 11
|
 |
« Reply #8 on: March 04, 2011, 11:11:12 am » |
Comme je débute avec Arduino, je ne le savais pas.
Que me propose tu à mettre sur cette ligne ???
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 44
Arduino rocks
|
 |
« Reply #9 on: March 04, 2011, 12:54:17 pm » |
Si tu n'as aucune connaissance en programmation C/C++ et que tu débutes avec Arduino, je te conseil d'abandonner (temporairement) ton projet. Il existe plusieurs kits pour débutant qui te permettrons de faire tes gammes progressivement avec des projets plus simple. Par exemple : Serge
|
|
|
|
|
Logged
|
|
|
|
|
|