digitalWrite(HIGH) is much less than 5V

I try to use a arduino nano to control a simple motor thru' a L9110 motor drive IC.

I use the pin D9 an D10 as signal output and control it by digitalWrite(HIGH), but it was not as expected 5V when it was measured by a multimeter.

The arduino is powered by a 7.4 V LiPo battery and the 5V output is connector to a HC-06 bluetooth and a mini-servo.

The whole program is also attached.

thanks for your help.


#include <SoftwareSerial.h>
#include <Wire.h> //引用二個函式庫SoftwareSerial及Wire SoftwareSerial
#include <Servo.h>
SoftwareSerial I2CBT(A0,A1); //定義PIN10及PIN11分別為RX及TX腳位
Servo myservo; // create servo object to control a servo

int pos = 0; // variable to store the servo position
int INA = 9;
int INB = 10;
//int LED = 13;

void setup() {
Serial.begin(9600); //Arduino起始鮑率9600
I2CBT.begin(9600); //藍牙鮑率57600
myservo.attach(3); // attaches the servo on pin 3 to the servo object
pinMode(INA,OUTPUT);
pinMode(INB,OUTPUT);
}

void loop() {
byte cmmd[20];
int insize;
servo(90);
while(1){
if ((insize=(I2CBT.available()))>0){
Serial.print("input size = ");
Serial.println(insize); //顯示接收多少訊息
for (int i=0; i<insize; i++) {
Serial.print(cmmd*=char(I2CBT.read()));//將接收的訊息顯示出來*

  • //Serial.print("\n");*

  • } //for*

  • switch (cmmd[0]) {*

  • case 97: //'a' *

  • //digitalWrite(LED,HIGH);*

  • motorforward();*

  • Serial.print(" go");*

  • break; *

  • case 98: //'b'*

  • //digitalWrite(LED,LOW);*

  • motorstop();*

  • Serial.print(" stop");*

  • break;*

  • case 102: //'f'*

  • //digitalWrite(LED,LOW);*

  • motorback();*

  • Serial.print(" back");*

  • break;*

  • case 99: //'c'*

  • servo(150);*

  • Serial.print(" Left");*

  • break;*

  • case 100: //'d'*

  • servo(90);*

  • Serial.print(" Ctr");*

  • break;*

  • case 101: //'e'*

  • servo(30);*

  • Serial.print(" Right");*

  • break;*

  • } //Switch *

  • Serial.print("\n");*

  • } //if*

  • } //while*
    }
    //**************************
    void servo(int servopos) {

  • myservo.write(servopos); // tell servo to go to position in variable 'pos'*

  • delay(15); // waits 15ms for the servo to reach the position*
    }
    void motorforward() {

  • digitalWrite(INA,LOW);*

  • digitalWrite(INB,HIGH);*

  • //delay(1000);*
    }
    void motorstop() {

  • digitalWrite(INA,LOW);*

  • digitalWrite(INB,LOW);*

  • //delay(1000);*
    }
    void motorback() {

  • digitalWrite(INA,HIGH);*

  • digitalWrite(INB,LOW);*

  • //delay(1000);*
    }

joeydream:

You also need [b]pinMode (INA, OUTPUT)[/b] and [b]pinMode (INB, OUTPUT)[/b].

krupski:
You also need [b]pinMode (INA, OUTPUT)[/b] and [b]pinMode (INB, OUTPUT)[/b].

?

See setup()

@OP - please remember to use code tags when posting code

AWOL:
?

See setup()

@OP - please remember to use code tags when posting code

Good grief! I looked it over twice and didn't see it. Must need sleep.

Thanks for the catch.

I use the pin D9 an D10 as signal output and control it by digitalWrite(HIGH), but it was not as expected 5V when it was measured by a multimeter.

What is the voltage... Is it close to 5V?.

And, what does the 5V power measure.... Is the 5V power "holding up" when you try to run the motor?

Are you seeing the "go" "stop" and "back" on the serial monitor? (I like to put those messages in the function so I know I'm really calling/running the function.)

Try a simpler test-program similar as the Blink Example, but run the motor instead of blinking an LED.

Try it with and without the L9110 connected.

joeydream:
...and the 5V output is connector to a HC-06 bluetooth and a mini-servo.

The 5volt regulator of a Nano might just be able to power the BT module, but NOT the servo.
Leo..

And you shouldn't be considering using the logic 5V supply rail for motors, servos or other heavy current
loads. Separate power capable of the high current is really strongly advised.