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:
- yamaotoko
- Date:
- 2018-09-06
- Revision:
- 0:4e684157ecca
- Child:
- 1:f43ebe88228e
File content as of revision 0:4e684157ecca:
#include "mbed.h"
#include "HX711.hpp"
#include "Dynamixel.h"
HX711 hx711(p21, p22);
Serial pc(USBTX, USBRX);
Dynamixel motor(p13,p14,p15,0xFE,57600);
//Dynamixel回転方向対応用
//多分11bitのうちMSBが符号,最上位で回転方向を指定している
move(int speed){
if(speed >= 0)
motor.setSpeed(speed);
else{
motor.setSpeed(-1*speed+1024); //11bitのうちMSBが符号
}
}
//--------------------HX711
void calibrate(float gram){
hx711.setScale(1.f);
hx711.tare();
//この辺をProcessing用に組み替える
printf("place the weight and put any key\n");
char c = pc.getc();
float natural = hx711.readGram();
float calibVal = natural / gram;
hx711.setScale(calibVal);
//printf("calibrated! %f %f %d\n", calibVal, natural, hx711.read());
}
int main() {
//ホイールモードにするための設定
motor.setAngleLimit(0, ADDRESS_CW_ANGLE_LIMIT);
motor.setAngleLimit(0, ADDRESS_CCW_ANGLE_LIMIT);
while(1) {
}
}