ROBOTC.net forums
http://www.robotc.net/forums/

RobotC and Arduino with Motor Sheild
http://www.robotc.net/forums/viewtopic.php?f=62&t=5821
Page 1 of 1

Author:  VatsanM [ Mon May 06, 2013 9:22 pm ]
Post subject:  RobotC and Arduino with Motor Sheild

I am new to the Arduino platform and I am trying to learn to a good level that I can teach middle school kids Robotics and engineering concepts. I have Arduino R2 and a L293D motor sheild from Seeed Studio ( details on http://www.seeedstudio.com/depot/motor- ... th=132_134). Using the native Arduino sketch I was able to get the motor spinning. Now I want to move over to RobotC and there lies the issue. The RobotC code doesnt turn on the motor. I see the LED on the UNO board blinking but nothing happens. Below are both teh programs. Can anyone tell me what I did wrong please or is it a bug in RobotC?

Arduino native API:

Code:
int pinI1=8;//define I1 interface
int pinI2=11;//define I2 interface
int speedpinA=9;//enable motor A
int pinI3=12;//define I3 interface
int pinI4=13;//define I4 interface
int speedpinB=10;//enable motor B
int spead =127;//define the spead of motor

void setup()
{
  pinMode(pinI1,OUTPUT);
  pinMode(pinI2,OUTPUT);
  pinMode(speedpinA,OUTPUT);
  pinMode(pinI3,OUTPUT);
  pinMode(pinI4,OUTPUT);
  pinMode(speedpinB,OUTPUT);
}

void forward()
{
  analogWrite(speedpinA,spead);//input a simulation value to set the speed
  analogWrite(speedpinB,spead);
  digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
  digitalWrite(pinI3,LOW);
  digitalWrite(pinI2,LOW);//turn DC Motor A move anticlockwise
  digitalWrite(pinI1,HIGH);
}
void backward()//
{
  analogWrite(speedpinA,spead);//input a simulation value to set the speed
  analogWrite(speedpinB,spead);
  digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise
  digitalWrite(pinI3,HIGH);
  digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise
  digitalWrite(pinI1,LOW);
}
void left()//
{
  analogWrite(speedpinA,spead);//input a simulation value to set the speed
  analogWrite(speedpinB,spead);
  digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
  digitalWrite(pinI3,LOW);
  digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise
  digitalWrite(pinI1,LOW);
}
void right()//
{
  analogWrite(speedpinA,spead);//input a simulation value to set the speed
  analogWrite(speedpinB,spead);
  digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise
  digitalWrite(pinI3,HIGH);
  digitalWrite(pinI2,LOW);//turn DC Motor A move clockwise
  digitalWrite(pinI1,HIGH);
}
void stop()//
{
  digitalWrite(speedpinA,LOW);// Unenble the pin, to stop the motor. this should be done to avid damaging the motor.
  digitalWrite(speedpinB,LOW);
  delay(1000);

}

void loop()
{
  left();
  delay(2000);
  stop();
  right();
  delay(2000);
  stop();
  // delay(2000);
  forward();
  delay(2000);
  stop();
  backward();
  delay(2000);
  stop();
  exit;
}



RobotC:
Code:
#pragma config(CircuitBoardType, typeCktBoardUNO)
#pragma config(Motor,  motor_5,         motor5,        tmotorExternalHBridgeSinglePWM, openLoop, IOPins, dgtl5, dgtl8)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
motor[motor5] = 100;
wait10Msec(2000);

}

Author:  VatsanM [ Thu Jun 06, 2013 8:13 am ]
Post subject:  Re: RobotC and Arduino with Motor Sheild

Any pointer is very appreciated. Like I mentioned earlier, I am trying to learn this so that I can teach middle school kids in summer and I am totally stumped.

Author:  roboRed [ Tue Oct 22, 2013 12:10 am ]
Post subject:  Re: RobotC and Arduino with Motor Sheild

You did know that you can edit your own posts instead of making a new one for each follow up comment you make?

Author:  chaotic5555 [ Thu Jan 23, 2014 1:56 pm ]
Post subject:  Re: RobotC and Arduino with Motor Sheild

Have you tried adding the shield in the "Motors and Sensors" tab? If you do that it should recognize the board but otherwise it wont know what to reference. Because you were able to get it working with IDE you probably configured it but just a tip.

Author:  YORKHIGHSCHOOL [ Wed Mar 26, 2014 11:42 am ]
Post subject:  Re: RobotC and Arduino with Motor Sheild

Vatsan....I tried to do the same thing as you but gave up. For some reason the code for the motorshield was very difficult for me to get working. I finally took the 293D chip off and put it on a breadboard as in the following link. I followed this guys tutorial and within an hour I was up and running. He has a link to his code on his websie as well. Of course, you would have to obtain (if you do not have it already) the wire jumpers and breadboard shown in the video. Good luck.

https://www.youtube.com/watch?v=5nDaHJqruq0

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/