Bonjour,
je cherche à savoir comment faire pour que j'éteingne mon module GPS lorsque mon bouton soit à 0 et qu'il s'allume quand mon bouton est à 1.
Savez-vous comment faire ?
Voici mon programme:
# include <SoftwareSerial.h>
# include <Servo.h>
Servo servo1;
int NPOT,POS;
int bouton = 4;
int pos =90;
SoftwareSerial SoftSerial(0, 1);
unsigned char buffer[64];
int count=0;
void setup()
{
SoftSerial.begin(9600);
Serial.begin(9600);
servo1.attach(3);
pinMode(bouton,INPUT);
}
void loop()
{
boolean etatbouton1=digitalRead(bouton);
if (etatbouton1 == 1)
{
for(pos = 0; pos <=180; pos++)
{
servo1.write(pos);
delay(15);
}
for(pos = 180; pos>=0; pos--)
{
servo1.write(pos);
delay(15);
}
if (SoftSerial.available())
{
digitalWrite(SoftSerial, HIGH);
while(SoftSerial.available())
{
buffer[count++]=SoftSerial.read();
if(count == 64)break;
}
Serial.write(buffer,count);
clearBufferArray();
count = 0;
}
if (Serial.available())
SoftSerial.write(Serial.read());
}
else (etatbouton1 == 0);
{
digitalWrite(SoftSerial, LOW);
while(SoftSerial.available())
{
buffer[count--]=SoftSerial.read();
if(count == 0)break;
}
servo1.write(10);
delay(1000);
}
}
void clearBufferArray()
{
for (int i=0; i<count;i++)
{
buffer[ i ]=NULL;
}
}