R 3 Arduino Uno 4 X 4 Keypad

  • Slides: 17
Download presentation

작품소개 Ⅲ. 부품설명 아두이노 우노 R 3 (Arduino Uno) 4 X 4 키패드 모듈

작품소개 Ⅲ. 부품설명 아두이노 우노 R 3 (Arduino Uno) 4 X 4 키패드 모듈 (Keypad Module) 1 EA 아두이노 서보 모터 (Arduino Servo motor) 1 EA 점퍼선 (JUMPERS CABLE)

개발 과정 Ⅲ 아두이노 스케치 byte row. Pins[ROWS] = {9, 8, 7, 6}; byte

개발 과정 Ⅲ 아두이노 스케치 byte row. Pins[ROWS] = {9, 8, 7, 6}; byte col. Pins[COLS] = {5, 4, 3, 2}; Keypad keypad = Keypad(make. Keymap(keys), row. Pins, col. Pins, ROWS, COLS); char PIN[6]={'1', '2', '3', '4', '5', '6'}; // 비번 설정 char attempt[6]={0, 0, 0, 0}; int z=0; void setup() { Serial. begin(9600); mysv. attach(10); //8번핀으로 초기화 }

개발 과정 Ⅲ 아두이노 스케치 void correct. PIN() { Serial. println("pass PIN entered. .

개발 과정 Ⅲ 아두이노 스케치 void correct. PIN() { Serial. println("pass PIN entered. . . "); //올바른 비밀번호 입력시 실행 for(po=0; po<150; po+=1){ mysv. write(po); delay(1000); } } void incorrect. PIN() { Serial. println("worng PIN entered!"); //틀린 비밀번호 입력시 실행 }

개발 과정 Ⅲ 아두이노 스케치 ② ① void check. PIN() if (correct==6) { {

개발 과정 Ⅲ 아두이노 스케치 ② ① void check. PIN() if (correct==6) { { correct. PIN(); int correct=0; } else int i; { for ( i = 0; i < 6 ; i++ ) incorrect. PIN(); { } if (attempt[i]==PIN[i]) for (int zz=0; zz<6; zz++) // 이전에 사용자가 입력했던 번호를 지움 { { correct++; attempt[zz]=0; } }

개발 과정 Ⅲ 아두이노 스케치 ② ① void read. Keypad() case '#': delay(100); //

개발 과정 Ⅲ 아두이노 스케치 ② ① void read. Keypad() case '#': delay(100); // 처리를 위해 0. 1초 동안 대기한다. { char key = keypad. get. Key(); check. PIN(); if (key !=NO_KEY) break; { default: switch(key) attempt[z]=key; { z++; case '*': } z=0; break; } }