DIoT 2023 Skills Dev IV: Working With Motor

Made by Yujin Wu

A display of bus arrival time with Servo

Created: November 30th, 2023

0

Product

The product I wish to create is an installation that can provide a visual display of the estimated time for the next bus arrival. As a habitual last-minute person who tends to multitask in the morning, I find it challenging to prepare my lunch bento box while also checking Google Maps for the upcoming bus schedule. Therefore, I have identified three key time intervals for catching the bus:

t < 10 min & t > 5 min: Start packing the school bag (The bus slowly move towards the bus stop)

t <= 5 min & t >= 3 min: Leave the house to walk to bus stop

t < 3 min: It is impossible to catch this bus; wait for the next one. 

0

Process


While deliberating on which motor to use—servo or solenoid—I ultimately chose to work with a servo due to its generally easier implementation.

One challenge I encounter is to handle with servo. Especially with smaller angles (angle < 20 degrees, in general), it sometimes wobbled for a few seconds before reaching the set position, or in some cases, it did not reach the set position at all. I invested a considerable amount of time in understanding this mysterious wobbling, only to discover I should have connected the positive wire to VUSB not 3V3.

0
int servoPin = A2;
int servoPosition = 0;
Servo servo;

void setup()
{
    Serial.begin( 9600 );
    Particle.function( "pos", setPosition );
    servo.attach( servoPin );
}

void loop()
{
    delay(100);
}

int setPosition( String timeBeforeArrivalStr ){
    int timeBeforeArrival = timeBeforeArrivalStr.toInt();

    // servo.write( timeBeforeArrival ); 
    // return timeBeforeArrival;

    
    if (timeBeforeArrival >= 10) {
        servo.write( 175 );
    }
    
    if (timeBeforeArrival < 10 && timeBeforeArrival > 5) {
        servoPosition =  map(timeBeforeArrival, 10, 5, 30, 80); 
        servo.write( servoPosition );        
    }
    
    
    if (timeBeforeArrival <= 5 && timeBeforeArrival >= 3) {
        servo.write( 80 ); 
    }
    
    if (timeBeforeArrival < 3) {
        servo.write( 90 );
    }
    
    delay(1000);
    
    return 1;

}
Click to Expand
0

Outcome & Possible Improvement

    • I am able to get a proof of concept [see video]
  • One potential improvement for the future is to incorporate another motor for producing sound or vibration. This enhancement would better capture my attention during a busy morning.

0
x
Share this Project

Courses

48-675 Designing for the Internet of Things 24

· 11 members

A hands-on introductory course exploring the Internet of Things and connected product experiences.


About

A display of bus arrival time with Servo