help with writing code that will calculate three points to build a parabola based on the received function from the port monitor (the function of the example is ax^2+bx+c where a,b,c are coefficients), coordinates for each point are needed x and y
Can I ask what is the final purpose of your project?
The goal of my project is to build a parabola based on a function derived from a port monitor. To do this, I need to calculate the coordinates of three points on the parabola. The function has the form ax^2 + bx +c, where a, b and c are coefficients. I want to find the x and y values for each of these points using arduino
sorry, for the first time on this forum, I did not find the right category
Starting is half the work...
void setup() {
}
void loop() {
}
If you want to parse ax^2+bx+c you will need to recognize the coefficients, variables and exponents, factor and solve.
Start with reading the Serial monitor.
When you get the full array of characters, parse each character.
I have a problem writing the main part of the code.
the fact is that I do not understand how to extract the necessary coefficients from the resulting equation (I mean how to implement reading certain values from the resulting equation)
I can only guess what you mean by "extract", but here is some random example code:
float a = 1.2;
float b = -0.02;
float c = 75.;
float x = 2.0;
float y = a*x*x + b*x + c;
Serial.print(" y = ");
Serial.println(y);
This will be "parsing serial input" - Read the link in Post #10.
For some reason I think you got the assignment backwards.
A more interesting challenge would be to read the x,y coordinates of 3 points in the parabola and then calculate its coefficients. And display a graph on a tft display
My suggestion is to start by doing the calculations on a piece of paper. Then when the math is all sorted out, then you can approach writing a program to do the same.
Now if the issue is that you don't know how to approach the math problem, perhaps a mathematics forum would be a good place to start.
BTW, it's been a long time but I don't think your stated form is that of a parabola.
Show us the code that you've written.
Tell us what the problem with it is. Does it not compile? Show us the error messages. Does it run but not do what you expected? What did it do? What where you expecting it to do?
No one is going to write the code for you. Help you get your code working, certainly. Do it for you, certainly not.
See post #11 ![]()
Is this a school project?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.