Go Down

Topic: Digital write not working on DUE but same code works Uno and Mega 2560 (Read 410 times) previous topic - next topic

The following code works great on UNO and Mega 2560.  It is a driver for an Elechous dual channel motor driver.  I am using it to drive linear actuators with a joystick.  the condition loops work but digital write pins do go high when required.  see asterisks in code. Any help would be much appreciated
Quote



int SignalA= (0);//define input signal pin

int SignalB= (0);//define input signal pin


void setup()
{
  pinMode(2,OUTPUT);
  pinMode(3,OUTPUT);
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  pinMode(8,OUTPUT);
  pinMode(9,OUTPUT);


  // default mode is INPUT
  Serial.begin(9600);

}

void LaIn()// Linear Actuator A IN
{
  digitalWrite(2, HIGH);   // in
  digitalWrite(5, HIGH);   // in
  analogWrite(3,1);   // in
}
void LaOut()// Linear Actuator A Out
{
  digitalWrite(2, HIGH);   // out
  digitalWrite(3, HIGH);   // out
  analogWrite(5,1);   // out   
}
void LaStop()// Linear Actuator A STOP
{
  digitalWrite(2, HIGH);   // stop  *********this pin goes high**********************
  digitalWrite(3, HIGH);   // stop  [font=Verdana]********************this pin and pin 5 do not ******************[/font]
  digitalWrite(5, HIGH);   // stop
  Serial.print("hello");
  Serial.print("\t");
}
void LbIn()// Linear Actuator B IN
{

  digitalWrite(8, HIGH);   // in
  digitalWrite(6, HIGH);   // in
  analogWrite(9,1);   // in
}
void LbOut()// Linear Actuator B Out
{
  digitalWrite(8, HIGH);   // in
  digitalWrite(9, HIGH);   // in
  analogWrite(6,1);   // in     
}
void LbStop()// Linear Actuator B STOP
{
  digitalWrite(8, HIGH);   // stop
  digitalWrite(9, HIGH);   // stop
  digitalWrite(6, HIGH);   // stop

}

void loop()  {

  digitalWrite(0, LOW); 
  digitalWrite(4, LOW);   //  set pin low
  digitalWrite(7, LOW);   //

  SignalA=(analogRead(A0));
  SignalB=(analogRead(A5));


  Serial.print(SignalA);
  Serial.print("\t");
  Serial.print(SignalB);
  Serial.print("\t");



  Serial.println(" ");

  if (SignalA > 900)
    LaIn();

  if (SignalB > 900)
    LbIn(); 

  if (SignalA < 400)
    LaOut();

  if (SignalB < 400)
    LbOut();   

  if (SignalA > 400 && SignalA < 900)
    LaStop(); 

  if (SignalB > 400 && SignalB < 900)
    LbStop();   


  delay(10);     
}






Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy