Go Down

Topic: how do i call a void function() and why does it not compile?! (Read 722 times) previous topic - next topic

nemoskull

trying to write a function to output a servo pulse (1.5ms high, 22 ms low) but i do not under stand functions.

into QBASIC i would type CALL xxx
or in ASM i would type RCALL xxx

how do i do this in the arduino?


code will not compile.
Code: [Select]

void setup() {
  // put your setup code here, to run once:
  int a = 0;
  int b = 0;

  int axisX = 6;
  int axisY = 7;
  int axisZ = 8;
  int axisA = 9;
 
  int joystickX = 0;
  int joystickZ = 0;
  int triggers = 0;
  int joystickT = 0;
 
  pinMode(axisX, OUTPUT);
  pinMode(axisY, OUTPUT);
  pinMode(axisZ, OUTPUT);
  pinMode(axisA, OUTPUT);
  pinMode(joystickX, INPUT);
  pinMode(joystickZ, INPUT);
  pinMode(triggers, INPUT);
  pinMode(joystickT, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
 
   int a = 1500;
   
   servoX (int a, int axisX);
   
 
}

void servoX(int a, int axisX) {
 
  digitalWrite(axisX, HIGH);    //begin position pulse
  delayMicroseconds(a);
  digitalWrite(axisX, LOW);     //end position pulse
  delay(22);                //servo dead time, 22 ms
}

Graynomad

servoX (int a, int axisX);

Get rid of the yellow bits in the call.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Go Up