Oshadha Gunasekara
Partner: Justin Kufro
Our interface of communication was through switch actuation. One of the cars would travel forward at a constant speed until a switch was pressed. This actuation resulted in the car stopping for a moment until the second vehicle moved backward. The second car would not travel until its switch was actuated.
Due to the minimalism of our designs as well as the pull/placement of the wires, our vehicles have an obvious side drift to them. That results in a circular movement pattern for both vehicles. This makes it difficult for them to actuate both switches at the same time and maintain continuous communication.
Video
Arduino Code
#define MOT_B1_PIN 5
#define MOT_B2_PIN 6
#define SWITCH_PIN 2
#define LED_PIN 13
void setup() {
// Initialize Switch and LED pins
pinMode(SWITCH_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
// Initialize the stepper driver control pins to output drive mode.
pinMode(MOT_B1_PIN, OUTPUT);
pinMode(MOT_B2_PIN, OUTPUT);
// Start with drivers off, motors coasting.
digitalWrite(MOT_B1_PIN, LOW);
digitalWrite(MOT_B2_PIN, LOW);
}
// https://courses.ideate.cmu.edu/16-223/f2018/text/lib/WheelDrive.html
void set_motor_pwm(int pwm)
{
if (pwm < 0) { // reverse speeds
analogWrite(MOT_B1_PIN, -pwm);
digitalWrite(MOT_B2_PIN, LOW);
} else { // stop or forward
digitalWrite(MOT_B1_PIN, LOW);
analogWrite(MOT_B2_PIN, pwm);
}
}
void loop() {
// read the value from the sensor:
bool switch_val = digitalRead(SWITCH_PIN);
// turn the ledPin on
if (switch_val == HIGH){
set_motor_pwm(0);
delay(1000);
}
else{
set_motor_pwm(100);
}
}
The SolidWorks files can be found here.
Leave a Reply
You must be logged in to post a comment.