Pages: [1]   Go Down
Author Topic: Cofre eletronico com senha  (Read 3228 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

gostaria de criar um algoritmo que lesse 6 numeros digitados num teclado numerico e se fosse a sequencia certa, ligaria um relê

se alguem pudesse me ajudar obrigado
Logged

Brazil
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Experimente dar uma procurada aqui neste link, deve ter algo que te possa ser util

http://www.arduino.cc/playground/Projects/ArduinoUsers

 smiley-cool
Logged

????????????????????

Brazil
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Melhor ainda, olhe:

http://arduino.cc/playground/Code/Keypad

 smiley-cool
Logged

????????????????????

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Valeu pela ajuda, vo tenta aqui introduzir esse codigo aqui, qualquer duvida eu posto aqui,
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

consegui um código aqui no forum, da library do key pad, mais não to conseguindo introduzir o que eu quero
queria que quando uma senha de 6 digitos fosse digitada acendesse um led, mais não sei como fazer a alteração no código
alguem me ajuda, o código eh esse:

/* @file EventSerialKeypad.pde
|| @version 1.0
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Demonstrates using the KeypadEvent.
|| #
*/
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 3; //four columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'#','0','*'}
};
byte rowPins[ROWS] = {5,4,3,2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8,7,6}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
byte ledPin = 10;

boolean blink = false;

void setup(){
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
  digitalWrite(ledPin, HIGH);   // sets the LED on
  keypad.addEventListener(keypadEvent); //add an event listener for this keypad
}
 
void loop(){
  char key = keypad.getKey();
 
  if (key != NO_KEY) {
    Serial.println(key);
  }
  if (blink){
    digitalWrite(ledPin,!digitalRead(ledPin));
    delay(100);
  }
}

//take care of some special events
void keypadEvent(KeypadEvent key){
  switch (keypad.getState()){
    case PRESSED:
      switch (key){
        case '#': digitalWrite(ledPin,!digitalRead(ledPin)); break;
        case '*':
          digitalWrite(ledPin,!digitalRead(ledPin));
        break;
      }
    break;
    case RELEASED:
      switch (key){
        case '*':
          digitalWrite(ledPin,!digitalRead(ledPin));
          blink = false;
        break;
      }
    break;
    case HOLD:
      switch (key){
        case '*': blink = true; break;
      }
    break;
  }
}

Logged

Brazil
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

o q vc precisa é disto:

#include "Password.h"
#include "Keypad.h"

Password password = Password( "1234" );

const byte ROWS = 4;
const byte COLS = 4;

char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};

byte rowPins[ROWS] = {2,3,4,5};
byte colPins[COLS] = {6,7,8,9};

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
  digitalWrite(13, LOW);
  Serial.begin(9600);
  keypad.addEventListener(keypadEvent);
  keypad.setDebounceTime(250);
}

void loop(){
  keypad.getKey();
}

void keypadEvent(KeypadEvent eKey){
  switch (keypad.getState()){
    case PRESSED:
   Serial.print("Digitado: ");
   Serial.println(eKey);
   switch (eKey){
     case '#': guessPassword(); break;
      default:
         password.append(eKey);
  }
}
}

 putz que moleza hein?    smiley-sleep    smiley-sleep
Logged

????????????????????

Brazil
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Desculpa aí pessoal mas faltou um pedaço do código, no final coloquem:

void guessPassword(){
     Serial.print("Verificando, aguarde... ");
     if (password.evaluate()){
        Serial.println("Abrindo a porta "); //
        digitalWrite(13, HIGH);   //ativa o solenoide
        delay(2000);       
        digitalWrite(13, LOW);   //desativa o solenoide
        password.reset(); //apaga a senha
             }else{
                  digitalWrite(13, LOW);
             Serial.println("PASSWORD INVALIDA");
                  password.reset(); //apaga a senha
     }
}
Logged

????????????????????

Pages: [1]   Go Up
Jump to: