é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:
@@ -52,7 +52,7 @@ AccelStepper myStepper(4, In1, In3, In2, In4);
|
||||
int prevDimValue=0;
|
||||
int newDimValue=0;
|
||||
char convBuffer[10];
|
||||
const int debattement = 2038 * 5;
|
||||
const int debattement = 2038 * 1.2;
|
||||
|
||||
bool homed=false;
|
||||
// atmega328p pin 26 -> pc3 -> arduino A3;
|
||||
@@ -86,9 +86,8 @@ void setup() {
|
||||
myStepper.setAcceleration(50.0);
|
||||
myStepper.setSpeed(200);
|
||||
// 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);
|
||||
digitalWrite(homing_pin, HIGH);
|
||||
|
||||
@@ -185,17 +184,19 @@ void receive(const MyMessage &message) {
|
||||
newDimValue = atoi(message.getString(convBuffer));
|
||||
|
||||
#ifdef MY_DEBUG
|
||||
Serial.print("prevDimValue: ");
|
||||
Serial.println(prevDimValue);
|
||||
// Serial.print("prevDimValue: ");
|
||||
// Serial.println(prevDimValue);
|
||||
Serial.print("newDimValue: ");
|
||||
Serial.println(newDimValue);
|
||||
#endif
|
||||
|
||||
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);
|
||||
int pos = (debattement / 100) * newDimValue * -1; // turn counter clock wise to go done
|
||||
myStepper.moveTo(pos); // move the stepper
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user