(Solved)Arduino Uno only 1.5 volts from digital outputs instead of 5 volts

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);
}

You need to put your code in a "Code Block" (The pound (#) icon).

Anyhow, check out this thread:
http://arduino.cc/forum/index.php/topic,122825.0.html

Sounds like it might have the tips you are looking for.

Is it possible that this sketch is too much for the arduino to process?

No, a sketche's complexity has no effect on the digital output pins.
From your description it sounds like you are not setting the pins to be an output, however that code shows you are. The other thing is that you might be overloading the outputs, that is drawing too much current from the.
A schematic of what you have would be good.

wikitjuggla:
i am trying to use my arduino with a rc receiver without pwm and a 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.

You're trying to drive motors directly from the Arduino pins? It won't work, motors draw too many amps. That's why you need a motor shield.

Don't continue without one. You can damage your Arduino.

We are told there is a motor shield, the output pins are driving that.

We are also told the motor demo works.

My suspicion is something to do with the supply voltage or common grounding is awry - a schematic of the wiring might be useful, but I'd suggest checking that all the supply voltages are correct during operation and all grounds are common.

i haven't been trying to drive the motors from the digital pins themselves, i have been testing my arduino by using the button wiring setup from the 5 volt pin output and connecting it one at a time to my input pins and testing my outputs with a multimeter and an LED and i just can't seem to get it to work right. as for a schematic i don't really have one since i haven't started much of a project, just been trying to get this rc thing to work and go from there and i am pretty new at this stuff, the motor shield just stacks on top of the arduino and i have been testing my arduino without anything connected to it and it still doesn't work right because at first i thought i had wired something wrong. thank you for your input

and testing my outputs with a multimeter and an LED and i just can't seem to get it to work right.

If you are testing the outputs by wiring a led to it and not using a series current limiting resistor, then you are causing too much current to be drawn from the output pin which will reduce it's output voltage as well as risk damage to the pin and the led.

Lefty

i am using a 270ohm resistor for the LED and i test the outputs with the multimeter w/o the LED connected

So when you remove the connections to the motor driver does the voltage recover?

wikitjuggla:
i am using a 270ohm resistor for the LED and i test the outputs with the multimeter w/o the LED connected

Good. So are you sure whatever sketch you are using during these 'tests' is writing a steady HIGH output and not switching between high and low at some rate, as your meter will give a lower voltage reading in reponse to a changing digital output?

Lefty

Posted on: Today at 07:47:26 AM
Posted by: Grumpy_Mike
Insert Quote
So when you remove the connections to the motor driver does the voltage recover?

No my voltage does not recover, my first thought was that i had caused a short circuit which would make my voltage drop but that was not the case

Good. So are you sure whatever sketch you are using during these 'tests' is writing a steady HIGH output and not switching between high and low at some rate, as your meter will give a lower voltage reading in reponse to a changing digital output?

the above sketch is my primary sketch that am using and i have tried sever different variations of that sketch and seem to always get the same result. one of the sketches i wrote will give power to the motor pins correctly but the speed pins will sometimes work and sometimes not

Read this before posting a programming question

it only puts out 1.5 volts and sometimes it will vary on its own up to the 5 volts.

Which pin, exactly?

pins 9 and 10 but depending on the sketch sometimes all of my designated output pins

wikitjuggla:
pins 9 and 10 but depending on the sketch sometimes all of my designated output pins

I suggest you write a very simple sketch that in your setup function you make all pins output mode and set to HIGH and just have your loop function empty. Then go measure the output voltage on all the pins to gain confidence in your controller chip and your measurements, then report back.

Lefty

well each and every one of my outputs measured 5 volts on the money so that would probably signify its a problem with the sketch one would assume?

probably signify its a problem with the sketch one would assume?

Yes as mentioned at the start you are probably not setting them to outputs or they are being reset to inputs somewhere else in the sketch.

i may have discovered what is wrong but i am not positive on this, i believe the stop command being at the end of every if statement is conflicting with the outputs. everything is set to "else" stop so when one, lets say "left" command, is trying to give power to one of the motor and speed pins, all the other if statement commands are trying to tell those pins to "stop" or write time "low". someone please correct me if i am wrong and if i am right i would appreciate help with a way around this problem in my sketch

Almost certainly. First how about doing what a number of people suggested?

Please edit your post, select the code, and put it between [code] ... [/code] tags.

You can do that by hitting the # button above the posting area.

What you are measuring as 1.5 V with a multimeter is quite likely to be 5V, pulsed with 0V, at a certain rate. An oscilloscope or logic analyzer would clear that up.

i devised a new code that is operational and seems to have solved my problem but does not give me dependable simultaneous operation of both motors but it shall do..... i thank you all for your input on this matter. here is a copy of my redone 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 rcleft=2;  //rc reciever inputs which are just basic
int rcright=3;  // 5 volt on off buttons so to speak because
int rcforward=4; // my reciever is not pwm 
int rcbackward=5;

void setup()
{
  pinMode(pinI1,OUTPUT);
  pinMode(pinI2,OUTPUT);
  pinMode(speedpinA,OUTPUT);
  pinMode(pinI3,OUTPUT);
  pinMode(pinI4,OUTPUT);
  pinMode(speedpinB,OUTPUT);
  pinMode(rcleft,INPUT);
  pinMode(rcright,INPUT);
  pinMode(rcforward,INPUT);
  pinMode(rcbackward,INPUT);
}
 
void forward() //one could use analogWrite to slow the speed of the 
{             // motors but if you wanted to adjust the speed
             // you would have to reupload the sketch
     digitalWrite(speedpinB,HIGH);
     digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
     digitalWrite(pinI3,LOW);
}
void backward()
{
     
     digitalWrite(speedpinB,HIGH);
     digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise
     digitalWrite(pinI3,HIGH);
     
}
void left()
{
     digitalWrite(speedpinA,HIGH);
     digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise
     digitalWrite(pinI1,LOW);
}
void right()
{
     digitalWrite(speedpinA,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);
     digitalWrite(pinI1, LOW);
     digitalWrite(pinI2, LOW);
     digitalWrite(pinI3, LOW);
     digitalWrite(pinI4, LOW);
     
 
}

void loop() {
  if (digitalRead(rcleft) == HIGH) {
    left();
  }
  
  else if (digitalRead(rcright) == HIGH) {
    right();
  }
  
  else if (digitalRead(rcforward) == HIGH) {
    forward();
  }
  
  else if (digitalRead(rcbackward) == HIGH) {
    backward();
  } else { 
    stop();
  }
}

Cool. So lesson learned?

It's hard to debug a software problem with a voltmeter.
But then again it's also pretty hard to troubleshoot a wiring problem with a software debug function. :wink:

Welcome to the embedded controller world where hardware is king and software is always evil. :smiley:

Lefty