Bonsoir,
Mon projet consiste à peser sur un bouton et faire fonctionner le servo pour qu’il se rende à un certain angle. Une fois rendu à cet angle, une lumière s’Allumera. Le seul souci est cette erreur de compilation que je reçois lors de la vérification du code. J’ai réinstallé le logiciel et vérifié si j’avais le bon type de carte et programmeur, mais sans succès.
Voici le code :
#include <Servo.h>
Servo servo1;
int pos = 0; // initial position
int button1 = 4; // set the first button to pin 4
int button2 = 2; // set the second button to pin 2
int redLed = 10; // se the red Led to pin 10
int greenLed = 13; // set the green Led to pin 13
void setup()
{
servo1.attach(1); // set the servo to pin 1
pinMode (greenLed, OUTPUT); // declaring the green Led as an output
pinMode (redLed, OUTPUT); // declaring the redLed as an output
}
void loop(){
if(pinMode(button1,INPUT)==HIGH && pinMode(button2,INPUT)==LOW){
servo1.write(180); // go to 180 degrees
delay (15); // wait for the servo to move
digitalWrite (greenLed, HIGH); // set brightness to the green Led
digitalWrite (redLed, LOW); // set no brightness to the red Led
}
if(pinMode (button1,INPUT)==LOW && pinMode(button2,INPUT)==HIGH){
servo1.write(0); // go to 0 degree
delay(15); // wait for the servo to move
digitalWrite(greenLed, LOW); // set no brightness to the green Led
digitalWrite (redLed, HIGH); // set brightness to the red Led
}
}
Voici le message d’erreur :
Arduino:1.8.8 (Windows Store 1.8.19.0) (Windows 10), Carte : “Arduino/Genuino Uno”
In file included from sketch\internet_2_buttons_servo_modif_3.ino.cpp:1:0:
C:\Users\admin\Documents\Arduino\internet_2_buttons_servo_modif_2\internet_2_buttons_servo_modif_3\internet_2_buttons_servo_modif_3.ino: In function ‘void loop()’:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.19.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:40:14: error: invalid operands of types ‘void’ and ‘int’ to binary ‘operator==’
#define HIGH 0x1
^
C:\Users\admin\Documents\Arduino\internet_2_buttons_servo_modif_2\internet_2_buttons_servo_modif_3\internet_2_buttons_servo_modif_3.ino:20:28: note: in expansion of macro ‘HIGH’
if(pinMode(button1,INPUT)==HIGH && pinMode(button2,INPUT)==LOW){
^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.19.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:41:14: error: invalid operands of types ‘void’ and ‘int’ to binary ‘operator==’
#define LOW 0x0
^
C:\Users\admin\Documents\Arduino\internet_2_buttons_servo_modif_2\internet_2_buttons_servo_modif_3\internet_2_buttons_servo_modif_3.ino:20:60: note: in expansion of macro ‘LOW’
if(pinMode(button1,INPUT)==HIGH && pinMode(button2,INPUT)==LOW){
^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.19.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:41:14: error: invalid operands of types ‘void’ and ‘int’ to binary ‘operator==’
#define LOW 0x0
^
C:\Users\admin\Documents\Arduino\internet_2_buttons_servo_modif_2\internet_2_buttons_servo_modif_3\internet_2_buttons_servo_modif_3.ino:27:31: note: in expansion of macro ‘LOW’
if(pinMode (button1,INPUT)==LOW && pinMode(button2,INPUT)==HIGH){
^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.19.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:40:14: error: invalid operands of types ‘void’ and ‘int’ to binary ‘operator==’
#define HIGH 0x1
^
C:\Users\admin\Documents\Arduino\internet_2_buttons_servo_modif_2\internet_2_buttons_servo_modif_3\internet_2_buttons_servo_modif_3.ino:27:62: note: in expansion of macro ‘HIGH’
if(pinMode (button1,INPUT)==LOW && pinMode(button2,INPUT)==HIGH){
^
exit status 1
Erreur de compilation pour la carte Arduino/Genuino Uno
Ce rapport pourrait être plus détaillé avec
l’option “Afficher les résultats détaillés de la compilation”
activée dans Fichier → Préférences.
Je ne comprends tout simplement pas quoi faire pour avancer dans mon code.
Merci d’avance.