Need help with output to follow input
hello everyone,
i'm new arduino coding , need 1 of projects.
basically project take in signal(in pulse width modulation) pixhawk , send 2 motors through esc(electronic speed controller), , need have switch(signal in pwm) turn motors off.
the problem facing when switch allows signal pass through, output not follow input, though led of pin 13 working.
the following code. (the board i'm using arduino uno)
i'm new arduino coding , need 1 of projects.
basically project take in signal(in pulse width modulation) pixhawk , send 2 motors through esc(electronic speed controller), , need have switch(signal in pwm) turn motors off.
the problem facing when switch allows signal pass through, output not follow input, though led of pin 13 working.
the following code. (the board i'm using arduino uno)
code: [select]
int motoraout = 5;
int motorbout = 6;
int motora = 9;
int motorb = 10;
int motorcontrol =11;
boolean a=0;
boolean b=0;
void setup()
{
pinmode(motoraout, output);
pinmode(motorbout, output);
pinmode(motora, input);
pinmode(motorb, input);
pinmode(motorcontrol,input);
pinmode(13, output);
}
void loop()
{
int controlswitch = pulsein(motorcontrol, high);
if(controlswitch>1500) //my motor control switch have period of 20 millisecond,
{ //on state having pulse of 2 millisecond , off being 1.
= digitalread(motora);
digitalwrite (motoraout,a);
b = digitalread(motorb);
digitalwrite (motorbout,b);
digitalwrite (13,high);
}
else
{
digitalwrite (motoraout,low);
digitalwrite (motorbout,low);
digitalwrite(13,low);
}
}
quote
the problem facing when switch allows signal pass through, output not follow input, though led of pin 13 working.what mean "does not follow"? frequency pwm in?
why use of pulsein? why not simple digitalread?
i'm not familiar pulsein function. according decription, wait till pin goes low (after detected high), if keep button / switch pushed, have timeout of 1 second.
if timing critical, use simple , gate (e.g. 74hc08); 1 input controlled arduino (on/off) , other input connected pwm input. output goes esc.
Arduino Forum > Using Arduino > Project Guidance > Need help with output to follow input
arduino
Comments
Post a Comment