다음의 아두이노 코드를 이용할 수 있습니다.
Arduino Code
/* Read Jostick
* ------------
*
* Reads two analog pins that are supposed to be
* connected to a jostick made of two potentiometers
*
* We send three bytes back to the comp: one header and two
* with data as signed bytes, this will take the form:
* Jxyrn
*
* x and y are integers and sent in ASCII
*
* http://www.0j0.org | http://arduino.berlios.de
* copyleft 2005 DojoDave for DojoCorp
*/
int ledPin = 13;
int joyPin1 = 0; // slider variable connecetd to analog pin 0
int joyPin2 = 1; // slider variable connecetd to analog pin 1
int value1 = 0; // variable to read the value from the analog pin 0
int value2 = 0; // variable to read the value from the analog pin 1
void setup() {
pinMode(ledPin, OUTPUT); // initializes digital pins 0 to 7 as outputs
Serial.begin(9600);
}
int treatValue(int data) {
return (data * 9 / 1024) + 48;
}
void loop() {
// reads the value of the variable resistor
value1 = analogRead(joyPin1);
// this small pause is needed between reading
// analog pins, otherwise we get the same value twice
delay(100);
// reads the value of the variable resistor
value2 = analogRead(joyPin2);
digitalWrite(ledPin, HIGH);
delay(value1);
digitalWrite(ledPin, LOW);
delay(value2);
Serial.print('J');
Serial.print(treatValue(value1));
Serial.println(treatValue(value2));
}
(주)인투피온
대표:소영삼 사업자등록번호:113-86-29364 [사업자정보확인] 통신판매신고:2015-서울구로-1028
본사 : 서울 구로구 경인로 53길 90 STX W-Tower 1307호
매장 : 서울 구로구 경인로 53길 15 중앙유통단지 가동 3101호
고객상담 팩스번호: 02-6124-4242 이메일: info@intopion.com
* 재고 확인, 배송, 기술문의는 바로 답변이 어려우니, 가급적 카카오톡 플러스친구 [인투피온] 이용 부탁드립니다 *
개인정보관리책임자 : 이성민 / Hosting Provider : ㈜가비아씨엔에스