i am using the arduino to controll the pololu low voltage dual serial motor controller, and im am getting an error labeled "within this context" on
motor.write(BYTE)0x80); // command
This is my whole entire sketch
this is my whole sketch-
Code:
#include <NewSoftSerial.h> // includes the library for serial data transfers
#define txPin 2 // states what pin transmits the data to the pololu controller
#define rstPin 3 // states what pin is used a reset,which puts the controller to a defualt, all motors off state
#define rxPin 4 // this pin is used to recive data and is required, however it is unused in this sketch
NewSoftSerial motor(rxPin, txPin); // this shows what pins that are defined will be used with the New Soft Serial interface
void setup() {
pinMode(rstPin, OUTPUT); // this shows that the reset pin set to transfer, and not to recive electricity.
motor.begin(9600); // this begins a NSS interface named "motor"
digitalWrite(4, HIGH); // this causes electrical current to flow on the reset pin, which in turn prevents the motor controller from random reset
delay(500);
}
void loop() {
motor.write(BYTE)0x80); // command
motor.write(BYTE)0x00); // device number
motor.write(BYTE)0x03); // motor 2 backward
motor.write(BYTE)0x7F); // full speed
delay(2000);
}
This code gives me the the "no matching function to 'newsoflserial::write(int,int)' " error
#include <NewSoftSerial.h> // includes the library for serial data transfers
#define txPin 2 // states what pin transmits the data to the pololu controller
#define rstPin 3 // states what pin is used a reset,which puts the controller to a defualt, all motors off state
#define rxPin 4 // this pin is used to recive data and is required, however it is unused in this sketch
NewSoftSerial motor(rxPin, txPin); // this shows what pins that are defined will be used with the New Soft Serial interface
void setup() {
pinMode(rstPin, OUTPUT); // this shows that the reset pin set to transfer, and not to recive electricity.
motor.begin(9600); // this begins a NSS interface named "motor"
digitalWrite(4, HIGH); // this causes electrical current to flow on the reset pin, which in turn prevents the motor controller from random reset
delay(500);
}
void loop() {
motor.write(0x80, BYTE); // command
motor.write(0x00, BYTE); // device number
motor.write(0x03, BYTE); // motor 2 backward
motor.write(0x7F, BYTE); // full speed
delay(2000);
}
i read your reply 5, and that code did not compile, it gave the within this context error, so then when the other guy said to use motor.print, it compiled just fine however, the motor controller i am trying to communicate with shows no status LEDs blink at all so that means the motor controller and arduino arent comunicating properly, i spoke with people at pololu and they said it is wired correctly so the issue is the software, thats what i need help on, i just want to get the controller to comunicate
#include <NewSoftSerial.h> // includes the library for serial data transfers
#define txPin 5 // states what pin transmits the data to the pololu controller
#define rstPin 6 // states what pin is used a reset,which puts the controller to a defualt, all motors off state
#define rxPin 4 // this pin is used to recive data and is required, however it is unused in this sketch
NewSoftSerial motor(rxPin, txPin); // this shows what pins that are defined will be used with the New Soft Serial interface
void setup() {
pinMode(rstPin, OUTPUT); // this shows that the reset pin set to transfer, and not to recive electricity.
motor.begin(9600); // this begins a NSS interface named "motor"
digitalWrite(4, HIGH); // this causes electrical current to flow on the reset pin, which in turn prevents the motor controller from random reset
delay(500);
}
void loop() {
motor.print(0x80, BYTE); // command
motor.print(0x00, BYTE); // device number
motor.print(0x03, BYTE); // motor 2 backward
motor.print(0x7F, BYTE); // full speed
delay(2000);
}
ok, i removed that line, and still there are no status LED blinkers on the motor controller, i think i am missing the configuration data for the controller in my sketch however i have no clue how to implement that
yes, the motor controller is capable of running at between 1200 19200 baud, and the controller auto-detects the buad rate. All i want really is an example code for this motor controller that works well. i just need a simple one, that makes the motors move in one direction on the 2 motor setup.
Post a link to the motor controller you are using, and a schematic of how it is connected to the Arduino, along with a high resolution, in focus, picture that illustrates that the connection is as your schematic shows.