PROJECT HELP!! URGENT!!!

So my project was given to me and I have to finish in by 9pm so hopefully someone responds. Basically, I have three buttons that are suppose to control one buzzer. I also have a potentiometer that when you turn it, it displays on the screen "Volume (0-10)". The volume doesn't actually have to change, but if I get it to display from 0 to 10 in the volume then I am all set. I will post a screenshot of what displayed I am talking about. I already finished the button portion so that fine.

I thought if I did something like this it would work:
sensorPin = analogRead (A3);
if (sensorPin >= 0) {
lcd.print("Volume 0");
}
else if (sensorPin >= 93){
lcd.print("Volume 1");
}
else if (sensorPin >= 186){
lcd.print("Volume 2");
}
else if (sensorPin >= 279){
lcd.print("Volume 3");
}
else if (sensorPin >= 372){
lcd.print("Volume 4");
}
else if (sensorPin >= 465){
lcd.print("Volume 5");
}
else if (sensorPin >= 558){
lcd.print("Volume 6");
}
else if (sensorPin >= 651){
lcd.print("Volume 7");
}
else if (sensorPin >= 744){
lcd.print("Volume 8");
}
else if (sensorPin >= 837){
lcd.print("Volume 9");
}
else if (sensorPin >= 930){
lcd.print("Volume 10");

Screen Shot 2020-12-13 at 6.57.57 PM.png

Screen Shot 2020-12-13 at 6.57.57 PM.png

I thought if I did something like this it would work:

...so, what did happen?

Of course it won't. Analog input 930 is technically bigger or equals to (>=) 0, which will give you value of 0 and break out of the if statements.

You need to define the upper limit for your conditions too, not just the lower limit.

If You read the first topics that gives advice for new members You will manage better.
Learn to use a project name so later members can search and find the help You got. That's the idea of Forum. Try google on "PROJECT HELP!! URGENT!!!"
Learn what information You are expected to give.
Learn how to post code.
Learn that Frizings are not for engineering.That's sails peoples material.

Urgent.... What makes You use think that helps You? In what way are You special, more worth to help? Every member wants answers "today", not tomorrow. Urgent just brings a bad taste for the question.

linearity64:
Of course it won’t. Analog input 930 is technically bigger or equals to (>=) 0, which will give you value of 0 and break out of the if statements.

You need to define the upper limit for your conditions too, not just the lower limit.

Any input is >= 0.

Names that have “pin” in them sensibly refer to pin identifiers. So sensorPin is a terrible choice of name for the variable, usually you would see something like

const int sensorPin = A3;  //give the pin a name
...
sensorValue = analogRead (sensorPin);

volume = map(analogRead(potPin), 0, 1023, 0, 10);

aarg:
Any input is >= 0.

That was just an example.

Names that have "pin" in them sensibly refer to pin identifiers. So sensorPin is a terrible choice of name for the variable, usually you would see something like

const int sensorPin = A3;  //give the pin a name

...
sensorValue = analogRead (sensorPin);

And I agree.

Wawa:
volume = map(analogRead(potPin), 0, 1023, 0, 10);

+1

Should actually be:

volume = map(analogRead(potPin), 0, 1024, 0, 11);

for a better (equal) resolution between 9 and 10.

And there should be spaces behind the numbers in lcd.print, so "90" is not printed after you have displayed "10".
Or, better, print "volume" in setup() and only the number when it changes in loop(), to eliminate flicker.
Leo..

Wawa:
Should actually be:

volume = map(analogRead(potPin), 0, 1024, 0, 11);

for a better (equal) resolution between 9 and 10.

And there should be spaces behind the numbers in lcd.print, so “90” is not printed after you have displayed “10”.
Or, better, print “volume” in setup() and only the number when it changes in loop(), to eliminate flicker.
Leo…

+1

nicholaslamb88:
So my project was given to me and I have to finish in by 9pm so hopefully someone responds

When was the project given to you?

I can’t imagine that it was given to you at midnight for completion 21 hours later unless the person handing out the project was confident that you already had the skills to do the job.

…R