Division comes out as Integer

Hey all

I’m new with this Squirrel coding, and I have a problem with a division:

led3.write(pot1.read()/65535);

Pot1.read is input from a variable resistor and I can see from the log that the value is between 0 and 65535.

The result is always 0 or 1. How do I get a decimal number to write to PWM_OUT?

Thanks in advance :o)

Mike

The Squirrel arithmetic rules are the same as C’s: if both operands are integers, the result is an integer, but if either one is floating-point, the result is floating-point.

Which basically means, divide by 65535.0 instead.

Peter

@Peter

Thanx alot. That solved it. I’m not really seasoned in C.

Mike :o)