des news, les vérins électriques ne devraient pas tarder à arriver, en attendant , je me penche(beaucoup) sur le code ,toujours avec la carte Arduino UNO et une carte motoshield v1.
j'ai réalisé un capteur avec 3 photorésistances,montées à 120° les unes des autres et donc il y aura les 2 vérins.
petit problème sur le code , mais j'avance , hier les moteurs ne fonctionnaient pas, aujourd'hui ça tourne, mais pas comme je veux,
1 s marche - 1s arrêt et continuellement, et pour chaque moteur
les cellules réagissent bien à la lumière,sur le sérial monitor, je lis les variations de lumière en fonction de la source, mais il doit manquer quelque chose,un lien entre les 2 pour que ça fonctionne bien, je cherche, je n'y connais pas grand chose, voir même ,presque rien, mais c'est très intéressant .
je mets en dessous mon code, je suis plus constructeur que programmateur, je précise, mon tracker 1 axe fonctionne très bien, le panneau solaire de 50 w me sort du 3A, à 11 h au soleil de Décembre. je pense avoir encore de meilleur résultat avec un tracker 2 axes.
merci d'avance de vos conseils,
le code en question:
/*
traque le soleil en utilisant la tension de 3 LDRs
*/
// These constants won't change:
const int sensorPinA0 = A0; // pin that the Bottom/Left sensor is attached to
const int sensorPinA1 = A1; // pin that the Right sensor is attached to
const int sensorPinA2 = A2; // pin that the Top sensor is attached to
//const int pmotorPinA0 = 13; // pin that the pan motor relay is attached to
//const int pmotorPinA1 = 12; // pin that the pan motor relay is attached to
//const int tmotorPinA0 = 11; // pin that the tilt motor relay is attached to
//const int tmotorPinA2 = 8; // pin that the tilt motor relay is attached to
// variables:
int sensorValueA0 = 0; // Bottom/Left photoresistor
int sensorValueA1 = 0; // Right photoresistor
int sensorValueA2 = 0; // Top photoresistor
int panDelay = 1000; // The amount of time the pan and tilt motor will run
int tiltDelay = 1000; // this will vary depending on motor and drive train
void setup() {
//initialize the serial port:
Serial.begin(9600);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
// Send debugging information via the Serial monitor
Serial.begin(9600);
//Assign and set motor driver pins to low
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
pinMode(12, OUTPUT);
digitalWrite(12, LOW);
pinMode(11, OUTPUT);
digitalWrite(11, LOW);
pinMode(8, OUTPUT);
digitalWrite(8, LOW);
}
void loop() {
// read the sensor:
sensorValueA0 = analogRead(sensorPinA0);
sensorValueA1 = analogRead(sensorPinA1);
sensorValueA2 = analogRead(sensorPinA2);
// Compare sensor readings and drive pan motor left or right
// If the sensor values are equal (what we want) it will skip adjusting the pan motor
// Pan Right
if (sensorValueA0 > sensorValueA1){
digitalWrite(13, HIGH);
delay(panDelay);
digitalWrite(13, LOW);
}
// Pan Left
if (sensorValueA0 < sensorValueA1){
digitalWrite(12, HIGH);
delay(panDelay);
digitalWrite(12, LOW);
}
// Compare sensor readings and drive tilt motor up or down
// If the sensor values are equal (what we want) it will skip adjusting the tilt motor
// Tilt Down
if (sensorValueA0 > sensorValueA2){
digitalWrite(11, HIGH);
delay(tiltDelay);
digitalWrite(11, LOW);
}
// Tilt Up
if (sensorValueA0 < sensorValueA2){
digitalWrite(8, HIGH);
delay(tiltDelay);
digitalWrite(8, LOW);
}
//Print debugging information
Serial.print("Left/Bottom reading = ");
Serial.println(sensorValueA0); // the left/bottom sensor analog reading
Serial.print("Right reading = ");
Serial.println(sensorValueA1); // the right sensor analog reading
Serial.print("Top reading = ");
Serial.println(sensorValueA2); // the top sensor analog reading
delay(1000);
}