Hi all,
Hopefully someone can spare a few minutes to help a beginner out.
I have purchased a Trex JR and wish to control it from my Arduino Diecimila.
The first thing i did was remove the chip from the arduino and hook up the Trex JR to it hardware serial pins and set up the jumpers to allow serial control. Then i ran the Trex configuration software to change the baud rate down to 9600 with E parity and one stop bit. Then i had a play with controlling my motors (i love it!).
My next step was to set up a sketch for arduino with software serial. I want to be able to send commands and receive data back from the trex jr, and leave the hardware serail open to allow me to debug with the arduinos usb port and the arduino’s ide serial monitor.
And thats where i am struggling. (didn’t get very far did i? )
I wrote a very simple sketch that sets up a software serial port and sends what i think (probably way off) is a command to the trex jr to set motor ones speed to 127.
Heres the sketch
#include <AFSoftSerial.h>
AFSoftSerial mySerial = AFSoftSerial(7, 6);
void setup() {
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
}
void loop() // run over and over again
{
unsigned char buff[32]; // create a buffer
buff[0]=0xC2; // Motor one forward COMMAND
buff[1]=0x7F; // Motor one speed 127 DATA
for(int i=0;i<2;i++){
mySerial.print(buff[i],BYTE);
}
delay (5555);
}
I get nothing. I can see the trex’s green LED light up very briefly, but thats all.
I have no prior knowledge of anything like this, and would really really appriciate a little guidance.
Please help