/*
Grove LED Bar - Level Example
This example will show you how to use setLevel() function of this library.
The setLevel() function illuminates the given number of LEDs from either side.
Syntax setLevel(level)
0 = all LEDs off
5 = 5 LEDs on
10 = all LEDs on
*/
#include <Grove_LED_Bar.h>
const int capteurfsr = A0;
const int bled = 4;
int valeur;
int value;
//BE SURE USE CORRESPONDING DEVICE
//Grove_LED_Bar bar(6, 7, 0, LED_CIRCULAR_24);
//FOR LED_BAR_10
Grove_LED_Bar bar(7, 4, 1, LED_BAR_10); // Clock pin, Data pin, Orientation
void setup() {
// nothing to initialize
bar.begin();
pinMode(bled, OUTPUT);
Serial.begin(9600); //initialisation du moniteur série
}
void loop() {
// Walk through the levels
valeur = analogRead(capteurfsr); //lecture de la valeur de la pression puis elle est sauvegardée dans variable //affichage de la valeur captée sur le moniteur série
value = map(valeur, 0, 1023, 0, 255); //Map valeur 0-1023 en 0-255 (PWM)
Serial.println(value);
if ( (value>0) && (value<=25) ){
bar.setLevel(1);
delay(100);
}
else if ( (value>25) && (value<=50) ){
bar.setLevel(2);
delay(100);
}
else if ((value>50) && (value<=75)){
bar.setLevel(3);
delay(100);
}
else if ((value>75) && (value<=100)){
bar.setLevel(4);
delay(100);
}
else if ((value>100) && (value<=125)){
bar.setLevel(5);
delay(100);
}
else if ((value>125) && (value<=150)){
bar.setLevel(6);
delay(100);
}
else if ((value>150) && (value<=175)){
bar.setLevel(7);
delay(100);
}
else if ((value>200) && (value<=225)){
bar.setLevel(8);
delay(100);
}
else if ((value>225) && (value<=250)){
bar.setLevel(9);
delay(100);
}
else if ((value>250) && (value<=255)){
bar.setLevel(10);
delay(100);
}
else if (value==0) {
bar.setLevel(0);
delay(100);
}
}
C:\Users\XXX\OneDrive\Documents\XXX\SIN\Fichier Arduino\Ledba\LEDBATEST.ino:13:13: error: redefinition of 'const int capteurfsr'
const int capteurfsr = A0;
^~~~~~~~~~
C:\Users\XXXX\OneDrive\Documents\XXX\SIN\Fichier Arduino\Ledba\Ledba.ino:13:11: note: 'const int capteurfsr' previously defined here
const int capteurfsr = A0;
^~~~~~~~~~
C:\Users\XXXXX\OneDrive\Documents\XXXX\SIN\Fichier Arduino\Ledba\LEDBATEST.ino:14:13: error: redefinition of 'const int bled'
const int bled = 4;
^~~~
C:\Users\XXXOneDrive\Documents\XXXX\SIN\Fichier Arduino\Ledba\Ledba.ino:14:11: note: 'const int bled' previously defined here
const int bled = 4;
^~~~
C:\Users\XXXX\OneDrive\Documents\XXX\SIN\Fichier Arduino\Ledba\LEDBATEST.ino:15:7: error: redefinition of 'int valeur'
int valeur;
^~~~~~
C:\Users\XXXX\OneDrive\Documents\XXXX\SIN\Fichier Arduino\Ledba\Ledba.ino:15:5: note: 'int valeur' previously declared here
int valeur;
^~~~~~
C:\Users\XXXX\OneDrive\Documents\XXX\SIN\Fichier Arduino\Ledba\LEDBATEST.ino:16:7: error: redefinition of 'int value'
int value;
^~~~~
C:\Users\XXX\OneDrive\Documents\XXX\SIN\Fichier Arduino\Ledba\Ledba.ino:16:5: note: 'int value' previously declared here
int value;
^~~~~
C:\Users\XXX\OneDrive\Documents\XXX\SIN\Fichier Arduino\Ledba\LEDBATEST.ino:20:18: error: redefinition of 'Grove_LED_Bar bar'
Grove_LED_Bar bar(7, 4, 1, LED_BAR_10); // Clock pin, Data pin, Orientation
^
C:\Users\XXX\OneDrive\Documents\XXX\SIN\Fichier Arduino\Ledba\Ledba.ino:20:15: note: 'Grove_LED_Bar bar' previously declared here
Grove_LED_Bar bar(7, 4, 1, LED_BAR_10); // Clock pin, Data pin, Orientation
^~~
C:\Users\XXX\OneDrive\Documents\XX\SIN\Fichier Arduino\Ledba\LEDBATEST.ino: In function 'void setup()':
C:\Users\XXXX\OneDrive\Documents\XXX\SIN\Fichier Arduino\Ledba\LEDBATEST.ino:22:6: error: redefinition of 'void setup()'
void setup() {
^~~~~
C:\Users\XXX\OneDrive\Documents\XX\SIN\Fichier Arduino\Ledba\Ledba.ino:22:6: note: 'void setup()' previously defined here
void setup() {
^~~~~
C:\Users\lvgeo\OneDrive\Documents\T2D\SIN\Fichier Arduino\Ledba\LEDBATEST.ino: In function 'void loop()':
C:\Users\lvgeo\OneDrive\Documents\T2D\SIN\Fichier Arduino\Ledba\LEDBATEST.ino:29:6: error: redefinition of 'void loop()'
void loop() {
^~~~
C:\Users\XXX\OneDrive\Documents\XX\SIN\Fichier Arduino\Ledba\Ledba.ino:29:6: note: 'void loop()' previously defined here
void loop() {
^~~~
exit status 1
Compilation error: redefinition of 'const int capteurfsr'
Bonjour, ci dessus mon code et mes erreurs. Je ne comprend pas ce qui ne fonctionne pas, pouvez vous m'aider ? merci beaucoup