본 제품은 로터리 인코더 모듈입니다. 한 회전당 20 펄스를 출력합니다.
로터리 모듈에는 10K 풀업저항이 장착되어 있어 외부 풀업저항이 필요가 없습니다.
SW핀은 스위치 핀으로 GND에 연결되어 있으며, 샤프트를 누를시 동작합니다.
Working voltage: 5V
Pulses per rotation: 20
Pinout
1...GND
2...+5V supply
3...SW connects pin to GND whebn shaft is pressed
4...DT direction pulse. Pin has 10K pullup connected to supply.
5...CLK clock pulse. Pin has 10K pullup connected to supply.
아두이노 코드
/* Define digital pins used to read the encoder */ #define DT 2 #define CLK 3 #define SW 4 void setup() { Serial.begin(9600); pinMode(DT, INPUT); pinMode(CLK, INPUT); pinMode(SW, INPUT); digitalWrite(SW, HIGH); } /* Main program */ void loop() { int counter; byte DialPos; byte Last_DialPos; /* Reset the counter */ counter = 0; /* Continiouously read the state of the encoder */ while(1) { /* Read the status of the dial */ DialPos = (digitalRead(CLK) << 1) | digitalRead(DT); /* Is the dial being turned anti-clockwise? */ if (DialPos == 3 && Last_DialPos == 1) { counter--; } /* Is the dial being turned clockwise? */ if (DialPos == 3 && Last_DialPos == 2) { counter++; } /* Output the counter to the serial port */ Serial.println(counter); /* Is the switch pressed? */ if(!digitalRead(SW)) Serial.println("Switch pressed!"); /* Save the state of the encoder */ Last_DialPos = DialPos; } }
* 유의사항 *
KY-040은 교육용으로 볼트 너트가
없는 경우도 잇습니다
이점 유의바랍니다.
(주)인투피온
대표:소영삼 사업자등록번호:113-86-29364 [사업자정보확인] 통신판매신고:2015-서울구로-1028
본사 : 서울 구로구 경인로 53길 90 STX W-Tower 1307호
매장 : 서울 구로구 경인로 53길 15 중앙유통단지 가동 3101호
고객상담 팩스번호: 02-6124-4242 이메일: info@intopion.com
* 재고 확인, 배송, 기술문의는 바로 답변이 어려우니, 가급적 카카오톡 플러스친구 [인투피온] 이용 부탁드립니다 *
개인정보관리책임자 : 이성민 / Hosting Provider : ㈜가비아씨엔에스