press PASSCODE then proceed to program

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
sharmzzz
 
Posts: 2
Joined: Sun Jul 27, 2014 12:57 am

press PASSCODE then proceed to program

Post by sharmzzz »

Hello! The codes below is what I want to happen. But before that, I need first to set a passcode by pressing buttons.
for example my passcode would be switches 1,4 and 3. Then it will proceed to run the below codes. If I entered incorrect password (132), then all LED's will on then off. Then I can try another passcode. It has 6 switches, 1 for reset and 8 LED's.
Please help me on the codes :D
Thanks a lot!

int timer = 100;
int ledPins[] = {
13,12,11, 10, 9, 8, 7, 6};
int pinCount = 8;
void setup() {

for (int thisPin = 0; thisPin < pinCount; thisPin++) {
pinMode(ledPins[thisPin], OUTPUT);
}
}

void loop() {

if (buttonState == HIGH) {
digitalWrite(ledPin, LOW);
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
digitalWrite(ledPins[thisPin], LOW);

}
for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
digitalWrite(ledPins[thisPin], LOW);
}
}
}
Attachments
Untitledfd.png
Untitledfd.png (45.87 KiB) Viewed 285 times
Last edited by sharmzzz on Mon Jul 28, 2014 9:11 pm, edited 3 times in total.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: press 3 random buttons then proceed to program

Post by adafruit_support_bill »

When you press any 3 random buttons(like a go signal), it will then proceed to the main program like on assembly language.
Is that what it does, or is that what you want it to do?
If you can explain exactly what works and what does not work, we might be able to help.

sharmzzz
 
Posts: 2
Joined: Sun Jul 27, 2014 12:57 am

Re: press 3 random buttons then proceed to program

Post by sharmzzz »

adafruit_support_bill wrote:
When you press any 3 random buttons(like a go signal), it will then proceed to the main program like on assembly language.
Is that what it does, or is that what you want it to do?
If you can explain exactly what works and what does not work, we might be able to help.


It is what I want to do.
1. Press any 3 random buttons. Then 3 LED's will be HIGH
2. All Led's will on, rotating from left to right.

That's all. I'm having difficulty of how will I program the buttons.
Please help me :D
THANKS!

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: press 3 random buttons then proceed to program

Post by adafruit_support_bill »

I'm having difficulty of how will I program the buttons.
Lesson 6 covers wiring and programming for digital inputs like pushbuttons: https://learn.adafruit.com/adafruit-ard ... tal-inputs

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”