so i broutg a new wild thumper motor controller load code below on it and now te controller makes this noise whn i turn on te rc controller. also my ardiouno idle says its not syn. still it seems programs are uploading. basicly its the onl the rc code on the basic code provided . but as far as i know the sound indicades something is wrong because when i used my first vcontroller it wasnt making sound altho i did blow that one up after a while. any 1 can tell me why its making the sound i must have missed somthing ?
code :
#include <Servo.h>
#include "IOpins.h"
#include "Constants.h"
//-------------------------------------------------------------- define global variables --------------------------------------------
unsigned int Volts;
unsigned int LeftAmps;
unsigned int RightAmps;
unsigned long chargeTimer;
unsigned long leftoverload;
unsigned long rightoverload;
int highVolts;
int startVolts;
int Leftspeed=0;
int Rightspeed=0;
int Speed;
int Steer;
byte Charged=1; // 0=Flat battery 1=Charged battery
int Leftmode=1; // 0=reverse, 1=brake, 2=forward
int Rightmode=1; // 0=reverse, 1=brake, 2=forward
byte Leftmodechange=0; // Left input must be 1500 before brake or reverse can occur
byte Rightmodechange=0; // Right input must be 1500 before brake or reverse can occur
int LeftPWM; // PWM value for left motor speed / brake
int RightPWM; // PWM value for right motor speed / brake
void setup()
{
//------------------------------------------------------------ Initialize I/O pins --------------------------------------------------
pinMode (Charger,OUTPUT); // change Charger pin to output
digitalWrite (Charger,1); // disable current regulator to charge battery
}
void loop()
{
//------------------------------------------------------------ Check battery voltage and current draw of motors ---------------------
Volts=analogRead(Battery); // read the battery voltage
LeftAmps=analogRead(LmotorC); // read left motor current draw
RightAmps=analogRead(RmotorC); // read right motor current draw
if (LeftAmps>Leftmaxamps) // is motor current draw exceeding safe limit
{
analogWrite (LmotorA,0); // turn off motors
analogWrite (LmotorB,0); // turn off motors
leftoverload=millis(); // record time of overload
}
if (RightAmps>Rightmaxamps) // is motor current draw exceeding safe limit
{
analogWrite (RmotorA,0); // turn off motors
analogWrite (RmotorB,0); // turn off motors
rightoverload=millis(); // record time of overload
}
if ((Volts<lowvolt) && (Charged==1)) // check condition of the battery
{ // change battery status from charged to flat
//---------------------------------------------------------- FLAT BATTERY speed controller shuts down until battery is recharged ----
//---------------------------------------------------------- This is a safety feature to prevent malfunction at low voltages!! ------
Charged=0; // battery is flat
highVolts=Volts; // record the voltage
startVolts=Volts;
chargeTimer=millis(); // record the time
digitalWrite (Charger,0); // enable current regulator to charge battery
}
else
{//----------------------------------------------------------- GOOD BATTERY speed controller opperates normally ----------------------
RCmode();// RC mode via D0 and D1
// --------------------------------------------------------- Code to drive dual "H" bridges --------------------------------------
if (Charged==1) // Only power motors if battery voltage is good
{
if ((millis()-leftoverload)>overloadtime)
{
switch (Leftmode) // if left motor has not overloaded recently
{
case 2: // left motor forward
analogWrite(LmotorA,0);
analogWrite(LmotorB,LeftPWM);
break;
case 1: // left motor brake
analogWrite(LmotorA,LeftPWM);
analogWrite(LmotorB,LeftPWM);
break;
case 0: // left motor reverse
analogWrite(LmotorA,LeftPWM);
analogWrite(LmotorB,0);
break;
}
}
if ((millis()-rightoverload)>overloadtime)
{
switch (Rightmode) // if right motor has not overloaded recently
{
case 2: // right motor forward
analogWrite(RmotorA,0);
analogWrite(RmotorB,RightPWM);
break;
case 1: // right motor brake
analogWrite(RmotorA,RightPWM);
analogWrite(RmotorB,RightPWM);
break;
case 0: // right motor reverse
analogWrite(RmotorA,RightPWM);
analogWrite(RmotorB,0);
break;
}
}
}
else // Battery is flat
{
analogWrite (LmotorA,0); // turn off motors
analogWrite (LmotorB,0); // turn off motors
analogWrite (RmotorA,0); // turn off motors
analogWrite (RmotorB,0); // turn off motors
}
}
}
void RCmode()
{
//------------------------------------------------------------ Code for RC inputs ---------------------------------------------------------
Speed=pulseIn(RCleft,HIGH,25000); // read throttle/left stick
Steer=pulseIn(RCright,HIGH,25000); // read steering/right stick
if (Speed==0) Speed=1500; // if pulseIn times out (25mS) then set speed to stop
if (Steer==0) Steer=1500; // if pulseIn times out (25mS) then set steer to centre
if (abs(Speed-1500)<RCdeadband) Speed=1500; // if Speed input is within deadband set to 1500 (1500uS=center position for most servos)
if (abs(Steer-1500)<RCdeadband) Steer=1500; // if Steer input is within deadband set to 1500 (1500uS=center position for most servos)
if (Mix==1) // Mixes speed and steering signals
{
Steer=Steer-1500;
Leftspeed=Speed-Steer;
Rightspeed=Speed+Steer;
}
else // Individual stick control
{
Leftspeed=Speed;
Rightspeed=Steer;
}
Leftmode=2;
Rightmode=2;
if (Leftspeed>(Leftcenter+RCdeadband)) Leftmode=0; // if left input is forward then set left mode to forward
if (Rightspeed>(Rightcenter+RCdeadband)) Rightmode=0; // if right input is forward then set right mode to forward
LeftPWM=abs(Leftspeed-Leftcenter)*10/scale; // scale 1000-2000uS to 0-255
LeftPWM=min(LeftPWM,255); // set maximum limit 255
RightPWM=abs(Rightspeed-Rightcenter)*10/scale; // scale 1000-2000uS to 0-255
RightPWM=min(RightPWM,255); // set maximum limit 255
}