Page 1 of 1
R / C receiver ouput from c ++ to flowcode
Posted: Wed Sep 07, 2016 8:08 am
by Monie Jacobsen
Is there anyone here who will be assisting with the following
In Arduino used "map" procodure.
How to make "map" procodure in Flowcode 7 ??
Can you give a code eksemple?
Code:
Channel 2 = map (Channel 2, 970, 1970, 0, 255); // Change input about two 0-255 Bytes
Signal from receiver 970-1970
See Web link here!
http://forum.arduino.cc/index.php?topic=3922.0
Re: R / C receiver ouput from c ++ to flowcode
Posted: Wed Sep 07, 2016 11:28 am
by Benj
Hi Monie,
Can you just do something like this.
Code: Select all
FloatVar = Number (970 to 1970)
FloatVar = FloatVar - 970.0
FloatVar = FloatVar / 3.90626
NewNumber = FloatVar
NewNumber should now be in the range 0 - 255.
Or if you don't want to use floating point maths then you could use this to get an approximation 0 - 250.
Code: Select all
IntVar = Number (970 to 1970)
IntVar = IntVar - 970
IntVar = IntVar / 4
NewNumber = IntVar
You may need to do additional bounds checking on Number to ensure you are in range.
e.g.
Code: Select all
if ( (Number >= 970) && (Number <= 1970) )
Yes : Code from above...
No: NewNumber = 0
Re: R / C receiver ouput from c ++ to flowcode
Posted: Wed Sep 07, 2016 11:47 am
by Monie Jacobsen
Hi Benj
Many, many thanks for the info.
Re: R / C receiver ouput from c ++ to flowcode
Posted: Mon Sep 19, 2016 12:59 pm
by Benj
Flowcode example of the map function now available here:
http://www.flowcode.co.uk/mmforums/viewt ... 136#p77099