Hi, just asking on how will i grab the value of the integer when i pushed the button.
i've declared test as char as a container for the value that i needed.
now, when i pressed button, the value of the button should be "button=123"
and for the second button, "button1=456" when i pressed. but i can't get it.
int button=2;
int button1=3;
int buttonstate=0;
int buttonstate1=0;
char test;
char password={test};
void setup()
{
pinMode(button,INPUT);
}
void loop()
{
buttonstate=digitalRead(button);
buttonstate1=digitalRead(button1);
if(buttonstate==HIGH)
{
test="123";Â //This should be the value of the "char password"
}
if(buttonstate1==HIGH)
{
test="456"; //This should be the value of the "char password"
}
}
int button=2;
int button1=3;
int buttonstate=0;
int buttonstate1=0;
char *test[4];
//char password={test};
void setup()
{
 pinMode(button,INPUT);
}
void loop()
{
 buttonstate=digitalRead(button);
 buttonstate1=digitalRead(button1);
 if(buttonstate==HIGH)
 {
  *test = "123"; //This should be the value of the "char password"
 }
 if(buttonstate1==HIGH)
 {
  *test="456"; //This should be the value of the "char password"
 }
}
int button1=3;
int buttonstate=0;
int buttonstate1=0;
char *test[4];
//char password={test};
void setup()
{
pinMode(button,INPUT);
}
void loop()
{
buttonstate=digitalRead(button);
buttonstate1=digitalRead(button1);
if(buttonstate==HIGH)
{
*test = "123"; //This should be the value of the "char password"
}
if(buttonstate1==HIGH)
{
*test="456"; //This should be the value of the "char password"
}
}
sir what about the "char password=*test" :)
is there no other way?
sir what would be the best way to get the value of the string and put it to the "password" i declared?
when i pressed button 1, the val should be button1="123"
when i pressed button2, the value should be button2="456" and place the value to password="button1 or button2"
outputs:
> comparing 123 to 123
> Same
> comparing 123 to 113
> Different
so try to put that together...
sir thank you so much for your effort. i really appreciate it but i still can't reach what i need. right now im using two buttons and each button hold different value, and those value should be store to, e.g. char password="//button1 or button2 value" and im using keypad to access it.
OK.... use your mad skills with this, for example and modify your original sketch... see what transpires!
char *test[4];
char *test2[4];
char *password[4];
void setup()
{
 Serial.begin(115200);
 *test = "123";
 *test2 = "123";
 Serial.print("comparing "); Serial.print(*test); Serial.print(" to "); Serial.println(*test2);
 Serial.println(strncmp(*test,*test2,3)?"Different":"Same");
 *test = "123";
 *test2 = "113";
 Serial.print("comparing "); Serial.print(*test); Serial.print(" to "); Serial.println(*test2);
 Serial.println(strncmp(*test,*test2,3)?"Different":"Same");
 *password = *test;
 Serial.print("Password = "); Serial.println(*password);
}
void loop()
{
}