//My calibrated distance sensor - SHARP 2Y0A02 F 9Y // out[] holds the values wanted in cm int out[] = {150,140,130,120,110,100, 90, 80, 70, 60, 50, 40, 30, 20}; // in[] holds the measured analogRead() values for defined distances // note: the in array should have increasing values int in[] = { 90, 97,105,113,124,134,147,164,185,218,255,317,408,506}; val = analogRead(A0); cm = multiMap(val, in, out, 14); // Some "sinus" approximation int out[] = {0,316,601,827,972,1023,972,827,601,316,0,-316,-601,-827,-972,-1023,-972,-827,-601,-316, 0 }; // 21 // note: the in array should have increasing values int in[] = {0,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000}; val = analogRead(A0); // connect a potmeter? x = multiMap(val, in, out, 21); // A normal distribution int out[] = { 0, 5, 20, 50, 80, 95, 100, 95, 80, 50, 20, 5, 0 }; // 13 // note: the in array should have increasing values int in[] = {0,80,160,240,320,400,480,560,640,720,800,880,960}; val = analogRead(A0); x = multiMap(val, in, out, 13); y = multiMap(val/2, in , out, 7); // using only left halve of the array. // S curve int s[] = { 0, 0, 10, 30, 70, 130, 180, 320, 350, 370, 380}; // 11 // note: the in array should have increasing values int in[] = { 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}; val = analogRead(A0)/10; x = multiMap(val, in, s, 11); // trapezium int trapx[] = { 0, 100, 100, 0}; // 4 int trapy[] = { 0, 100, 200, 0}; // 4 int trapz[] = { 0, 400, 200, 0}; // 4 // note: the in array should have increasing values int in[] = { 0, 100, 700, 1000}; val = analogRead(A0); x = multiMap(val, in, trapx, 4); y = multiMap(val, in, trapy, 4); z = multiMap(x, in, trapx, 4); // can you see what it does?