Hello. I have this problem with map() not really being recognised it seems. If it matters, I am using Arduino IDE 1.8.1, and a MEGA 2560 board.
Currently I am trying to make a class work,
DSDroneSignal.h
#include "Config.h"
class DSDroneSignal
{
public:
//DSDroneSignal(); // Constructor set default ppm-values
void EditControl(char InputSegment[]);
void ChangeVelocity(int Channel, int Value);
private:
int PPM[CHANNEL_NUMBER];
};
and DSDroneSignal.cpp,
void DSDroneSignal::EditControl(char InputSegment[])
{
if ( InputSegment[0] == ( ('t' || 'r' || 'a' || 'y') || ('T' || 'R' || 'A' || 'Y') ) )
{
// TODO: Make channel recogniser-function instead,
int ChannelIndex = 1;
int VelocityRate = atoi(&InputSegment[1]);
int NewVelocity = map(VelocityRate, 0, 100, CHANNEL_MIN_VALUE, CHANNEL_MAX_VALUE);
DSDroneSignal::ChangeVelocity(ChannelIndex, NewVelocity);
}
};
void DSDroneSignal::ChangeVelocity(int Channel, int Value)
{
DSDroneSignal::PPM[Channel] = Value;
};
And I get this error,
sketch/DroneSignal.cpp: In member function 'void DSDroneSignal::EditControl(char*)':
DroneSignal.cpp:11: error: 'map' was not declared in this scope
int NewVelocity = map(VelocityRate, 0, 100, CHANNEL_MIN_VALUE, CHANNEL_MAX_VALUE);
Inside of the Config.h file are the capitalised constants given as well as the standard library included (<stdlib.h>).
I dont' really see anyone having this problem except for one guy in 2008, because map() was recently introduced back then, and he had not updated his software. Now, I am borrowing this Arduino from someone else, but I doubt it is that old.