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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #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); } 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.