Pages: [1]   Go Down
Author Topic: Leds  (Read 280 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hola quiero saber lo siguiente:
si tengo en 1 salida del arduino conectado 4 leds, mediante programacion se pueden detectar cada led?
Logged

Narvik, Norway
Offline Offline
Edison Member
*
Karma: 24
Posts: 1042
electronics engineer, teacher.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If LED is connected from analog pin to GND and a 100k pull_up resistor.
Use analogRead to determine if a LED is connected or not.
Logged

Ny

Offline Offline
Sr. Member
****
Karma: 7
Posts: 266
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hola

Un Arduino que funcione con 5V puede detectar una LED roja que está en un pin digital (LEDs de otros colores pueden no ser detectadas – usted debe tratar).

Por ejemplo :



Code:
int testLED(int pin) {
  pinMode(pin, INPUT);          // desactivar la salida
  digitalWrite(pin, HIGH);      // activar la resistencia interna
  delay(1);
  int val = ! digitalRead(pin); // leer la entrada
  if (val) {                    // si LED encontrada
    digitalWrite(pin, LOW);     //  apagar la LED
    pinMode(pin, OUTPUT);       //  activar la salida
  }
  return val;
}


* testLED.png (16.52 KB, 355x247 - viewed 40 times.)
« Last Edit: September 16, 2014, 06:26:23 am by _pepe_ » Logged

Pages: [1]   Go Up
Jump to: