Just Another Marble Robot (JAMR) 是一款非常简单的基于 Arduino 的 3 轴机器人,您可以将其构建为学校项目或与孩子一起构建的有趣项目。这个机器人会让你的大理石轨道更加有趣。
尽管体积小,但它具有大型机器人的所有步进功能,包括高精度。具有斜坡上升和下降功能,它的运动比伺服控制的机器人要平稳得多。
该机器人基于廉价的 28BYJ-48 12V 步进电机,带有 ULN2003 驱动器,您可以以每套 4 欧元/美元左右的价格购买。结合 Arduino Uno,该项目的总成本约为 32 欧元/美元,-.
在此页面上,您将找到开始构建机器人所需的所有信息。
该机器人所需的零件是:
• 6 x 28BYJ-48 12V 步进电机
• 6 x ULN2003 驱动程序
• 1 个 Arduino Uno
• 1 x 10k 电阻器
• 1 x BC547 晶体管
• 1 x 线圈,来自 12V 继电器
• 一些 M4 螺纹尼龙棒
• 一些 M4 尼龙螺母和粗体
• 电子元件外壳
• 一些 0,14mm2/26AWG 电线








项目代码
int speedSetting;
int stepCounter;
int calibrationSpeed = 5;
int bottomArmPosition, middleArmPosition, topArmPosition;
byte incommingByte;
void setup() {
Serial.begin(57600);
//Magnet
pinMode (A0, OUTPUT); //Magnet coil
//Bottom arm
pinMode(2, OUTPUT); //IN1
pinMode(3, OUTPUT); //IN2
pinMode(4, OUTPUT); //IN3
pinMode(5, OUTPUT); //IN4
//Middle arm
pinMode(6, OUTPUT); //IN1
pinMode(7, OUTPUT); //IN2
pinMode(8, OUTPUT); //IN3
pinMode(9, OUTPUT); //IN4
//Top arm
pinMode(10, OUTPUT); //IN4
pinMode(11, OUTPUT); //IN3
pinMode(12, OUTPUT); //IN2
pinMode(13, OUTPUT); //IN1
digitalWrite(2, HIGH);
digitalWrite(6, HIGH);
digitalWrite(10, HIGH);
digitalWrite(A0, LOW);
delay(5000);
calibrateArms();
bottomArmMove(120);
middleArmMove(-290);
topArmMove(170);
bottomArmMove(-46);
}
void loop() {
Serial.print("B=");
Serial.print(bottomArmPosition);
Serial.print(" M=");
Serial.print(middleArmPosition);
Serial.print(" T=");
Serial.print(topArmPosition);
Serial.print(" C=");
Serial.println(digitalRead(A0));
digitalWrite(A0, HIGH);
delay(500);
bottomArmMove(79);
middleArmMove(70);
bottomArmMove(-45);
digitalWrite(A0, LOW);
topArmMove(120);
middleArmMove(-70);
topArmMove(-120);
bottomArmMove(-34);
if (Serial.available()) {
incommingByte = Serial.read();
if (incommingByte == '7')bottomArmMove(10);
if (incommingByte == '1')bottomArmMove(-10);
if (incommingByte == '8')middleArmMove(10);
if (incommingByte == '2')middleArmMove(-10);
if (incommingByte == '9')topArmMove(10);
if (incommingByte == '3')topArmMove(-10);
if (incommingByte == '4')digitalWrite(A0, HIGH);
if (incommingByte == '6')digitalWrite(A0, LOW);
Serial.print("B=");
Serial.print(bottomArmPosition);
Serial.print(" M=");
Serial.print(middleArmPosition);
Serial.print(" T=");
Serial.print(topArmPosition);
Serial.print(" C=");
Serial.println(digitalRead(A0));
delay(100);
while (Serial.available())incommingByte = Serial.read();
}
}
void topArmMove(int steps) {
topArmPosition += steps;
speedSetting = 20;
if (steps == 0)return;
digitalWrite(10, HIGH);
if (steps > 0) {
for (stepCounter = 0 ; stepCounter < steps; stepCounter ++) {
digitalWrite(10, LOW);
digitalWrite(11, HIGH);
delay(speedSetting);
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
delay(speedSetting);
digitalWrite(12, LOW);
digitalWrite(13, HIGH);
delay(speedSetting);
digitalWrite(13, LOW);
digitalWrite(10, HIGH);
delay(speedSetting);
if (stepCounter > steps - 20 && speedSetting < 20)speedSetting += 2;
if (speedSetting > 4)speedSetting --;
}
}
else {
steps *= -1;
for (stepCounter = 0 ; stepCounter < steps; stepCounter ++) {
digitalWrite(10, LOW);
digitalWrite(13, HIGH);
delay(speedSetting);
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
delay(speedSetting);
digitalWrite(12, LOW);
digitalWrite(11, HIGH);
delay(speedSetting);
digitalWrite(11, LOW);
digitalWrite(10, HIGH);
delay(speedSetting);
if (stepCounter > steps - 20 && speedSetting < 20)speedSetting += 2;
if (speedSetting > 4)speedSetting --;
}
}
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
}
void middleArmMove(int steps) {
middleArmPosition += steps;
speedSetting = 20;
if (steps == 0)return;
digitalWrite(3, HIGH);
if (steps > 0) {
for (stepCounter = 0 ; stepCounter < steps; stepCounter ++) {
digitalWrite(3, LOW);
digitalWrite(5, HIGH);
delay(speedSetting);
digitalWrite(2, LOW);
digitalWrite(4, HIGH);
delay(speedSetting);
digitalWrite(5, LOW);
digitalWrite(3, HIGH);
delay(speedSetting);
digitalWrite(4, LOW);
digitalWrite(2, HIGH);
delay(speedSetting);
if (stepCounter > steps - 20 && speedSetting < 20)speedSetting += 2;
if (speedSetting > 4)speedSetting --;
}
}
else {
steps *= -1;
for (stepCounter = 0 ; stepCounter < steps; stepCounter ++) {
digitalWrite(2, LOW);
digitalWrite(4, HIGH);
delay(speedSetting);
digitalWrite(3, LOW);
digitalWrite(5, HIGH);
delay(speedSetting);
digitalWrite(4, LOW);
digitalWrite(2, HIGH);
delay(speedSetting);
digitalWrite(5, LOW);
digitalWrite(3, HIGH);
delay(speedSetting);
if (stepCounter > steps - 20 && speedSetting < 20)speedSetting += 2;
if (speedSetting > 4)speedSetting --;
}
}
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
}
void bottomArmMove(int steps) {
bottomArmPosition += steps;
speedSetting = 20;
if (steps == 0)return;
digitalWrite(7, HIGH);
if (steps > 0) {
for (stepCounter = 0 ; stepCounter < steps; stepCounter ++) {
digitalWrite(7, LOW);
digitalWrite(9, HIGH);
delay(speedSetting);
digitalWrite(6, LOW);
digitalWrite(8, HIGH);
delay(speedSetting);
digitalWrite(9, LOW);
digitalWrite(7, HIGH);
delay(speedSetting);
digitalWrite(8, LOW);
digitalWrite(6, HIGH);
delay(speedSetting);
if (stepCounter > steps - 20 && speedSetting < 20)speedSetting += 2;
if (speedSetting > 4)speedSetting --;
}
}
else {
steps *= -1;
for (stepCounter = 0 ; stepCounter < steps; stepCounter ++) {
digitalWrite(6, LOW);
digitalWrite(8, HIGH);
delay(speedSetting);
digitalWrite(7, LOW);
digitalWrite(9, HIGH);
delay(speedSetting);
digitalWrite(8, LOW);
digitalWrite(6, HIGH);
delay(speedSetting);
digitalWrite(9, LOW);
digitalWrite(7, HIGH);
delay(speedSetting);
if (stepCounter > steps - 20 && speedSetting < 20)speedSetting += 2;
if (speedSetting > 4)speedSetting --;
}
}
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
}
void calibrateArms(void) {
//Set top arm position
for (stepCounter = 0 ; stepCounter < 300; stepCounter ++) {
digitalWrite(10, LOW);
digitalWrite(13, HIGH);
delay(calibrationSpeed);
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
delay(calibrationSpeed);
digitalWrite(12, LOW);
digitalWrite(11, HIGH);
delay(calibrationSpeed);
digitalWrite(11, LOW);
digitalWrite(10, HIGH);
delay(calibrationSpeed);
}
//Set middle arm position
for (stepCounter = 0 ; stepCounter < 300; stepCounter ++) {
digitalWrite(2, LOW);
digitalWrite(5, HIGH);
delay(calibrationSpeed);
digitalWrite(5, LOW);
digitalWrite(4, HIGH);
delay(calibrationSpeed);
digitalWrite(4, LOW);
digitalWrite(3, HIGH);
delay(calibrationSpeed);
digitalWrite(3, LOW);
digitalWrite(2, HIGH);
delay(calibrationSpeed);
}
//Set bottom arm position
for (stepCounter = 0 ; stepCounter < 300; stepCounter ++) {
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
delay(calibrationSpeed);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
delay(calibrationSpeed);
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
delay(calibrationSpeed);
digitalWrite(9, LOW);
digitalWrite(6, HIGH);
delay(calibrationSpeed);
}
}
【Arduino 动手做】基于 Arduino 的 28BYJ-48 升降机械臂
项目链接:http://www.brokking.net/JAMR.html
项目作者:Joop Brokking
项目视频 :https://www.youtube.com/watch?v=DWgC4vC-IGg
项目代码:http://www.brokking.net/images/jamr/JAMR_Arduino_code.zip
3D 文件:http://www.brokking.net/images/jamr/JAMR_parts.zip

评论