NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Everything Else » switching power to ground

September 07, 2010
by Quinnifir
Quinnifir's Avatar

hi my names Quinn and i have a science class where im building a remote control car. i need to know how to make the car reverse by switching the power to ground and the ground to power. thank you!

September 07, 2010
by Ralphxyz
Ralphxyz's Avatar

Hi Quinn, look at the Digtal Scale code.

Some thing like this without the printf_ of course:

  while(1) {
    // set polarity +-
    PORTD |= (1<<PD3);
    PORTD &= ~(1<<PD4);
    // wait 5 time constants (bw=12kHz, T=13.2us)
    // take reading
    //reading = adc_read();
    printf_P(PSTR("%d "), adc_read());

    // set polarity -+
    PORTD |= (1<<PD4);
    PORTD &= ~(1<<PD3);
    // wait 5 time constants (bw=12kHz, T=13.2us)
    // take reading
    //reading = reading - adc_read();
    printf_P(PSTR("%d\r\n"), adc_read());

I make no promises as I have never done this with a motor but it seems as though it should work.

It does reverse the polarity. Of course you will need to watch the current load if you are driving the motor with the MCU.

You could wire it up using some transistors, drive the transistors from pins on the MCU, start by lighting a LED one for forward and one for reverse.

Look at the Motors and MIcrocontrollers Tutorial 101

Let us know how you make out, one of these days I have to do something with a RC car and will need your help.


September 07, 2010
by Rick_S
Rick_S's Avatar

Probably one of the most common ways is through the use of what is called an "H-Bridge" this is esentially a set of driver transistors that will do the reversal based on an input. Here is a link to a fairly common lower current IC H-bridge. You can also build your own using discrete components (transistors, resistors, diodes). Do a google search for H bridge and you'll find more info than you can shake a stick at.


Post a Reply

Please log in to post a reply.

Did you know that our USB NerdKit comes with everything you need to get started with microcontrollers? Learn more...