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;
}
}