i want to turn on/off a LED by a password without using a keypad
.. need just char[5],
i want to put the password of 4 character at the time and test if true, Led X high, else, Led X low
.....
......
this is an exemple of my own work .... but it dosent work correctly
.....
.....
char data = ' '; //Variable for storing received data
char cod[5]=("1234") ; //code to test (1234);
int v= 0; //counter
void setup()
{
Serial.begin(9600);
pinMode(8, OUTPUT);
pinMode(10, OUTPUT);
}
void loop()
{
digitalWrite(8,HIGH); //alwayse on
for (int j=0; j<4; j++)
{
if(Serial.available() > 0) // Send data only when you receive data:
{
data = Serial.read(); //Read the incoming data & store into data
Serial.print(data); //Print Value inside data in Serial monitor
Serial.print("\n");
if (data==cod[j])
{
v++;
}
}
}
if (v==4)
{digitalWrite(10,HIGH);}
}
.... need a smart solution ...
please ...
thanks aloot
1.) Please ALWAYS wrap your code in [ code ] [ /code ] tags.. (use the </> icon if needed..)
2.) If you dont want to use a keyboard/keypad to enter in your 'password'... how do you plan on entering it? What event lets you interact with your project?
3.) Where is this serial data coming from that you are attempting to parse in the code above?
I think reading the serial basics thread would help you out:
meaning by dosent work correctly m ... it need 4 time giving the right code to turn on the LED 10
.. all what i need is how to turn on a led using a password (caracters,numbers,...)
...
the serial come from a bluetooth sumilation