For our project, we decided to make two systems interact with each other. Initially, we had plans to use 3 systems interacting with each other. However, due to being unable to run a motor driver, we stuck to 2 systems and the third was being manipulated by us.
The first system consists of a pusher arm(a pencil) attached to a servo with a photoreflector in one of the braces. The other system has a a rectangular surface attached to a servo, as well as another photoreflector in its body. It is supported by a base of three legs, and will be referred to as the ‘faller’.
These two systems interact in the following way- Once the photoreflector sense the faller the pusher arm activates and tries to push the faller and make it fall. Meanwhile, the photoreflector in the faller senses the pusher arm coming towards it and at a certain threshold, the servo activate and the surface rotates to dodge the pusher. This keeps on repeating until the faller ends up falling. The top of the faller is attached to a string, which goes through braces acting as a pulley, and then to a motor. In the case that the faller falls, the motor pulls the faller back up by coiling up the string. However, since we were unable to make the motor run through the driver, we had to manually pull the faller back up. To ensure that the faller comes back up to the same position, two legs are taped to the ground.
Here is the Arduino code for the pusher-
#include <Servo.h> const int IN_PIN = A3; const int OUT_PIN = 7; const int initial_angle = 5; const int final_angle = 90; const int delay_time = 1000; const int threshold = 935; Servo s; void setup() { pinMode(IN_PIN,INPUT); s.attach(7); s.write(initial_angle); Serial.begin(9600); } void loop() { int value = analogRead(IN_PIN); Serial.println(value); while(analogRead(IN_PIN) <= threshold){ delay(500); s.write(final_angle); delay(500); s.write(initial_angle); delay(5000); Serial.println(analogRead(IN_PIN)); } }
And here is the Arduino code for the faller-
#include <Servo.h> const int IN_PIN = A3; const int OUT_PIN = 7; const int initial_angle = 0; const int final_angle = 75; const int delay_time = 1000; const int threshold = 750; Servo s; void setup() { pinMode(IN_PIN, INPUT); s.attach(7); s.write(initial_angle); Serial.begin(9600); } void loop() { Serial.println(analogRead(IN_PIN)); while(analogRead(IN_PIN) <= threshold){ s.write(final_angle);] delay(delay_time); s.write(initial_angle); } }
Leave a Reply
You must be logged in to post a comment.