Skip to content

YUKAI/MakerBoard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MakerBoard

Arduino互換機のメイカーボードを簡単にテキストプログラミングするためのライブラリです. IOピンの抽象化,DCモーターのPWM生成を行います.Arduino UnoやArduino pro miniでも使用いただけます. ピンアサインはMakerBoard.hをご確認ください.

This library abstracts IO pins and generates PWM for DC motors. It can also be used with Arduino Uno, Arduino pro mini and so on. Please check MakerBoard.h for pin assignment.

使い方 How to Use

examplesに簡単な例があります

LEDを点滅させる例 Blink LED example

#include <MakerBoard.h>
MakerBoard board;

void setup() {
  pinMode(board.LED_RED, OUTPUT);
  pinMode(board.LED_BLUE, OUTPUT);
}

void loop() {
  digitalWrite(board.LED_RED, HIGH);    // Red led ON 
  delay(1000);
  digitalWrite(board.LED_BLUE, HIGH);   // Blue led ON 
  delay(1000);
  digitalWrite(board.LED_RED, LOW);     // Red led OFF 
  delay(1000);
  digitalWrite(board.LED_BLUE, LOW);    // Blue led OFF
  delay(1000);
}

モーターを回転させる例 Drive motor

DCモーターを制御するためにPWMをTimer2で生成しています.そのため,Grove スピーカーなどのタイマーを使用するライブラリと干渉する恐れがあります.併用する場合はご注意ください.

PWM is generated using Timer2 to control the DC motor. Therefore, there is a risk of interference with libraries that use timers such as Grove speakers. Please be careful when using them together.

#include <MakerBoard.h>
#include <Servo.h>
#include <MsTimer2.h>

MakerBoard board;
Servo servo1;

void setup() {
  pinMode(board.SERVO1, OUTPUT);
  servo1.attach(board.SERVO1);

  board.motorPWMBegin();
}

void loop() {
  Motor1.set(100, Motor1.FORWARD);    // Motor1 rotate forward. Object motor1 was included from MakerBoard.h
  delay(1000);
  servo1.write(90);   // Servo motor rotate
  delay(1000);

  Motor1.set(50, Motor1.BACKWARD);   // Motor1 rotate backward 
  delay(1000);
  servo1.write(0);
  delay(1000);
}