如何使用Wekinator输出播放Arduino的噪音

电路图
将其中一个蜂鸣器的正极连接到arduino的9针,将另一个蜂鸣器的正极连接到arduino的10针。然后将两个蜂鸣器的底片连接到arduino的底部。
如何运行程序
首先,在arduino ide的帖子末尾粘贴为arduino提供的代码并上传代码。
然后您需要从wekinator的快速演练页面下载草图。
下载屏幕上的鼠标控制示例。解压缩并在处理中运行草图。该草图将为wekinator提供输入。您将需要wekinator输出的另一个草图。该草图的代码在本文末尾。将其粘贴到处理中并运行它。两个处理输出窗口如下所示:
现在打开wekinator并进行如下图所示的设置。将输入和输出设置为2.将类型设置为自定义,然后单击“配置”。您还可以查看下面附带的视频以查看过程
当您点击“configure”时,会打开一个新窗口,如下图所示。在该窗口中设置设置,如下图所示。
现在将处理窗口中的绿框拖到左下角,然后点击“随机”。开始录制半秒。
将处理窗口中的绿色框拖到中间顶部,然后单击“randomize”。开始录制半秒。
将处理窗口中的绿框拖到右下角,然后单击“随机化”。之后,开始录制半秒。
然后点击“train”,然后点击“run”。现在,当您在处理窗口中拖动绿色框时,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);
}

近年来国内PLC技术的进展和市场发展展望
路特斯电动汽车部门拟3月底前在纳斯达克上市
使用RX23E-A瑞萨解决方案入门套件进行准确的传感评估
PCB天线设计
89C51单片机中文简介,introduction of 89C51
如何使用Wekinator输出播放Arduino的噪音
数字隔离器将在多领域取代光耦
锂电池爆炸的原因是什么
vlookup如何一次性匹配多列数据
基于FPGA的心音采集系统
晶电表示预计2020年下半年MiniLED产品会有比较大的出货量
基于人机界面产品和总线技术实现变频器参数管理系统的设计
矿石提锂和盐湖提锂靠谱吗?
Matter设备的测试与认证
“跨界合作”360手机N5两天后登场:骁龙635+6GB大运存 重新定义多任务
魅蓝6T评测 市场竞品众多但魅蓝6T小有优势
特斯拉4680电池与比亚迪刀片电池的拆解分析
科创板航天宏图副总经理李济生介绍、履历信息
基于LBT01 LoRa的GPS跟踪器和来自LoRa的BLE信标
唯样荣获2018年度电子元器件“杰出电商平台”称号