电路图
将其中一个蜂鸣器的正极连接到arduino的9针和arduino的10针的另一个蜂鸣器的正面。然后将两个蜂鸣器的负片连接到项目的arduino.section的地面。
如何运行代码
首先,在arduino ide中粘贴为本文末尾的arduino提供的代码并上传代码。
然后您需要从wekinator的示例页面下载草图。
下载源代码以处理简单的10x10颜色网格。解压缩并在处理中运行代码。该程序将使用您的笔记本电脑的网络摄像头,根据您在摄像头前所做的操作,它将为wekinator提供输入。
您需要另一个草图来输出wekinator的输出。这篇文章末尾的草图代码。将其粘贴到处理中并运行草图。这个草图将从wekinator输出并将其发送到arduino,蜂鸣器将播放不同的声音。
两个处理窗口应如下所示。
现在打开wekinator并进行如下图所示的设置。将输入设置为100,将输出设置为2.将类型设置为“自定义”,然后单击“配置”。
点击“配置”时“,一个新窗口将打开,如下所示。更改设置,如下图所示。
现在退出网络摄像头并点击“随机化”。开始录制半秒。
现在将右手显示在网络摄像头的右侧,然后单击“随机化”。然后开始录制半秒。
现在将左手显示在网络摄像头的左侧,然后单击“随机化”。然后开始录制半秒。
然后,单击“训练”,然后单击“运行”。现在,arduino将根据您在网络摄像头前显示的手势播放声音。
处理代码(wekinator输出)
import vsync.*; // importing the library that will help us in sending and receiving the values from the arduino
import processing.serial.*; // importing the serial library
// below libraries will connect and send, receive the values from wekinator
import oscp5.*;
import netp5.*;
// creating the instances
oscp5 oscp5;
netaddress dest;
valuesender sender;
// these variables will be syncronized with the arduino and they should be same on the arduino side.
public int output;
public int output1;
void setup()
{
// starting the serial communication, the baudrate and the com port should be same as on the arduino side.
serial serial = new serial(this, “com10”, 19200);
sender = new valuesender(this, serial);
// synchronizing the variables as on the arduino side. the order should be same.
sender.observe(“output”);
sender.observe(“output1”);
// 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(); // second output
// converting the output to int type
output = int(value);
output1 = int(val);
}
}
void draw()
{
// nothing to be drawn for this example
}
arduino代码
#include // including the library that will help us in receiving and sending the values from processing
valuereceiver《2》 receiver; /*creating the receiver that will receive up to 2 values.
put the number of values to synchronize in the brackets */
/* the below two variables will be synchronized in the processing
and they should be same on both sides. */
int output;
int output1;
// pin connected to buzzer
int buzzer = 9;
int buzzer1 = 10;
int i,j;
void setup()
{
/* starting the serial communication because we are communicating with the
arduino through serial. the baudrate should be same as on the processing side. */
serial.begin(19200);
// synchronizing the variables with the processing. the variables must be int type.
receiver.observe(output);
receiver.observe(output1);
// defines the buzzer pins as output
pinmode(buzzer,output);
pinmode(buzzer1,output);
}
void loop()
{
// receiving the output from the processing.
receiver.sync();
// making the buzzer to beep according to the output from the processing
tone(buzzer1, output);
delay(5);
notone(buzzer1);
tone(buzzer,output1);
delay(5);
notone(buzzer);
}
福特中国正式公布 Mustang Mach-E 中国制造计划 全球首个高性能纯电动平台打造
全球云计算的3A格局正向物联网市场延续
紧逼S7edge手机 Mark给华为P10相机打了很高的分
全天候户外扬尘监控系统改善空气质量
基于物联网技术的下水道溢流监测系统解决下水道溢流
如何通过Wekinator平台使用手势控制Arduino
大数据要如何助力汽车新零售新金融的腾飞呢?
AD9361 RF捷变收发器的性能及应用
小马智行自研自动驾驶域控制器ADC已开始向用户交付样品
在Android 12中,操作系统的更新可能会更容易
你觉得区块链具有颠覆意义吗
新能力让数据多端协同更便捷,数据跨端迁移更高效
RF检波器的类型及应用范围
有没有音质比较好的蓝牙耳机?音质出色的蓝牙耳机推荐
模块电源使用四大注意事项
镜面显示屏已成为了智慧厕所广告投放的全新方式
国内外巨头争相圈地探索更多AI落地范本
伺服驱动器的功能作用及相关参数
帝豪EV年度首次登得新能源乘用车销量榜首,比亚迪继续保持插混强势地位
基于对图片的语音描述,可以学习在图片中辨认目标物体