Bonjour
Je suis nouveau et novice, je viens de m'offrir une carte arduino, un moteur
futaba S3003 et un détecteur de lumière Grove SEN11302P.
en faisant des recherche sur le net j'ai trouvé ce code pour le détecteur de lumière, mais je ne sais pas quoi mettre comme paramètre pour que mon moteur s'arrête la nuit et se remette en marche lorsqu'il fait jour.
j'aimerai savoir aussi comment intégrer ce code avec mon moteur.
auriez vous des liens ?, des tutos ?, des explications ?
Je vous remercie
/*
/* Grove - Light Sensor demo v1.0
*
* signal wire to A0.
* By: http://www.seeedstudio.com
*/
#include <math.h>
const int ledPin=12; //Connect the LED Grove module to Pin12, Digital 12
const int thresholdvalue=10; //The treshold for which the LED should turn on. Setting it lower will make it go on at more light, higher for more darkness
float Rsensor; //Resistance of sensor in K
void setup() {
Serial.begin(9600); //Start the Serial connection
pinMode(ledPin,OUTPUT); //Set the LED on Digital 12 as an OUTPUT
}
void loop() {
int sensorValue = analogRead(0);
Rsensor=(float)(1023-sensorValue)*10/sensorValue;
if(Rsensor>thresholdvalue)
{
digitalWrite(ledPin,HIGH);
}
else
{
digitalWrite(ledPin,LOW);
}
Serial.println("the analog read data is ");
Serial.println(sensorValue);
Serial.println("the sensor resistance is ");
Serial.println(Rsensor,DEC);//show the ligth intensity on the serial monitor;
delay(1000);
}