Arduino time(milli) and pressure sensor

I've succeeded to get an Arduino to work with a pressure sensor.

What I want to do is

  • when I put pressure on the sensor, after 5 minutes the led lights on.
  • it starts over again if there's no pressure on the sensor.
    Here's the program:
// FSR is verbonden met analoog 0 
int fsrAnalogePin = 0; 
// De LED is verbonden met pin 11 (pmw pin) 
int LEDpin = 11; 
// De analoge waarde van de fsr spanningdeler 
int fsrWaarde; 
// De helderheid van de led tussen 0 en 255 
int LEDhelderheid; 

void setup() { 
    // start de serial monitor 
    Serial.begin(9600); 
    pinMode(LEDpin, OUTPUT); 
} 

void loop() { 
    fsrWaarde = analogRead(fsrAnalogePin); 
    // print ‘Analoge waarde’ 
    Serial.print(“Analoge waarde = “); 
    // print de fsrwaarde op de monitor 
    Serial.println(fsrWaarde); 

    // maak van getallen tussen 0 en 1023 getallen tussen 0 en 255 
    LEDhelderheid = map(fsrWaarde, 0, 50, 0, 255); 
    analogWrite(LEDpin, LEDhelderheid); 
    delay(100); 
}

I've got this for the pressure sensor... now I need to combine it with 5 minutes and the led lights on when it's reached that 5 min of pressure.

i managed to do this but it aint enough...

unsigned long currentTime;
unsigned long startTime;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  currentTime = millis();
  startTime = currentTime;
}

    void loop() {
  currentTime = millis();
  // put your main code here, to run repeatedly: 
  Serial.println(currentTime);
  delay(1000); 

  if(currentTime-startTime > 6000) {
Serial.println("1 minuut voorbij");
startTime = currentTime;
  }
}

6000 is six seconds - perhaps you just need a longer time?

...R

ye i know about the time but that was only for testing.... i want to combine those 2 codes to realise my question..

i managed to do this but it aint enough...

Ain't it? EXACTLY wtf does that mean? It's impossible to make code match hand-waving.

I wrote a demo sketch to show how to manage several things at once in the first post in this Thread. It may give you an idea how to organize things.

...R

PaulS...dude im from holland and u got some serious issues... Robin2 thanks for the tip

peruwan:
PaulS...dude im from holland and u got some serious issues...

I guess you have the solution there as well :slight_smile: :slight_smile:

...R