Let's Make Robots!

motor command via Serial prob.

i need to command motors to start and stop via the serial line.   but i upload the code and they both just come on?  wont go off or enything.  they are small so for thesting i jush atached them to the pins and ground heres the code:

 

 

 

 

int message = 1;
int M1P =  5;
int M2P =  6;
int M1 = 0;
int M2 = 0;

void setup()
{
  pinMode(M1P, OUTPUT); 
  pinMode(M2P, OUTPUT);
  Serial.begin(9600);  
}


void loop()                     
{
  {
  if (Serial.available() > 0)
  message = Serial.read();
}{
  if (message == 'R');
  digitalWrite(M1P, HIGH); 
}{
  if (message == 'r');
  digitalWrite(M1P, LOW);
}{
  if (message == 'L');
  digitalWrite(M2P, HIGH);
}{
  if (message == 'l');
  digitalWrite(M2P, LOW);  

}
}

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

"Shut up about the f-ing motors" is not they way you ask for help. This fact is usually taught by parents to children.

And you have lost my help.

You have probably fried the pins that were connected to the motor. If you are lucky, you only lost those pins and not the whole chip. If you can still sync, it is a good sign. Test these pins with a simple blink program and also try your original test program on a couple different pins.

I know this for 2 resons -  the motors are very small (ive driven much biger motors on this board)  and i wrote all the pins high and used a led and 330ohm rissistor to test thim so shut up about the f-ing motors!!!

Christ what an attitude problem. I was going to offer a possible solution but I don`t think I will now.

Chris is very experienced with robot building, so he is talking from experience..  He and I have damaged chips from over sinking current from them.  Do you know what this means?

In a previous post you stated, "it dosint work now nothing hapens the Test LEDs dont come on or enything" and now you are saying 

i wrote all the pins high and used a led and 330ohm rissistor to test".  So now they are working with the LEDs?  Can you post the code you are using to test, if you have a question about that?

You need to be as clear as possible when stating your problem, if you really want help.  Add pictures or diagrams if you can.

Also, since you helped me with that great formatting tip, I will let you in on a tip/trick I use.  Most browsers are spell checking capable. A little squiggly line appears for misspelled words, you just right click and choose the correct spelling.  It adds to the clarity of your statements.

GroG

 

 

it dosint work now nothing hapens the Test LEDs dont come on or enything

Ok i will make the changes and use LEDs to test and get back with you guys if it works.

And GroG to make you code look good,

enter the arduino envirement and select all code then right click it and select "copy HTML".

come to LMR and select HTML in the coments box, paste code there.   DONE!

Chris showed his complete Awesomeness by reading carefully and pointing out what should have been obvious to us all !  Ting !

Now, I would like to know another "Awesome" thingy, which may be obvious to all...(except me)

How the HECK did you Breathit, make all your code so pretty ?!?!  

I thought there might be a code module now in LMR - but looking at the source it does not appear to be the case, because I would expect just a <class=code> and the implementation done with css.

I can make my code format correctly with carriage returns, spaces, and tabs with a <pre> tag...  but how did you do the syntax highlighting ?!?!?!

I am your grasshopper....

You should not be running motors directly off of the pins on the microcontroller! It is possible that you may have already fried something! --Test with a LED, my friend --or get a transistor for that motor!

Yep, I saw the code and got excited... but leave it to CTC to get to the root of the issue...

Max current from the pin will be about 40 ma... enough current for about 2 regular LEDs and not much more...