What I am trying to accomplish is this: I have an analog sensor (a stretch sensor, but it returns values like a potentiometer) which must control servos. Since the stretch sensor changes resistance over time and use, I need to set up my minimum and maximum variables at the outset of my program. I have a button connected as well as an indicator LED for this purpose. I want to be able to
turn on the Arduino, enter setup(),
wait for the button push,
when the button is pushed, set minimum variable to whatever is read by the sensor,
blink LED to indicate that is set,
wait for the button to be pushed again,
when it is pushed a second time, set the maximum variable to the sensor reading (it has been stretched to full range now),
blink LED again to indicate this is set,
begin the loop(), in which the servos' positions are mapped from 0 to 180 degrees based on the sensor input, using minimum and maximum which were determined in setup().
None of my for or while loops seem to work in setup(), and I cannot figure out why. Is it possible to create loops that wait for a button push in setup()?
wow me to i thought for a sec somethig was wrong with my browser.
We got to see some code to give u much help.
why does your loops/ and configuration have to run in setup.
could create a initialize/config function u call useing an if statment and is never called until reset in loop. try moveing it around.
or u dont need afunction
if (setRangeAlreadyRun == False){
//check you max /min values and get it all set here
setrange.... = true;
}
//then run your other code
reserve setup for initialize var nameing etc.
i think it works better but not alwasy obviously.
but if what u did doesnt work try something like that
Sorry, there isn't much code to see, because I kept trying different expressions and erasing them in favor of others when I couldn't get them to work. What I experienced was every for loop or switch expression I used in the setup() would just run through that code without pausing and then end up in the loop(). I hadn't considered putting an expression in the loop() part which could run only once.
If I try again and fail I will post the code that I failed with.
thebfs:
wow me to i thought for a sec somethig was wrong with my browser.
We got to see some code to give u much help.
why does your loops/ and configuration have to run in setup.
could create a initialize/config function u call useing an if statment and is never called until reset in loop. try moveing it around.
or u dont need afunction
if (setRangeAlreadyRun == False){
//check you max /min values and get it all set here
setrange.... = true;
}
//then run your other code
reserve setup for initialize var nameing etc.
i think it works better but not alwasy obviously.
but if what u did doesnt work try something like that