i am trying to use my arduino with a rc receiver without pwm and a motor shield. i set my output speed pins to HIGH. i have 4 digital inputs for the receiver which just inputs 5 volts to the inputs and then is supposed to output to the corresponding motor shield pins and 6 digital outputs for the motor shield. i am using the if statement in my code telling the arduino to put HIGH power to the motor shield pins if it receives the high signal from the input pins but my arduino won't put out a steady 5 volts on the outputs, it only puts out 1.5 volts and sometimes it will vary on its own up to the 5 volts. when i run the motor shield demo sketch my arduino works just fine but i have tried 3 different sketches to make my set up work and can not seem to get it to work and have tried many different tests and determined it seems to be a problem with my arduino itself. Is it possible that this sketch is too much for the arduino to process? here is a copy of my primary code if someone thinks it is a sketch problem. help would be greatly appreciated.
// Arduino code
// pins for r/c receiver
const int left = 2;
const int right = 3;
const int forword = 4;
const int reverse = 5;
// motor shield pins
const int pinI1=8;//define I1 interface
const int pinI2=11;//define I2 interface
const int speedpinA=9;//enable motor A
const int pinI3=12;//define I3 interface
const int pinI4=13;//define I4 interface
const int speedpinB=10;//enable motor B
void setup()
{
pinMode(pinI1,OUTPUT);
pinMode(pinI2,OUTPUT);
pinMode(speedpinA,OUTPUT);
pinMode(pinI3,OUTPUT);
pinMode(pinI4,OUTPUT);
pinMode(speedpinB,OUTPUT);
pinMode(left,INPUT); //my rc reciever input pins
pinMode(right,INPUT); //which are not pwm compatable
pinMode(forword,INPUT); //they put out what ever voltage
pinMode(reverse,INPUT); //that is powering the reciever
}
void loop() {
if (digitalRead(left) == HIGH) {
motor1_reverse(); // move left motor (motor1) reverse
motor2_forward(); // move right motor (motor2) forward - this should make the robot turn left
} else {
motor1_stop(); //otherwise, stop both motors
motor2_stop();
}
if (digitalRead(right) == HIGH) {
motor1_forward(); // move left motor (motor1) forward
motor2_reverse(); // move right motor (motor2) reverse - this should make the robot turn left
} else {
motor1_stop();
motor2_stop();
}
if (digitalRead(forword) == HIGH) {
motor1_forward(); // move motor1 forward
motor2_forward(); // move motor2 forward
} else {
motor1_stop();
motor2_stop();
}
if (digitalRead(reverse) == HIGH) {
motor1_reverse(); // move motor1 reverse
motor2_reverse(); // move motor2 reverse
} else {
motor1_stop();
motor2_stop();
}
}
// These functions make it easier to define the direction of each motor and the appropriate digitalWrite commands, so you can just call motor1_forward();
// You can change the code or names of any of these functions if your motors do not go the direction that they should.
void motor1_forward(){
digitalWrite(pinI1, HIGH);
digitalWrite(pinI2, LOW);
digitalWrite(speedpinA, HIGH);
}
void motor1_reverse(){
digitalWrite(pinI2, HIGH);
digitalWrite(pinI1, LOW);
digitalWrite(speedpinA, HIGH);
}
void motor1_stop(){
digitalWrite(pinI1, LOW);
digitalWrite(pinI2, LOW);
digitalWrite(speedpinA, LOW);
}
void motor2_forward(){
digitalWrite(pinI3, HIGH);
digitalWrite(pinI4, LOW);
digitalWrite(speedpinB, HIGH);
}
void motor2_reverse(){
digitalWrite(pinI4, HIGH);
digitalWrite(pinI3, LOW);
digitalWrite(speedpinB, HIGH);
}
void motor2_stop(){
digitalWrite(pinI3, LOW);
digitalWrite(pinI4, LOW);
digitalWrite(speedpinB, LOW);
}