Skip to content

Commit

Permalink
finish the lidar code with motor driver running at the same time
Browse files Browse the repository at this point in the history
  • Loading branch information
hwii-florescent committed Apr 23, 2024
1 parent 824087e commit 086f84f
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions electrical_code/lidar/lidar_data/lidar_data.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
Servo myservo;
int servo1_pin = 12;
int servo2_pin = 13;
// int motor_pin1 = 6;
// int motor_pin2 = 7;
int motor_pin3 = 6;
int motor_pin4 = 7;
int motor_pin1 = 6;
int motor_pin2 = 7;
int motor_pin3 = 8;
int motor_pin4 = 9;
int pin_input = 2;

const int stepPin = 4;
Expand Down Expand Up @@ -40,8 +40,8 @@ void setup() {

myservo.attach(servo1_pin);
// myservo.attach(servo2_pin);
// pinMode(motor_pin1, OUTPUT);
// pinMode(motor_pin2, OUTPUT);
pinMode(motor_pin1, OUTPUT);
pinMode(motor_pin2, OUTPUT);
pinMode(motor_pin3, OUTPUT);
pinMode(motor_pin4, OUTPUT);
pinMode(pin_input, INPUT);
Expand All @@ -57,18 +57,20 @@ void loop() {
myservo.write(servoAngle);
if (moveArmGo){
Serial.println("Running motor driver");
// digitalWrite(motor_pin1, HIGH);
// digitalWrite(motor_pin2, LOW);
digitalWrite(motor_pin3, LOW);
digitalWrite(motor_pin4, HIGH);
digitalWrite(motor_pin1, LOW);
digitalWrite(motor_pin2, HIGH);
digitalWrite(motor_pin3, HIGH);
digitalWrite(motor_pin4, LOW);
delay(8000);

// Use servo for 120 degrees
myservo.write(120);
delay(1500);

digitalWrite(motor_pin3, HIGH);
digitalWrite(motor_pin4, LOW);
digitalWrite(motor_pin1, HIGH);
digitalWrite(motor_pin2, LOW);
digitalWrite(motor_pin3, LOW);
digitalWrite(motor_pin4, HIGH);
delay(8000);

myservo.write(0);
Expand Down

0 comments on commit 086f84f

Please sign in to comment.