Pages: [1]   Go Down
Author Topic: In function 'void loop()': error: invalid convers  (Read 1323 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey everyone I keep getting this error:

 In function 'void loop()':
error: invalid conversion from 'int (*)()' to 'long unsigned int' In function 'int calcDelay()':


I'm wanting to use the value returned from a function as the value for delay();  The code in the loop is a series of servoWrite. values and delays that are generated from an animation.

any insights as to what I'm doing wrong would be appreciated

Nick

#include <Servo.h>

Servo myServo1;

int servoPin1 = 50;
int inputPin1 = 0;

int minPulse = 500;
int maxPulse = 2700;

int  convVal;
int inValue;
int inmin = 0 ;
int inmax = 1024;

int outmin = 1000;
int outmax = 10;

void setup(){
   myServo1.attach(servoPin1,minPulse,maxPulse);    
  
}

void loop()
{
myServo1.write(0);delay(calcDelay);
myServo1.write(6);delay(calcDelay);
myServo1.write(12);delay(calcDelay);
myServo1.write(19);delay(calcDelay);
myServo1.write(26);delay(calcDelay);
myServo1.write(34);delay(calcDelay);
myServo1.write(42);delay(calcDelay);
myServo1.write(49);delay(calcDelay);
myServo1.write(57);delay(calcDelay);
myServo1.write(65);delay(calcDelay);
myServo1.write(73);delay(calcDelay);
myServo1.write(81);delay(calcDelay);
myServo1.write(89);delay(calcDelay);
myServo1.write(97);delay(calcDelay);

///... and more values like this
}
int calcDelay()
{
inValue = analogRead(inputPin);
convVal = map(inValue,inmin,inmax,outmin,outmax);

  
return convVal;  
}




« Last Edit: November 17, 2010, 12:15:16 pm by npuckett » Logged

UK
Offline Offline
Faraday Member
**
Karma: 17
Posts: 2884
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need to call calcDelay(), not just dereference it.

Learning about arrays and for loops may reduce your code size too.
« Last Edit: November 17, 2010, 12:18:35 pm by GrooveFlotilla » Logged

Per Arduino ad Astra

0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the quick reply - I knew it had to be something simple I wasn't seeing.

Logged

Pages: [1]   Go Up
Jump to: