I have an Arduino Mega with an Adafruit motor shield on it. I also have a radio module with the data line on pin 14.
I am using VirtualWire to handle rf comms and it seems to be mucking with the motor shield. Specifically, M1 only does what it's told when I comment out
It is my conclusion, therefore, that VWire is using pins other than 14 (perhaps not controlling the pins but setting them as inputs/outputs) , pins that the motor shield is using.
Any help/ideas would be much appreciated, thanks
Which Adafruit motor shield, and which library? I think the VirtualWire uses a timer, I don't know if the Adafruit library uses a timer.
Can you take a look in the library source of VirtualWire ? There is a ptt pin in use. That is some kind of enable and it is almost never used, but VirtualWire still sets it as output. Perhaps setting it to an unused pin is enough to avoid conflicts.
Thanks for your reply.
This is the shield: http://www.adafruit.com/products/81
And I'm using the official Adufruit library for it AF_DCMotor Class | AFMotor Library Reference | Adafruit Learning System
I belive the AFMotor library does use a timer, but perhaps this isn't a problem as the other 3 motors perform exactly as they're told?
I have tried putting
vw_set_ptt(15); before vw_setup, but this doesn't seem to make a differnce.
Is the library this code ?
It uses TIMER1 and TIMER3 when the ATmega2560 is used.
The VirtualWire also uses TIMER1.
That is a problem. I don't know how to fix it. Perhaps another motor driver (instead of the Motor Shield). Perhaps other software with that Motor Shield.
Can you tell how the motors are connected and how they are used ?
Are they 4 motors with speed control and in both directions ?