Show Posts
Pages: [1] 2
1  Forum 2005-2010 (read only) / Syntax & Programs / Numpad LED on PS/2 Keyboard on: June 01, 2010, 01:20:38 am
how to make the numpad led (num lock led) blink ?

to arduino is connected a standard ps/2 keyboard .... i use the PS2Keyboard.h library....
2  Forum 2005-2010 (read only) / Syntax & Programs / Re: WHILE problem.. need help! on: May 16, 2010, 02:58:35 pm
look people , i know my code is fine !  I need only  the corect sintax !

look people , I can do :
Code:
If (i==1) digitalWrite(ledPin, digitalRead(pPin));
if (i==0) digitalWrite(ledPin, LOW);

but I need while (i==1) to do  digitalWrite(ledPin, digitalRead(pPin));
and while (i==0) to do digitalWrite(ledPin, LOW);

the value of i is changed before this stuff !  what is the right sintax ?
3  Forum 2005-2010 (read only) / Syntax & Programs / Re: WHILE problem.. need help! on: May 14, 2010, 07:01:57 am
when i do stuff like
Code:
if (i==1) digitalWrite(ledPin, HIGH);    
if (i==0) digitalWrite(ledPin, LOW);
it works !

but with while  no ...
4  Forum 2005-2010 (read only) / Syntax & Programs / Re: WHILE problem.. need help! on: May 14, 2010, 06:57:40 am
I can use  and the original stuff like

Code:
if (i==1) { while (i!=0) {
digitalWrite(ledPin, digitalRead(pPin));}}
else if (i==0) digitalWrite(ledPin, LOW);

its not the point.  the problem i think is in while ...  the value of i is not changed in while.
5  Forum 2005-2010 (read only) / Syntax & Programs / Re: WHILE problem.. need help! on: May 14, 2010, 06:40:09 am
Groove ,  Ok, I changed ... still not switching !

Code:
#include <ps2.h>
PS2 kbd(3, 4); //3- clock; 4- DATA
int pPin = 53; //sensor pin
int ledPin = 13;
void kbd_init()
{  char ack;  kbd.write(0xff);   ack = kbd.read();   ack = kbd.read();}
//------------------------------------------------------
void setup()
{   kbd_init();
 pinMode(pPin, INPUT);
 pinMode(ledPin, OUTPUT);}
//------------------------------------------------------
void loop()
{int i=2;
  unsigned char code;
       code = kbd.read();  
//--------------------------------
if (code==0x69) {i=1;}
if (code==0x72) {i=0;}
//------------------------------------------------------

switch (i) {
  case 0:    
    digitalWrite(ledPin, LOW);
    break;
  case 1:
while (i!=0){
  digitalWrite(ledPin, digitalRead(pPin));}   //the problem is here ... a can not switch to 0 case, because in the bosy of while, the value of i is not refreshing !  is there something like echo in arduino language
break;}

}

6  Forum 2005-2010 (read only) / Syntax & Programs / Re: WHILE problem.. need help! on: May 14, 2010, 06:37:58 am
Groove ,  I need to use while , because I have two states   when I pres 1 on keyboard (i=1) and 0 on the keyboard(i=0) !  by presing 1, I activate my system, by pressing 0, I diactivate ...
7  Forum 2005-2010 (read only) / Syntax & Programs / Re: WHILE problem.. need help! on: May 14, 2010, 06:32:32 am
The whole code :
Code:
#include <ps2.h>
PS2 kbd(3, 4); //3- clock; 4- DATA
int pPin = 53; //sensor pin
int ledPin = 13;
void kbd_init()
{  char ack;  kbd.write(0xff);   ack = kbd.read();   ack = kbd.read();}
//------------------------------------------------------
void setup()
{   kbd_init();
 pinMode(pPin, INPUT);
 pinMode(ledPin, OUTPUT);}
