obniz로 라디오 컨트롤 만들기
본 기사의 대상자
이 기사는 obniz에 관심이 있지만 주변 기기는 무엇을 구입해야할지 모르고 구매를 망설이는 사람을 향한 기사입니다.
내가 구입 한 주변 장치에서 그들을 이동하는 샘플 프로그램을 공유합니다.
덧붙여 obniz의 초기 설정에 대해서는, 사이트에 기재가 있기 때문에, 그쪽을 참조해 주세요.
<초기 설정에 대해 기재된 페이지>
htps : // 오 b ...
obniz를 본 적이 없다는 것은 아래의 링크처를 우선 참조해 주세요.
<링크>
obniz로 IoT를 실현하기 위한 도입 프로그램과 구입 주변기기
덧붙여 당 기사는, 작성 순서가 아니고, 어디까지나 작성에 이용한 하드나 프로그램의 소개입니다.
obniz로 라디오 컨트롤 만들기
obniz로, 스마트폰을 기울이면 기울인 방향으로 달리는 라디콘을 작성했으므로 그 만드는 방법을 기재한다.
obniz로 만든 라디콘

obniz에서 라디오 컨트롤을 만드는 데 사용 된 장비
obniz로, 스마트폰을 기울이면 기울인 방향으로 달리는 라디콘을 작성했으므로 그 만드는 방법을 기재한다.
obniz로 만든 라디콘

obniz에서 라디오 컨트롤을 만드는 데 사용 된 장비
obniz

400 타이 포인트 브레드 보드 3PCS + 120pcs 점퍼 와이어 점퍼 와이어 Arduino Raspberry pi 용

산하야토 점프 와이어 키트 SKS-100 단선 타입으로 자주 사용하는 짧은 점프 와이어 세트품

The perseids 2WD 로봇 스마트 카 섀시 2 륜 로봇 스마트 자동차 스피드 엔코더 for Arduino DIY 프로그래밍 자동차 교재 로봇 (2 륜)

덧붙여 대나무 끈은, 아이가 가지기 쉽도록 섀시의 구멍에 꽂은 것만 때문에 설명은 실시하지 않는다.
라디콘 조립 포인트
와이어와 모터를 연결

점퍼 와이어의 암컷을 자르고 와이어를 노출시켜 모터와 연결한다.
그 때, 좌우의 모터로 동일한 색의 와이어를 이용하는 것이 알기 쉽다.
브레드 보드에 모터와 연결된 와이어를 삽입


모터와 연결한 와이어는 브레드보드의 중심 영역에 끼우고 obniz와 연결하는 와이어를 브레드보드의 좌우의 「+」와 「-」에 꽂는다.
그 때, 짧은 점프 와이어로 좌우의 「+,-」와 중심부를 브리지할 필요가 있다.
obniz와 브레드 보드의 +,-에 연결된 와이어를 연결

무선 제어 프로그램
주의) 프로그램 내에 있는 「XXXX-YYYY」는, obniz의 ID가 되기 때문에, 적절히 obniz의 ID로 변경하는 것
프로그램은, 샘플로서 제공되고 있는 프로그램을 거의 그대로 이용하고 있습니다.
qiita.rb
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://obniz.io/js/jquery-3.2.1.min.js"></script>
<script src="https://unpkg.com/[email protected]/obniz.js" crossorigin="anonymous"></script>
</head>
<body>
<div id="obniz-debug"></div>
<h1>obniz robot controller </h1>
<div id="print"></div>
<script>
let obniz = new Obniz("XXXX-YYYY");
let motorL, motorR;
let threshold = 1, maxAccel = 5;
obniz.onconnect = function () {
motorL = obniz.wired("DCMotor", {forward: 0, back: 1});
motorR = obniz.wired("DCMotor", {forward: 2, back: 3});
};
window.addEventListener("devicemotion", function (event1) {
let x = event1.accelerationIncludingGravity.x;
let y = event1.accelerationIncludingGravity.y;
if (!motorR || !motorL) {
return;
}
if (Math.abs(y) > threshold) {
let power = Math.min(100 * (Math.abs(y) - threshold) / (maxAccel - threshold), 100);
motorL.power(power);
motorR.power(power);
let direction = y > 0;
motorL.move(direction);
motorR.move(direction);
} else if (Math.abs(x) > threshold) {
let power = Math.min(100 * (Math.abs(x) - threshold) / (maxAccel - threshold), 100);
if (x > 0) {
motorR.power(power);
motorR.move(true);
motorL.stop();
} else {
motorL.power(power);
motorL.move(true);
motorR.stop();
}
} else {
motorL.stop();
motorR.stop();
}
}, true);
</script>
</body>
</html>
Reference
이 문제에 관하여(obniz로 라디오 컨트롤 만들기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/KOJI-YAMAMOTO/items/25274719536db2808d1d텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)