日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁 > 嵌入式 > 嵌入式硬件
[導(dǎo)讀]本篇文章主要介紹如何在Wekinator軟件平臺(tái)中使用樹莓派連接到Arduino Uno開發(fā)板的直流電機(jī)。

本篇文章主要介紹如何在Wekinator軟件平臺(tái)中使用樹莓派連接到Arduino Uno開發(fā)板的直流電機(jī)。

然后將兩個(gè)伺服電機(jī)的紅線連接到Raspberry Pi的5V GPIO引腳。然后將兩個(gè)伺服系統(tǒng)的黑線連接到Raspberry Pi的地面。最后,將其中一個(gè)伺服電機(jī)的黃色線連接到Raspberry Pi的GPIO 4,將另一個(gè)伺服的黃色線連接到Raspberry Pi的GPIO 17。

 

 

如何運(yùn)行程序

《首先,您需要從Wekinator的快速演練頁面下載草圖。

從那里下載屏幕上的鼠標(biāo)控制示例。解壓縮并在處理中打開草圖。該草圖將為Wekinator提供輸入。您將需要另一個(gè)草圖來獲取Wekinator的輸出。該草圖的代碼在本文末尾。將其粘貼到處理中并運(yùn)行它。兩個(gè)處理輸出窗口如下所示:

 

 

現(xiàn)在打開Wekinator并進(jìn)行如下圖所示的設(shè)置。將輸入和輸出設(shè)置為2,然后將類型設(shè)置為“自定義”,然后單擊“配置”。

 

 

當(dāng)您點(diǎn)擊“配置”時(shí),一個(gè)新的窗口將打開。更改該窗口中的設(shè)置,如下圖所示。

 

 

現(xiàn)在將處理窗口中的綠框拖到左側(cè)中央并設(shè)置設(shè)置在Wekinator窗口中,如下所示。之后,開始錄制半秒。

 

 

現(xiàn)在將處理窗口中的綠色框拖到右側(cè)中央,然后在Wekinator窗口如下圖所示。之后,開始錄制半秒。

 

 

現(xiàn)在將處理窗口中的綠框拖到中心頂部并在Wekinator中設(shè)置設(shè)置窗口如下圖所示。之后,開始錄制半秒。

 

 

現(xiàn)在將處理窗口中的綠色框拖到底部中心一側(cè),然后在Wekinator窗口如下圖所示。之后,開始錄制半秒。

 

 

單擊“Train”,然后單擊“Run”?,F(xiàn)在當(dāng)您在處理窗口中拖動(dòng)綠色框時(shí),連接到Raspberry Pi的GPIO引腳的伺服器將根據(jù)它移動(dòng)。

處理代碼

import processing.io.*; // Importing the library to control the GPIO pins of raspberry pi

// Below libraries will help in connecting and sending, receiving the values from wekinator

import oscP5.*;

import netP5.*;

// Creating the instances

OscP5 oscP5;

NetAddress dest;

// Variable to store the output

public int output;

public int output1;

// Creating the instances to control the servo

SoftwareServo servo1;

SoftwareServo servo2;

void setup()

{

// Initializing the pins for servo

servo1 = new SoftwareServo(this);

servo1.attach(17);

servo2 = new SoftwareServo(this);

servo2.attach(4);

// Starting the communication with wekinator. listen on port 12000, return messages on port 6448

oscP5 = new OscP5(this, 12000);

dest = new NetAddress(“127.0.0.1”, 6448);

}

// Recieve OSC messages from Wekinator

void oscEvent(OscMessage theOscMessage) {

if (theOscMessage.checkAddrPattern(“/wek/outputs”) == true) {

// Receiving the output from wekinator

float value = theOscMessage.get(0).floatValue(); // First output

float val = theOscMessage.get(1).floatValue();

// Converting the output to int type

output = int(value);

output1 = int(val);

}

}

void draw()

{

if (output 》 0 && output 《 180)

{

servo1.write(output);

}

if (output1 》 0 && output1 《 180)

{

servo2.write(output1);

}

}

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時(shí)聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關(guān)閉