Idris WROTE:Hi neuroclast,
What type/spec of battery and motor do you used? If you don't mind, could you share your hardware setup photo/video and Arduino program?
Thanks for responding! It's a 12V 12Ah SLA battery. The motor is 12VDC, 17A. The "chuck" stuff is just an I2c interface to a wireless Wii Nunchuck.
Here is the code:
- CODE: SELECT_ALL_CODE
#include "Wire.h"
#include "WiiChuck.h"
WiiChuck chuck = WiiChuck();
void setup() {
Serial.begin(115200);
chuck.begin();
chuck.update();
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
}
void loop()
{
delay(20);
chuck.update();
int speedVal = chuck.readJoyY();
Serial.print("Speed: ");
Serial.print(speedVal);
Serial.println();
int speedPWM = abs(speedVal * 2);
if(speedPWM > 255)
speedPWM = 255;
if(speedVal < -5)
{
digitalWrite(2, LOW);
analogWrite(3, speedPWM);
}
else if(speedVal > 5)
{
digitalWrite(2, HIGH);
analogWrite(3, speedPWM);
}
else
{
digitalWrite(2, LOW);
analogWrite(3, 0);
}
}
And here is the circuit setup: