View Full Version : Serial Interfacing with DC Motor

01-08-2009, 09:43 PM
I want to drive 2 DC motors through PC serial port via microcontroller(Atmega8).

I am struck with the programming part(WinAVR).Please help me.

What i want is that when I send "1" the two motors should rotate clockwise(forward) and when "2" one should rotate clockwise another anti clockwise (left/right) and same for backward movement.

I have seen some examples where a character is send from PC like "C" and "[C]" is send back to PC.I have to modify those codes.

I am confused that after sending a command for forward movement let it be "1" and storing it in a variable,now after this how do i send the data to the output pins.

can it be like this :


also how to handle those buffers ?

(I have started few more threads all related to same stuffs sorry for that)

01-08-2009, 11:06 PM
can it be like this :


you are on right track, its all logical problem i.e. how u have to code,
look up table is your answer, just resolve how many combination there could be and map them like match the column analogy using if else or any equal statement, and also use <AND NOT> and <OR> logic with pin assertion, just for sanity....

01-10-2009, 06:41 PM
Hey you are writing "1" which is a string and strings CANNOT BE compared that way !!!

Write '1' instead of "1"

Coz '1' is single byte char while "1" = 2 byte STRING of char (the last byte for '\0' for string.

See my RS232/ USART turorials here