//constrain dan mapping - purwarupa3d.com

byte potPin = A0;
int constrainValue;
int mappingValue;
int maxValue;
int minValue;

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {

int analogSignal = analogRead(potPin);
constrainValue = constrain(analogSignal, 50 , 100);
mappingValue = map (analogSignal,0,1024,0,225);
maxValue = max (analogSignal,20);
minValue = min(analogSignal,200);
Serial.print("Nilai balik constrain= ");
Serial.println(constrainValue);
Serial.print("Nilai balik map= ");
Serial.println(mappingValue);
Serial.print("Nilai balik max= ");
Serial.println(maxValue);
Serial.print("Nilai balik min= ");
Serial.println(minValue);
delay (1000);
}