Arduino Library problem

hi,

i'm currently building a library to help simplify the way in which led's and switches are controlled. it started off as a little project to make my first library but has escalated into buttons led's and pwm Led's

my problem is this: i want to have a function that you can pass a float in as a fraction

Pwmled led1;
led1.pin(6);
led1.on(2/5);

but this doesn't work, to get it to work i have to use (float):

led1.on((float)2/5);

and then it works.

is there any way in which i can make the function work without this unnecessary (float)?

sorce code: BasicFn Library

i want to have a function that you can pass a float in as a fraction is there any way in which i can make the function work without this unnecessary (float)?

You could try actually using floats as the argument:

led1.on(2.0/5.0);

i compile and get this error:

 In function 'void loop()':
error: call of overloaded 'on(double)' is ambiguousC:\Program Files\arduino-0018\libraries\BasicFn/BasicFn.h:46: note: candidates are: void Pwmled::on(int)

C:\Program Files\arduino-0018\libraries\BasicFn/BasicFn.h:47: note:                 void Pwmled::on(float)

i think this is because i have
on();
on(int);
on(float)

-James

I think we need to see more of your code, then. Specifically, the header file.

if you look at the initial post you can see the whole code.

as for the test sketch

#include <BasicFn.h>


Pwmled led1;

void setup(){

  led1.pin(6);
  Serial.begin(9600);

}
void loop(){

led1.on(1.0/2.0);
Serial.println(led1.state());

}

So, try led.on(2.0f/5.0f); or overload the on method to take two integers or call the function with a float argument:

float ledVal = 2.0/5.0;
lod.on(ledVal);

yes thats a good idea.

i have modified the code to run with two integers

Pwmled::go(int i, int y){...}

thanks for the help.

-James