# graph between 2 points

so im trying to graph between 2 points using 2 pots as a reference of the table and a pressure sensor as the point selection betweenn the 2 points so if i set the 2 pots at the points to give me a selection say 5-10 and id use the pressure sensor to pick the point between them say 8 for this instance, ony problem is i dot even know where to begin to build a program like that

If this thread was any clearer it would probably be an XY problem http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem

Given beginning grade school reading and writing skills, this could be a tough project.

wow, sorry if at first i seemed illiterate, that was not my intention. what i’m trying to get accost is i understand the math, but i don’t understand the coding language enough to put what i would like to do in a phrase that the arduino can understand. i know i need a minimum of 4 variables. one to hold the input the pressure sensor gives, one each for the potentiometer readings and one for the variable that is come upon from the correlation of the pressure sensor signal upon the line between the two potentiometer readings, i don’t know how to describe it, in automotive its refereed to as a linear ramp rate, but i don’t know what it looks like as a program, i cant make the for statement work as iv tried so i’m trying to get help in putting it down in language thank you for the help of those who thought i was having trouble with the math but that’s not what i need

thankyou for any and all help

cw408: i understand the math, but i don't understand the coding language enough to put what i would like to do in a phrase that the arduino can understand.

If you can write it out in algebra, I'll show you the code. I'm still not 100% on what number you want to come up with in the end. But if you got the math, going from that to code is easy.

Say you had two ranges, a to c with b in the middle, and you wanted to map it into the range x to z, with y in the middle as the new point.

Then (b-a)/(c-a) is the percent of the range that b is between a & c.

Ex. range 4 to 10 with b at 7: (7-4)/(10-4) = 3/6 = 50%, or 0.5

If range 2 is then 20 (x) to 90 (z), then y is at x + 50% of (z-x): ((90-20) * .5) + 20 = 55 Doing the programming for that is similar. Do it in steps, probably using floats.

easy one use map value= map(pressure,potlow,pothigh,lowvalue,highvalue)

i use it a lot for calibration. another way is to use software to put the calibration values in, so you only need 1 analog input and it is steadier.

ok so i figured out more in depth of what i want to do,im essentially controlling the pwm value of a motor but in a progressive manner, id like to use 2 potentiometers to control values m and b and a analog sensor to control value x causing value y to be the pwm value of the motor as many have figured out im using the equation of a straight line y=mx+b but id like to also add a third potentiometer to set the value of when the motor starts based upon the value of x y= mx+b val=pot2*sensor+pot1 val=pwm, pot2= slope, sensor is how far on the line, and pot1 is the start point is it that simple? or am i takeing something complex and makeing it too simple?? and i guess id add and (if sensor>value) do this clause to make it use my start value?

cw408: ok so i figured out more in depth of what i want to do,im essentially controlling the pwm value of a motor but in a progressive manner, id like to use 2 potentiometers to control values m and b and a analog sensor to control value x causing value y to be the pwm value of the motor as many have figured out im using the equation of a straight line y=mx+b but id like to also add a third potentiometer to set the value of when the motor starts based upon the value of x y= mx+b val=pot2*sensor+pot1 val=pwm, pot2= slope, sensor is how far on the line, and pot1 is the start point is it that simple? or am i takeing something complex and makeing it too simple?? and i guess id add and (if sensor>value) do this clause to make it use my start value?

I still haven't a clue what you're trying to achieve. At the end of the day it's just a single PWM signal you're going to generate. Why the heck you'd want 2 pots AND a pressure sensor to dictate what speed a motor runs at is beyond me.

its because im trying to allow for human interface with the object as well as environmental interface with the project and the only way i understand to do that is with 2 pots to set values (so they can be changed at will) and a pressure sensor to react to the environment and stresses placed on the object i dont actually know of a simpler way to achieve my goal than how im currently going about it

Hi, you are talking about points with 2 dimensions, X and Y. Now when I was taught graphs my teacher would crucify us if we did not declare what the X and Y axis were. Now what is your X axis and what is your Y axis. X, PWM and Y pressure or X pressure and Y PWM.

Tom..... :)

y=mx+b pwm=slope*sensor input+y intercept

the pwm is the output the slope is pot2 (the pregression setting) the sensor is the progression along the x axis showing and the y intercept is the other sensor showing where the progression starts

