Hi,
I'm trying to light a led using bluetooth and then have it on for 3 minutes, then turn off. The problem is with the "timer", it dosen't turn off after 3 minutes (180000ms). Can anyone se what i'm doing wrong? I have just started programming so please be nice ![]()
int LED = 13;
int timer = 180000;
boolean offswitch = true;
unsigned long previousMillis = 0;
void setup() {
Â
 Serial.begin(9600);
 pinMode(LED, OUTPUT);
Â
}
void loop() {
 if(Serial.available() > 0){
  char data = Serial.read();
  if (data == 'a'){
   digitalWrite(LED, HIGH);
   offswitch = false; Â
  }
 }
Â
 if (offswitch == false){
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis > timer){
   previousMillis = currentMillis;
   digitalWrite(LED, LOW);
   offswitch = true;
  }Â
 }
Â
}