Hello All –
I’m working on the ‘ultimate cat toy’ project and decided to learn Ardiuno programming to control it. I’m using the map() function to control speed and felt like it wasn’t acting the way I wanted. I made a simple program to see exactly what the map fucntion was doing and am curious about the output…
Below is the program…
int val = -25;
int cycle = 0;void setup() {
Serial.begin(9600);
}void loop() {
do {
int valmap = map(val,0,10,0,255);
cycle++;
val++;Serial.println("***************************************");
Serial.print("Count = ");
Serial.println(cycle);
Serial.print("Input = ");
Serial.println(val);
Serial.print("Map = “);
Serial.println(valmap);
Serial.println(” ");} while (cycle < 305);
delay(1000);
}
For some reason it won’t let me copy the serial monitor output, but I don’t reach an output of 255 until my input value is 11. So, if I’m controling PWM using this fucntion, the input would have to go to 11 (Spinal Tap?)…
Is this correct? Am I missing Something?
-CW