Bonjour, dans le cadre de mon projet de terminale STI2D option SIN je dois créer un GPS .
J'ai trouver un tuto assez simple m'expliquant comment récupérer les coordonnées de mon Grove - GPS que j'envois sur une carte arduino qui ensuite envoie les info au PC sur le logiciel U center .
J'ai réussis à récupérer les coordonnées mais j'aimerais comprendre le code que le site m'as donné mais je suis débutant dans le domaine du code .
Quelqu'un aurait la gentillesse de me décrire le code suivant :
#include <SoftwareSerial.h>
SoftwareSerial SoftSerial(2, 3);
unsigned char buffer[64]; // buffer array for data receive over serial port
int count=0; // counter for buffer array
void setup()
{
SoftSerial.begin(9600); // the SoftSerial baud rate
Serial.begin(9600); // the Serial port of Arduino baud rate.
}
void loop()
{
if (SoftSerial.available()) // if date is coming from software serial port ==> data is coming from SoftSerial shield
{
while(SoftSerial.available()) // reading data into char array
{
buffer[count++]=SoftSerial.read(); // writing data into array
if(count == 64)break;
}
Serial.write(buffer,count); // if no data transmission ends, write buffer to hardware serial port
clearBufferArray(); // call clearBufferArray function to clear the stored data from the array
count = 0; // set counter of while loop to zero
}
if (Serial.available()) // if data is available on hardware serial port ==> data is coming from PC or notebook
SoftSerial.write(Serial.read()); // write it to the SoftSerial shield
}
void clearBufferArray() // function to clear buffer array
{
for (int i=0; i<count;i++)
{
buffer*=NULL;*
- } // clear all index of array with command NULL*
}
Pour plus d'info sur le tuto que j'ai utiliser voici le site :
Grove - GPS | Seeed Studio Wiki
Merci d'avance pour votre aide, bonne journée