smart Robot car

This is a special forum devoted to educators using Adafruit and Arduino products for teaching.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
martijn_schepkens
 
Posts: 1
Joined: Sun Oct 18, 2015 3:20 am

smart Robot car

Post by martijn_schepkens »

Hellow

I just starting to use Arduino. In my school we are using a robot car for some test.
Has someone an idea how i can accelerate my car from 0 to .....? 0 to 250
I can't find an arduino code for this. Can someone help me.

Thanks
Attachments
Free-shipping-4-set-Smart-Car-Robot-Plastic-Tire-Wheel-Tyre-DC3-6V-Gear-Motor-For.jpg
Free-shipping-4-set-Smart-Car-Robot-Plastic-Tire-Wheel-Tyre-DC3-6V-Gear-Motor-For.jpg (44.85 KiB) Viewed 395 times
Hot-For-2WD-DIY-Motor-Smart-Robot-Car-Chassis-Kit-Speed-Encoder-Battery-Box-Remote-Control.jpg
Hot-For-2WD-DIY-Motor-Smart-Robot-Car-Chassis-Kit-Speed-Encoder-Battery-Box-Remote-Control.jpg (399 KiB) Viewed 395 times

User avatar
adafruit_support_bill
 
Posts: 88092
Joined: Sat Feb 07, 2009 10:11 am

Re: smart Robot car

Post by adafruit_support_bill »

What motor shield are you using? The library for your motor shield should have some function to set the speed. You just need to write a loop to increment through the speeds:

something like this:

Code: Select all

void accelerate(int start, int end, int milliseconds)
{
    int interval = milliseconds / abs(end - start);

    for (int i = start; i < end; i++)
    {
        motor.setSpeed(i);
        delay(interval);
    }
}

Locked
Please be positive and constructive with your questions and comments.

Return to “For Educators”