Hi!
I am using an I2C pressure sensor (connected to a rubber bulb) with an Arduino Uno. I need to accomplish the following in my software:
- Press a button to start collecting data
- Temporarily stop collecting data after 5 seconds
- Save the pressure value obtained in the 3rd second of collection as a variable to be used later
- Resume taking data once the pressure read by the sensor equals that of the "3rd second variable"
- Stop taking data after 30 seconds
I am struggling with this and would greatly appreciate any help! Thanks in advance!
What have you tried ?
Take a look at Using millis() for timing. A beginners guide, Several things at the same time and the BlinkWithoutDelay example in the IDE
Thank you so much for your reply!
Right now I have the following in my loop:
void loop()
{
time = millis();
if (digitalRead(7) == 1) { //Pin 7 is my start (green) button
greenbutton = true;
while (greenbutton = true) {
if(time<=5000){ // This is to hopefully collect data for the first 5sec after button is pressed
ssc.update(); //this collects data from the sensor
Serial.println(ssc.pressure());
}
Unfortunately, right now the serial monitor does not stop showing data after 5 seconds. I don't want to exit my entire loop because I need to collect more data after 5 seconds, I just need to pause and analyze data in between. Thanks again!
Please post your complete program or a small but complete example of it
UKHeliBob:
Please post your complete program or a small but complete example of it
And please post using code blocks
Read this before posting a programming question ...
This is an issue for sure:
while (greenbutton = true) {
should be:
while (greenbutton == true) {
But we still need to see a complete sketch.