Goodday.
Hi, Im a beginner on arduino, our project is about entering/verifying pincodes on Arduino.
The pushbutton acts as the number input, arduino must check/verify the codes entered (sequence sensitive) and if verified correct, LED sequence will trigger. (our code is 1325) using 5 pushbuttons, pushbutton 4 is blank.
(I stored the codes on myArray and to be compared on the pushbutton strokes assigned also to another array).
*array,if,else,for,while,digitalRead,. are the only functions we can use in this exercise.
- How can I assign 1st pushbutton pressed on index 1 of myArraytest... on and so on and so forth?
- How can arduino detect 1st/2nd/3rd etc.. pushbutton pressed?
Hoping someone may help :))
Suggestions are welcome.. Thanks :)) and more power ![]()
PS. The codes below are still in beta and it is flawed.
int i;
int pin1;
int pin2;
int pin3;
int pin5;
int myArray[]={1,3,2,5};
int myArraytest[3];
void setup()
{
for(i=0;i<=7;i=i+1)
{
pinMode(i,OUTPUT);
}
}
void loop()
{
myArray[0]=1;
myArray[1]=3;
myArray[2]=2;
myArray[3]=5;
pin1=digitalRead(26);
pin2=digitalRead(25);
pin3=digitalRead(24);
pin5=digitalRead(22);
//Assign 1st pushbutton pressed to index 1 of myArrayTest, 2nd pusbutton pressed to 2nd. etc....
// Codes below are fas
if(pin1==1)
{
myArraytest[0]=1;
}
if(pin2==1)
{
myArraytest[1]=2;
}
if(pin3==1)
{
myArraytest[2]=3;
}
if(pin5==1)
{
myArraytest[3]=5;
}
if(myArraytest[0]==myArray[0]&&myArraytest[1]==myArray[1]&&myArraytest[2]==myArray[2]&&myArraytest[3]==myArray[3])
{
for(i=0;i<=6;i++)
{
digitalWrite(i,HIGH);
delay(100);
}
i=7;
while(i=7)
{
digitalWrite(i,HIGH);
delay(100);
digitalWrite(i,!HIGH);
delay(100);
}
}
}