Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- Soutajin
- Date:
- 2018-08-23
- Revision:
- 0:651a188c5dc3
- Child:
- 1:fa3a640a55e0
File content as of revision 0:651a188c5dc3:
#include "mbed.h"
DigitalInOut name(p8);//EN_IN(HIGHでICS機器に送信するモード、LOWでICS機器から受信するモードにするピン)と繋いでいる
Serial master(p9, p10);//シリアル通信を担当するピン
//Serial pc(USBTX, USBRX);実験中のため気にしないでください
//char ret1,ret2,ret3;実験中のため気にしないでください
int main() {
master.baud(115200);//クロックレートの設定
master.format(8, Serial::Even, 1);//通信方式の設定
name.output();//p8を出力モードに
name = 1;//EN_INにHIGH(送信モード)にする
master.putc(0x85);//ID5のサーボ(詳細ICS3.5/3.6コマンドリファレンスを参照してください)
master.putc(0x1B);//角度3500を110110101100と表し、さらに11011と0101100に分け1バイトずつ送信している
master.putc(0x2C);//11011 = 0x1B。0101100 = 0x2C。
wait(1.0);//送信した瞬間また次のコマンドを送信するとひとつ前のコマンドが送信しきれいないので連続での動作はできません。
//name.readable()を使おうと思いましたがうまく動作しないので便宜的にwaitを使っています。
master.putc(0x85);//一つ上に同じ
master.putc(0x59);//同じ
master.putc(0x6C);//同じ
wait(1.0);//同じ
/*name = 0;実験中のため気にしないでください
ret1 = master.getc();実験中のため気にしないでください
ret2 = master.getc();実験中のため気にしないでください
ret3 = master.getc();実験中のため気にしないでください
name = 1;実験中のため気にしないでください
pc.printf("");実験中のため気にしないでください*/
}