Skip to content

Commit

Permalink
debuing
Browse files Browse the repository at this point in the history
  • Loading branch information
loan-mgt committed Apr 2, 2023
1 parent 48522e9 commit 709fddf
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 15 deletions.
25 changes: 12 additions & 13 deletions L9110/HG7881_L9110/HG7881_L9110.ino
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,25 @@ float ki = 0.01;
motor motor1 = motor(ENCA, ENCB, IN1, IN2, 0, 50, 100); // Set upper limit to 100
void setup()
{
Serial.begin(9600);
Serial.begin(115200);


motor1.init(kp, ki, kd);

}
void loop()
{
//Serial.println(motor1.target_reached() );

// Check if the target position is reached

noInterrupts(); // disable interrupts
Serial.print("hello");
Serial.print("hello");
Serial.print("hello");Serial.print("hello");
Serial.print("hello");
interrupts(); // re-enable interrupts
noInterrupts();
Serial.println("hello");
interrupts();


motor1.set_target(target*count);
if (count%2 == 0){
motor1.set_target(0);
}else{
motor1.set_target(target);
}

motor1.start();

while (!motor1.target_reached()) {
Expand All @@ -47,7 +46,7 @@ void loop()
}
delay(1000); // Wait for 1 second
//motor1.turn_off();
motor1.set_target(target);

count++;


Expand Down
38 changes: 38 additions & 0 deletions motorHelp/motorHelp.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// include the library for the encoder
#include <Encoder.h>

// define the pins for the encoder
#define ENC_A 2
#define ENC_B 15

// create an Encoder object
Encoder myEnc(ENC_A, ENC_B);

// define the pins for the motor control
#define MOTOR_1 26
#define MOTOR_2 25

// define the target count
#define TARGET_COUNT 370

void setup() {
// set the motor control pins as outputs
pinMode(MOTOR_1, OUTPUT);
pinMode(MOTOR_2, OUTPUT);
}

void loop() {
// read the encoder count
long count = myEnc.read();

// check if the target count has been reached
if (count < TARGET_COUNT) {
// set the motor speed and direction
digitalWrite(MOTOR_1, HIGH);
digitalWrite(MOTOR_2, LOW);
} else {
// stop the motor
digitalWrite(MOTOR_1, LOW);
digitalWrite(MOTOR_2, LOW);
}
}
8 changes: 6 additions & 2 deletions risingSun/risingSun.ino
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ int doorStaus = 1;
float kp = 8;
float kd = 1;
float ki = 0.01;
motor motor1 = motor(ENCA, ENCB, IN1, IN2, 0, 80, 150); // Set upper limit to 100
motor motor1 = motor(ENCA, ENCB, IN1, IN2, 0, 50, 100); // Set upper limit to 100


void setup() {
Serial.begin(9600);
Serial.begin(115200);
rtc.setTime(1680108200);
while (!Serial);

Expand Down Expand Up @@ -183,9 +183,13 @@ void manageSettingsDoor() {

}
motor1.start();

while (!motor1.target_reached()) {

motor1.start();

}

delay(1000); // Wait for 1 second
motor1.turn_off();

Expand Down

0 comments on commit 709fddf

Please sign in to comment.