I connect VCC and GND (l9110s) to power, and Arduino to jack power (separate battery). But it doesn't work. I change the sensor, but it is the same. Not work. I assume the NewPing.h , I download from the Arduino Playground - HomePage. But it should be compatible (version 1.7)
I try this sketch, it moves. But without ultrasonic. Thanks.
/*
L9110 motor driver controlling 2 small DC motors
*/
const int AIA = 5; // (pwm) pin 5 connected to pin A-IA
const int AIB = 6; // (pwm) pin 6 connected to pin A-IB
const int BIA = 10; // (pwm) pin 10 connected to pin B-IA
const int BIB = 11; // (pwm) pin 11 connected to pin B-IB
byte speed = 255; // change this (0-255) to control the speed of the motors
void setup() {
pinMode(AIA, OUTPUT); // set pins to output
pinMode(AIB, OUTPUT);
pinMode(BIA, OUTPUT);
pinMode(BIB, OUTPUT);
}
void loop() {
forward();
delay(1000);
backward();
delay(1000);
left();
delay(1000);
right();
delay(1000);
}
void backward()
{
analogWrite(AIA, 0);
analogWrite(AIB, speed);
analogWrite(BIA, 0);
analogWrite(BIB, speed);
}
void forward()
{
analogWrite(AIA, speed);
analogWrite(AIB, 0);
analogWrite(BIA, speed);
analogWrite(BIB, 0);
}
void left()
{
analogWrite(AIA, speed);
analogWrite(AIB, 0);
analogWrite(BIA, 0);
analogWrite(BIB, speed);
}
void right()
{
analogWrite(AIA, 0);
analogWrite(AIB, speed);
analogWrite(BIA, speed);
analogWrite(BIB, 0);
}