Go Down

Topic: RFID Again! (Read 7 times) previous topic - next topic

PaulS

Make a copy of the code, before making changes. When the changes work, save them.

The LED code is this:

Code: [Select]
int ledCnt = 5;
int LED[] = {13, 11, 9, 7, 5};


That code defines the number of LEDs to be manipulated and the pins that the LEDs are connected to.

Code: [Select]
 for(int i=0; i<ledCnt; i++)
 {
   pinMode(LED[i], OUTPUT);
 }


That code declares the LED pins to be output pins.

and:

Code: [Select]
   for(int i=0; i<ledCnt; i++)
     digitalWrite(LED[i], LOW);
   if(tag > 0 && tag <= ledCnt)
     digitalWrite(LED[tag-1], HIGH);


That code turns off all the LED pins, and turns on one LED pin, depending on which tag was read.

SubMicro

#6
Nov 28, 2009, 06:54 pm Last Edit: Nov 28, 2009, 06:57 pm by SubMicro Reason: 1
Here's what I did to use only one pin to go high with a good read.
Code: [Select]
int ledCnt = 5;
 int LED[] = {5};


Heres what I added to turn the pin low after enuff time to open the door.
Code: [Select]
for(int i=0; i<ledCnt; i++)
     digitalWrite(LED[i], LOW);
   if(tag > 0 && tag <= ledCnt)
     digitalWrite(LED[tag-1], HIGH);
       delay(5000);
       digitalWrite(LED[tag-1], LOW);


Woo Hoo!!! it works!
I know it's not pretty but it works, now I'm working on the keypad which will be much more difficult!
Thank you for letting me turn your code into a mess ;) and helping me understand it.
Any tips as where to insert the keypad code??
SubMicro
Electronics newbie & Home Machinist

SubMicro

#7
Nov 28, 2009, 08:20 pm Last Edit: Nov 28, 2009, 08:56 pm by SubMicro Reason: 1
Ok it doesn't work!  The LED only lights for one tag! I know it's just an ID10T problem, I'm working on it.

got now had to change this line
Code: [Select]
int LED[] = {5};
to this
Code: [Select]
int LED[] = {5, 5, 5, 5, 5};
SubMicro
Electronics newbie & Home Machinist

PaulS

Simpler would have been to change

int LED[] = {5};

to

int LED = 5;

and change:

Code: [Select]
for(int i=0; i<ledCnt; i++)
     digitalWrite(LED[i], LOW);
   if(tag > 0 && tag <= ledCnt)
     digitalWrite(LED[tag-1], HIGH);
       delay(5000);
       digitalWrite(LED[tag-1], LOW);


to:

Code: [Select]

   digitalWrite(LED, LOW);
   if(tag > 0 && tag <= ledCnt)
     digitalWrite(LED, HIGH);
   delay(5000);
   digitalWrite(LED, LOW);

SubMicro

I tried something similar but couldn't get it to work, then I tried your changes. I had to change one other line from

Code: [Select]
pinMode(LED[i], OUTPUT);

to

Code: [Select]
pinMode(LED, OUTPUT);

but after that worked like a charm. My problem was that, tag-1 couldn't figure it out!

Now I'm on hold untill I figure out the pin out for the keypad! my DVM is on the fritz. (cheap Harbor Freight crud) I need to invest in a decent DVM.

I'm through for the night, all the wires are blurring together! time for a break!
SubMicro
Electronics newbie & Home Machinist

Go Up