"Map" and "fscale functions?

Hello ALL, I am trying to use on of these "functions" (if both really are) and need a little help please.

I went to the Reference and got the follwing code from there.. so NOT my code but from here.

Here's what was given:

int val;

void setup() { // begin setup

Serial.begin(9600); // okay, above is MY CODE, but needed.

val= map(val, 0, 800, 0, 16000); // I put in MY numbers .. tried reversing numbers, as we;; :wink:

Serial.print("Mapped value of 550 is "); Serial.println(550, val);delay(100000);

// val = map(val, 0, 1023, 0, 255); // the exact original code
// analogWrite(9, val);

The ERROR: When it prints to serial monitor I get either a small box for val or an &.
I was expecting a NUMBER between 0 to 16000 or the other way around.. 0 to 800 for val.

Now for fscale: I put in a "new" program ..

int j; int scaledResult; /// MY needed code

void setup() {
// put your setup code here, to run once:

}

void loop(){
for (int j=0; j < 200; j++) {
scaledResult = fscale( 0, 200, 0, 200, j, -1.5);

Serial.print(j, DEC);
Serial.print(" ");
Serial.println(scaledResult, DEC);
}
}

THE ERROR: 'FSCALE' NOT DECLARED IN THIS SCOPE

Oops.. closed on me .. to continue..

I was trying to add..

The IDE acts as if fscale is a Variable and NOT a function! The only thing I can come up with is:
I need a library which has this function command???

Thanks for kind help on this,
Andy_Ard

Please properly post the entirety of the code that is causing each problem, as described in the "How to use this forum" post.

Use code tags (</> button).

Think you need to declare the fscale function in order to use it..

Thank you for your reply, but, it doesn't help me much with the question. I DID put ALL the code this website gave as I documented if you read the WHOLE post and my own reply. I also showed the errors I was getting as stated in that POST.

My question was very simple and shoiuld require a simple answer.

I suppose you were referring to the fscale thingy .. Nevermind that now .. Way too complex.
I will stick to the simpler map function for now.

Can someone please expand a bit about that for me, then?

Andy_Ard.

If YOU would have posted ALL of your code instead of SNIPPETS, you would have an answer by now.. Your problem is most likely related to a missing/malplaced function prototype.

Map version - you need to put something into val before you do the map() of it. Serial.println() format is wrong. It looks like you're hoping the mapping will somehow magically happen in there. It won't.

I've never used fscale.

Steve

I asked rather long questions about map and fscale. Nevermind fscale for now as I will just use the simpler map function instead.

Again, here is what I got:

void setup() { // begin setup

Serial.begin(9600);

val= map(val, 0, 800, 0, 16000); MY numbers, though
Serial.print("Mapped value of 550 is "); Serial.println(550, val);delay(100000);

What it prints: Mapped value of 550 is &

Or the other way: Mapped value of 5550 is ⸮

What I expect: Some VALUE between the secon set of numbers from some value from the first.

Can someone suggest what I can do? The above code is from the "Reference" web page here.

Thank you,
Andy_Ard

I DID put ALL the code this website

Nope. The link in reply #2 gives ALL the code required.

Good luck with your journey. It will be a difficult one, given your attitude.

Yes, I DO need to put a value into val. I opened and copied the ONLY working example from examples I had and figured that out.

Instead of complaining about HOW I asked, if some one did THAT in the first place I would of been alright already, as well.

But, I DO want to thank ALL who replied. Especially the guy who referred me back to the fscale reference. He was right about the declaration error. Nevermind about fscale, though.. I give up on that!

Thanks again,
Andy