Sabtu, 15 Juni 2013
Arduino + keypad + saklar digital
int dt=0; int dx=0;
#include "Keypad.h"
const byte baris=4;
const byte kolom=4;
char z [baris][kolom] = {
{ '1','4','7','*'},
{ '2','5','8','0'},
{ '3','6','9','#'},
{ 'A','B','C','D'}};
byte rowPins[baris]={ 7,6,5,4};
byte colPins[kolom]={11,10,9,8};
int count=0;
Keypad keypad= Keypad (makeKeymap(z),rowPins,colPins,baris,kolom);
void setup()
{Serial.begin(9600);
pinMode(13,OUTPUT);
pinMode(2,OUTPUT); pinMode(3,OUTPUT);
}
void loop() {
char z=keypad.getKey();
if (z !=NO_KEY) {
Serial.print(z);
count++;
if (count==17){
Serial.println("yadi ");// ttambahan biar garis baru
count=0;
}
int vv=z;
Serial.println(vv);
if (vv==50){
digitalWrite(13,HIGH);
Serial.print("sakurata");
}
if (vv==49){
digitalWrite(13,0);}
}
dt = digitalRead(2); dx=digitalRead(3);
if (dt == HIGH){
digitalWrite(13,1);}
if (dx==HIGH){
digitalWrite(13,0);}
}
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar