Hi all,
I am trying to use an RC transmitter to control the Dual VNH5019 motor controller through an Arduino. I want to use PulseIn() to measure the pulse width from the receiver, map() it down to a usable set of values (-400 to 400 as per the motor controller), and send those values to the motor controller. However, the Dual VNH5019 library and the PulseIn function dont seem to play well together. The PulseIn and mapped values work fine until md.init() is added. I tried doing this with interrupts and it still didnt work.
Once md.init() is uncommented all I get on the serial stream is:
Pulse Width: 0
Mapped Pulse: -2332
Here is the broken code:
[code]#include "DualVNH5019MotorShield.h"
DualVNH5019MotorShield md;
int pulse;
int Setpoint;
void setup() {
pinMode(7, INPUT);
Serial.begin(9600);
md.init();
}
void loop() {
pulse = pulseIn(7, HIGH, 25000);
Setpoint = map(pulse, 1280, 1810, -400, 400);
Serial.print(“Pulse Width:”);
Serial.println(pulse);
Serial.print(“Mapped Pulse:”);
Serial.println(Setpoint);
md.setM1Speed(Setpoint);
//delay(200);
}[/code]
I’m no code guru so please go easy on me!
Thanks in advance!