"Long Press" using LDRs


hi, working on project in witch want fire laser @ multiple ldrs (one @ time) change brightness of leds, have circuit working need adding feature:

as stands shine laser @ chosen ldr , led lights set brightness, , led lights up, can ignored. want have when shine laser @ specific ldr 3 seconds, locks choice place until shine @ ldr 3 seconds. hope makes sense, in advance !!!

here code far:

code: [select]

const int ldr0 = a0;
const int ldr1 = a1;
const int ldr2 = a2;
const int led = 9;
const int led1 = 2;
const int threshold = 960;

void setup() {
  pinmode(led, output);
  pinmode(led1, output);
  serial.begin(9600);
}

void loop() {
int ldr0_val = analogread(ldr0);
  delay (50);
int ldr1_val = analogread(ldr1);
  delay(50);
 
  if (ldr0_val > threshold) {
 analogwrite(led, 10);
 digitalwrite(led1, high);
  }
  else if (ldr1_val > threshold) {
    analogwrite(led, 150);
  }
  else {
    digitalwrite(led,low);
    digitalwrite(led1,low);
  } 
  serial.println(ldr0);
  delay(50);
}

this thread has code different "keypress" times can adapted needs.

...r


Arduino Forum > Using Arduino > Programming Questions > "Long Press" using LDRs


arduino

Comments