//------------------------------------------------------
void loop()
{int i=2;
  unsigned char code;
    for (;;) {    code = kbd.read();  
//--------------------------------
if (code==0x69) {i=1;}
if (code==0x72) {i=0;}
//------------------------------------------------------

switch (i) {
  case 0:    
    digitalWrite(ledPin, LOW);
    break;
  case 1:
while (i!=0){
  digitalWrite(ledPin, digitalRead(pPin));}   //the problem is here ... a can not switch to 0 case, because in the bosy of while, the value of i is not refreshing !  is there something like echo in arduino language
break;

}}
8  Forum 2005-2010 (read only) / Syntax & Programs / Re: WHILE problem.. need help! on: May 14, 2010, 03:25:42 am
no!   the question is , how to change the value of "i"  when "i" is in the body of while ! when the value of "i" is changed in the main loop...
9  Forum 2005-2010 (read only) / Syntax & Programs / Re: WHILE problem.. need help! on: May 13, 2010, 03:32:46 pm
OK  pPin is a DSC pir sensor ... when is no movement its LOW  when is movement its HIGH  

i==1 is ARMED state ...  when the pPin is HIGH , it lighs the led
when pPin is LOW, the led is turned off...

i==0 is NORMAL status ... whatever pPin state is , the led is turned off
10  Forum 2005-2010 (read only) / Syntax & Programs / Re: WHILE problem.. need help! on: May 13, 2010, 10:01:01 am
I see the problem in the fact that in the body of while , the value of "i" is without changes, when in the program the i is changing.
Or Im wrong ?
11  Forum 2005-2010 (read only) / Syntax & Programs / Re: WHILE problem.. need help! on: May 13, 2010, 09:55:05 am
I connected the ps2Keyboard to the board  for ex.  i=1 is when I press button "alt" and i=0 when I press "ctrl" !   i changes the value before the while stuff ...the while's are at the and of the code ...

the body are not the same...  

in i==1

if (digitalRead(pPin) == HIGH) digitalWrite(ledPin,HIGH );
if (digitalRead(pPin) == LOW) digitalWrite(ledPin,LOW);}

and in i==0 I have

if (digitalRead(pPin) == HIGH) digitalWrite(ledPin,LOW );
if (digitalRead(pPin) == LOW) digitalWrite(ledPin,LOW);}
12  Forum 2005-2010 (read only) / Syntax & Programs / WHILE problem.. need help! on: May 13, 2010, 08:01:38 am
So , I have an  "i" variable , that has to lets say states:  s=0 and s=1...

When (i==1) I need to do

Code:
if (digitalRead(pPin) == HIGH) digitalWrite(ledPin,HIGH );
if (digitalRead(pPin) == LOW) digitalWrite(ledPin,LOW);

and when (i==0) to do
Code:
if (digitalRead(pPin) == HIGH) digitalWrite(ledPin,LOW );
if (digitalRead(pPin) == LOW) digitalWrite(ledPin,LOW);

When Im doing this with  WHILE it works only in a half.. the second part with (i==0) is ignored !

Code:
while(i==1) {
if (digitalRead(pPin) == HIGH) digitalWrite(ledPin,HIGH );
if (digitalRead(pPin) == LOW) digitalWrite(ledPin,LOW);}

while(i==0) {
if (digitalRead(pPin) == HIGH) digitalWrite(ledPin,LOW );
if (digitalRead(pPin) == LOW) digitalWrite(ledPin,LOW);}
13  Forum 2005-2010 (read only) / Syntax & Programs / PS/2KEYBOARD Password check on: May 07, 2010, 01:44:50 pm
Hello!

I want to light the led  when the password entered from the keyboard is the same as programm for leds ON and other password for led OFF. I use only the numpad.. so there is only numbers ...   and I would like to make a delay after 3 incorect passwords entered...

something like :
passON=12345+; ( the + is the button '+' 0x79)
passOFF=12345enter ( the enter is the button 'Enter' 0xE0 0x5A ) if am right
if (passON== inpass)
digitalWrite(ledPin, HIGH);
if (passOFF== inpass)
digitalWrite(ledPin, LOW);

I'll use  thes code ... I'm new in arduino, so i'll be happy if someone will help me...

 
Code:
#include <ps2.h>

PS2 kbd(3, 4);

void kbd_init()
{
  char ack;
  
  kbd.write(0xff);  // send reset code
  ack = kbd.read();  // byte, kbd does self test
  ack = kbd.read();  // another ack when self test is done
}

void setup()
{
  Serial.begin(9600);
  kbd_init();
  }
void loop()
{int m;
  unsigned char code;
  
  for (;;) { /* ever */  
    /* read a keycode */
    code = kbd.read();
    
    
     }
}
14  Forum 2005-2010 (read only) / Troubleshooting / Re: Interfacing with Parallax RFID Reader/Writer on: January 23, 2011, 03:15:11 pm
15  Forum 2005-2010 (read only) / Troubleshooting / Re: Interfacing with Parallax RFID Reader/Writer on: November 04, 2010, 04:46:37 am
progress ! the led turned in to red ...  thanks ! mySerial.print(RFID_READ, BYTE); its right !

Quote
When the module is successfully powered-up  and is in an idle state, the LED will be GREEN;
when the module is in an active state (for example, searching for a valid tag or performing an operation
on the tag), the LED will be RED.  

Pages: [1] 2