so now that i know what i want does anyone know how to write that in code??

so now that i know what i want does anyone know how to write that in code??

No one else knows what you want.

Why not take a couple of minutes to think things through clearly and actually answer the questions that have been posed?

It will help if you write in the English language, with sentence structure and punctuation.

cw408: y=mx+b pwm=slope*sensor input+y intercept

the pwm is the output the slope is pot2 (the pregression setting) the sensor is the progression along the x axis showing and the y intercept is the other sensor showing where the progression starts

Y intercept cannot be a sensor. Do you mean the value from a sensor?

So right now you're up to this:

``````pwm = analogRead(pot2) * (analogRead(sensor) + analogRead(otherSensor);
``````

I wonder if other sensor was supposed to be pot1.

This also suffers from some scaling issues. The analog reads will vary from 0 to 1023 but the pwm can only vary from 0 to 255.

Again, I think you need to work on the math here before you try to code it. You have three values, 2 pots and a sensor, that can all be 1023. Show me with math how you get a number from 0 to 255 that suits your needs and I'll show you how to write that into code. But I can't guess at the math you want and your description is ambiguous.

sorry i thought i was using good grammar? please bare with me if its not proper im only 14 so im using what i know of punctuation and writing. what im trying to do is make an output based on 3 inputs to control a motor, the turning on of it as well as the speed, what im trying to use is y=mx+b the formula for a straight line and how im trying to set it up is as follows

y=mx+b

m=slope setting //how steep the progression of motor speed is by a 10k potientometer

x= sensor value //a pressure sensor telling the motor when to turn on and pressure causes the motor to follow the slope value

b= start value // the pressure at which the motor will turn on, im using an analog sensor similar to a potientometer, this is also the y intercept i believe

y=pwm output value // and the output of the motor will be the value of where the pressure sensor sets it along the slope of the line but the pressure sensor will need to be set past the preset value before the motor turns on

http://www.mathsisfun.com/data/straight_line_graph.html

i use visuals so what im trying to achieve is the graph in the website, a chart that isnt determined by time but the inputs you select where

m=the steepness of the slope, so the rate at which the pwm value increases

x=the value of the pressure sensor telling where it is on the slope

b= the pressure at which my analog pressure sensor triggers the motor to turn on and also the start pwm value

im trying to make this same basic concept as in the website but having the x-axis being the pressure sensor value and the y axis being pwm output

is this a good explaination because i dont understand what concept im not getting out if this isnt?

im sorry im trying to the best of my abilitys to write with proper grammar and get my idea acrost , please keep in mind im only 14, so i am actually using the best grammar i know of im trying to make a progressive control based on x and y graph where the y-axis is pwm and the x axis is the pressure signal y=mx+b y=the pwm of the motor m= the slope of the progression x = the pressure acting as a slider along the graphed line b=the start point for the progression

http://www.mathsisfun.com/data/straight_line_graph.html

this would be a good example i think but i dont want to start the motor turning on untill a certain pressure is reached and i want the pwm to progress with the preset slope, so im trying to use 2 pots. one to set the motor start point. and one to set the slope of the progression. and a pressure sensor to tell the arduino where in the progression it is

is this better?? anything im leaving out or not explaining id like to do ??

By age 14, you should have learned that there are rules for writing English sentences. They are considered very important by people who will judge you.

In addition your communication skills are poor. Unless you work to improve both, this will haunt you for the rest of your life. In particular you will have trouble in school and later, in applying for work. Give yourself a chance!

actually most things have spell check its easyier to use the spoken language than than the written language, and no one uses paper anymore makeing spell check in use on everything, and it seems that people are more interested in telling me i dont understand english than saying hey that program wont work but what your trying to do would be more like this, all i needed is programing help, if you dont understand what im saying could you ask "hey what do you mean when you say sentence x?" anyways thanks delta g for your insight it looks like i just need to write a formula with the arduino reading the values for the formula and putting the output as the pwm value, i think i understand what needs done now after much reading and the little bit of help i got between people telling me that my grammar is bad and that they dont understand what im helping, so thankyou to those who actually helped if it seems im being rude, im sorry but why dont you trying asking someone for help just to have them tell you your inferior at something.