Bonjour,
Depuis quelques jours, mon fils s'initie à l'électronique avec le starter kit mega project
Je l'aide (et je kiffe bien, faut l'avouer) mais lors des différentes manipulations pour récupérer les croquis (nous suivons les leçons issues du tutoriel elegoo) il y a systématiquement des erreurs
Je passe par l'IDE arduino téléchargeable sur le site, ma carte (mega 2560) est bien branchée et bien reconnue, la bibliothèque est celle que j'ai téléchargé sur le site arduino.
Je suis sous Windaube 11 Pro
Or donc par exemple je souhaite faire le tuto n°2 "Blink"
modalité 1 :
Croquis
Ajouter 1 fichier
Exemple
01.basic
Blink
et je sélectionne le fichier
Le code s'implémente dans l'IDE
/*
Blink
Turns an LED on for one second, then off for one second, repeatedly.
Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
the correct LED pin independent of which board is used.
If you want to know what pin the on-board LED is connected to on your Arduino
model, check the Technical Specs of your board at:
https://www.arduino.cc/en/Main/Products
modified 8 May 2014
by Scott Fitzgerald
modified 2 Sep 2016
by Arturo Guadalupi
modified 8 Sep 2016
by Colby Newman
This example code is in the public domain.
https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink
*/
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
mais lorsque je le vérifie (ou le téléverse) j'ai le message d'erreur suivant :
Arduino : 1.8.18 (Windows 10), Carte : "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
C:\Users\UTILIS~1\AppData\Local\Temp\untitled1660595638.tmp\sketch_jul30a\Blink.ino: In function 'void setup()':
Blink:26:6: error: redefinition of 'void setup()'
void setup() {
^~~~~
C:\Users\UTILIS~1\AppData\Local\Temp\untitled1660595638.tmp\sketch_jul30a\sketch_jul30a.ino:1:6: note: 'void setup()' previously defined here
void setup() {
^~~~~
C:\Users\UTILIS~1\AppData\Local\Temp\untitled1660595638.tmp\sketch_jul30a\Blink.ino: In function 'void loop()':
Blink:32:6: error: redefinition of 'void loop()'
void loop() {
^~~~
C:\Users\UTILIS~1\AppData\Local\Temp\untitled1660595638.tmp\sketch_jul30a\sketch_jul30a.ino:6:6: note: 'void loop()' previously defined here
void loop() {
^~~~
exit status 1
redefinition of 'void setup()'
Idem lorsque j’applique la solution n°2
lorsque je vais chercher le croquis dans le fichier annexe des tutoriels que j'ai téléchargé sur le site arduino elegoo
...
Je cherche donc sur le forum et je tombe là dessus
/*
Blink
Turns an LED on for one second, then off for one second, repeatedly.
Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
the correct LED pin independent of which board is used.
If you want to know what pin the on-board LED is connected to on your Arduino
model, check the Technical Specs of your board at:
https://www.arduino.cc/en/Main/Products
modified 8 May 2014
by Scott Fitzgerald
modified 2 Sep 2016
by Arturo Guadalupi
modified 8 Sep 2016
by Colby Newman
This example code is in the public domain.
https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink
*/
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for 1 second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for 1 second
}
Ce code fonctionne parfaitement mais je ne trouve pas de différence avec le précédent qui ne fonctionne pas
...
Qu'ai-je mal fait?
Y aurait-il un espace qui traine quelque part sur une erreur de copier/coller de ma part?
d'ailleurs l'IDE est il sensible à ce genre d'erreur?
Et bien évidement c'est pareil sur l'ensemble des tuto téléchargés sur le site et à chaque fois je ne trouve pas de différence entre les 2 codes
Voilà
Merci de m'avoir lu,
Veuillez m'excuser si d'aventure une réponse existe sur ce forum et que je n'ai pas réussi à la trouver