état avant rangement : dernière version ULN2003 (15.01.2024, jamais commitée)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-29 23:18:15 +01:00
co-authored by Claude Opus 5.5
parent 852721ab34
commit ab77927086
+8 -7
View File
@@ -52,7 +52,7 @@ AccelStepper myStepper(4, In1, In3, In2, In4);
int prevDimValue=0; int prevDimValue=0;
int newDimValue=0; int newDimValue=0;
char convBuffer[10]; char convBuffer[10];
const int debattement = 2038 * 5; const int debattement = 2038 * 1.2;
bool homed=false; bool homed=false;
// atmega328p pin 26 -> pc3 -> arduino A3; // atmega328p pin 26 -> pc3 -> arduino A3;
@@ -86,9 +86,8 @@ void setup() {
myStepper.setAcceleration(50.0); myStepper.setAcceleration(50.0);
myStepper.setSpeed(200); myStepper.setSpeed(200);
// myStepper.moveTo(2038); // myStepper.moveTo(2038);
// todo make a homing of stepper motor OR find a way to sensorize where it is
// myStepper.setCurrentPosition(0);
// make a homing of stepper motor
pinMode(homing_pin, INPUT); pinMode(homing_pin, INPUT);
digitalWrite(homing_pin, HIGH); digitalWrite(homing_pin, HIGH);
@@ -185,17 +184,19 @@ void receive(const MyMessage &message) {
newDimValue = atoi(message.getString(convBuffer)); newDimValue = atoi(message.getString(convBuffer));
#ifdef MY_DEBUG #ifdef MY_DEBUG
Serial.print("prevDimValue: "); // Serial.print("prevDimValue: ");
Serial.println(prevDimValue); // Serial.println(prevDimValue);
Serial.print("newDimValue: "); Serial.print("newDimValue: ");
Serial.println(newDimValue); Serial.println(newDimValue);
#endif #endif
if (homed) if (homed)
{ {
// todo instead of 1 revolution (2038) define how much revolution we want to do for full opening (100% of the dimmer in HA) int pos = (debattement / 100) * newDimValue * -1; // turn counter clock wise to go down
if (myStepper.distanceToGo() != 0) {
myStepper.stop();
}
myStepper.setSpeed(400); myStepper.setSpeed(400);
int pos = (debattement / 100) * newDimValue * -1; // turn counter clock wise to go done
myStepper.moveTo(pos); // move the stepper myStepper.moveTo(pos); // move the stepper
} }