第1步:你需要什么:
你只需要一些東西此
2。運(yùn)行Microsoft Visual Studio的計(jì)算機(jī)和您的代碼編輯軟件(在本例中是我的Arduino)
3。用于將草圖上傳到機(jī)器人的USB電纜
步驟2:從機(jī)器人開始
我已附上以下代碼但是,如果您沒有使用Arduino軟件,我已經(jīng)在下面發(fā)布了它。這就是我用于RobotShop.com的漫游機(jī)器人。我采用了一個(gè)簡(jiǎn)單的WASD草圖并對(duì)其進(jìn)行了修改,以允許程序“遠(yuǎn)程”控制它。復(fù)制代碼后,您可以使用USB電纜或用于上傳到機(jī)器人的任何方式將其上傳到機(jī)器人。
//Setting motor variables
int motorSpeed = 6;
int motor2Speed = 5;
int motor1 = 8;
int motor2 = 7; void setup() {
int i;
for(i=5;i《=8;i++)
pinMode(i, OUTPUT);
Serial.begin(9600); //Start Serial Communication } void loop() {
//waiting for any serial communication. If any is received conduct the switch statement.
char data = Serial.read();
//Setting speed. 255 is max speed, you can change the values below to slow it down if you want.
int leftspeed = 255;
int rightspeed = 255;
switch (data) {
case ‘0’: //If the arduino receives a 0 then it will run the halt command which is defined below.
halt ();
break;
case ‘1’:
forward (leftspeed, rightspeed);
break;
case ‘2’:
reverse (leftspeed, rightspeed);
break;
case ‘3’:
left (rightspeed, leftspeed);
break;
case ‘4’:
right (rightspeed, leftspeed);
break;
} } void halt(void)
{
digitalWrite(motorSpeed, LOW);
digitalWrite(motor2Speed, LOW);
} void forward(char a, char b)
{
analogWrite(motorSpeed, a); //releasing the “brake”
digitalWrite(motor1, LOW); //Applying full power to the pin. This would typically be HIGH but, my wires are hooked up backwards so I just switched the command.
analogWrite(motor2Speed, b);
digitalWrite(motor2, LOW);
} void reverse (char a, char b)
{
analogWrite(motorSpeed, a);
digitalWrite(motor1, HIGH);
analogWrite(motor2Speed, b);
digitalWrite(motor2, HIGH);
}
void left (char a,char b)
{
analogWrite (motorSpeed, a);
digitalWrite(motor1, HIGH);
analogWrite (motor2Speed, b);
digitalWrite(motor2, LOW);
}
void right (char a,char b)
{
analogWrite (motorSpeed, a);
digitalWrite(motor1, LOW);
analogWrite (motor2Speed, b);
digitalWrite(motor2, HIGH);
}
步驟3:Microsoft Visual Studio C#應(yīng)用程序
現(xiàn)在是時(shí)候啟動(dòng)Microsoft Visual Studio了。我們首先創(chuàng)建一個(gè)C#windows窗體應(yīng)用程序。我首先創(chuàng)建UI。這包括5個(gè)標(biāo)簽,1個(gè)富文本框和2個(gè)按鈕??梢允褂闷聊蛔髠?cè)的工具箱將這些添加到表單中。
添加上述項(xiàng)目后,您可以雙擊應(yīng)用程序的頂部邊框。這將打開程序背后的C#代碼窗口。在附件和下面的代碼中,我試圖評(píng)論很多,它應(yīng)該很容易遵循。如果沒有,我已附加程序的“已發(fā)布”版本和Visual Studio項(xiàng)目文件。
您可以編輯COM端口到您的機(jī)器人所在的任何位置。我的機(jī)器人在COM5上。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Ports;
using System.Speech;
using System.Speech.Recognition;
using System.Speech.Synthesis;
第4步:現(xiàn)在是時(shí)候把它放在一起了!
我們一直在等待的那一刻!啟動(dòng)機(jī)器人和程序。一切都啟動(dòng)后,單擊啟用并說出您的第一個(gè)命令!我很好,有時(shí)程序可能有點(diǎn)奇怪,并重復(fù)多次命令。這從來沒有打擾過我,所以我接受它。我希望你看看視頻,讓我知道這是否有助于你控制你的機(jī)器人!祝你有個(gè)美好的一天!
-
機(jī)器人
+關(guān)注
關(guān)注
213文章
31182瀏覽量
222922 -
聲音控制
+關(guān)注
關(guān)注
0文章
4瀏覽量
9006
發(fā)布評(píng)論請(qǐng)先 登錄
人形機(jī)器人爆發(fā)背后,一個(gè)被忽視的核心技術(shù):機(jī)器人運(yùn)動(dòng)學(xué)控制
在 VisionFive 2 上實(shí)現(xiàn)機(jī)器人伺服控制
高精度機(jī)器人控制的核心——基于 MYD-LT536 開發(fā)板的精密運(yùn)動(dòng)控制方案
MCU微控制器,N32H47x高性能MCU機(jī)器人關(guān)節(jié)控制方案
RK3576機(jī)器人核心:三屏異顯+八路攝像頭,重塑機(jī)器人交互與感知
揭秘工業(yè) 4.0 機(jī)器人:感知、安全和控制技術(shù)
MT6701絕對(duì)式磁編碼器優(yōu)化機(jī)器人關(guān)節(jié)伺服控制
工業(yè)機(jī)器人的特點(diǎn)
MT6701磁編芯片:開創(chuàng)機(jī)器人運(yùn)動(dòng)控制新時(shí)代
盤點(diǎn)#機(jī)器人開發(fā)平臺(tái)
【「# ROS 2智能機(jī)器人開發(fā)實(shí)踐」閱讀體驗(yàn)】機(jī)器人入門的引路書
【「# ROS 2智能機(jī)器人開發(fā)實(shí)踐」閱讀體驗(yàn)】+內(nèi)容初識(shí)
基于先進(jìn)MCU的機(jī)器人運(yùn)動(dòng)控制系統(tǒng)設(shè)計(jì):理論、實(shí)踐與前沿技術(shù)
雅特力科技助力宇樹科技推動(dòng)智慧機(jī)器人創(chuàng)新應(yīng)用:深入布局機(jī)器人電機(jī)控制核心
如何用聲音控制任何串行控制的機(jī)器人
評(píng)論