连接rgb led的最长脚到arduino。通过220欧姆电阻将其他支路连接到arduino的引脚9,10和11,如下面的电路图所示。
如何运行程序
首先,粘贴在arduino ide中本文末尾为arduino提供的代码并上传代码。
然后,您需要从wekinator的示例页面下载草图。
下载mfcc的可执行文件(mel频率倒频谱系数)。我有一个64位操作系统,所以我从那里下载了“win64”。
下载后,解压缩并运行“.exe”文件。它将如下所示。现在您需要一个麦克风来为wekinator提供输入。如果您已连接外接麦克风,请确保在计算机的声音设置中选择它。
您将需要另一个草图(“输出草图”) )从wekinator获得输出。该草图在本文末尾给出。将其粘贴到新的处理窗口并运行草图。
现在打开wekinator并进行如下图所示的设置。将输入设置为13,将输出设置为1.将类型设置为“所有动态时间扭曲”,使用3种手势类型,然后单击“下一步”。
现在按住output_1前面的“+”按钮并说“红色”。
然后按住output_2前面的“+”按钮并说“绿色”。
然后按住output_3前面的“+”按钮并说“蓝色”。
之后,单击“train”,然后单击“run”。现在,rgb led的颜色将根据您说的颜色名称而改变。
arduino代码
#include //including the library that will help us in receiving and sending the values from processing
valuereceiver《1》 receiver; /*creating the receiver that will receive 1 value.
put the number of values to synchronize in the brackets */
/* the below variable will be synchronized in the processing
and they should be same on both sides. */
int output;
// initializing the pins for led‘s
int red_light_pin= 11;
int green_light_pin = 10;
int blue_light_pin = 9;
void setup()
{
/* starting the serial communication because we are communicating with the
processing through serial. the baudrate should be same as on the processing side. */
serial.begin(19200);
pinmode(red_light_pin, output);
pinmode(green_light_pin, output);
pinmode(blue_light_pin, output);
// synchronizing the variable with the processing. the variable must be int type.
receiver.observe(output);
}
void loop()
{
// receiving the output from the processing.
receiver.sync();
// matching the received output to light up the rgb led
if (output == 1)
{
rgb_color(255, 0, 0); // red
}
else if (output == 2)
{
rgb_color(0, 255, 0); // green
}
else if (output ==3)
{
rgb_color(0, 0, 255); // blue
}
}
void rgb_color(int red_light_value, int green_light_value, int blue_light_value)
{
analogwrite(red_light_pin, red_light_value);
analogwrite(green_light_pin, green_light_value);
analogwrite(blue_light_pin, blue_light_value);
}
处理代码(输出草图)
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;
// this variable will be syncronized with the arduino and it should be same on the arduino side.
public int output;
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 variable as on the arduino side.
sender.observe(“output”);
// 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);
}
//this is called automatically when osc message is received
void oscevent(oscmessage theoscmessage) {
if (theoscmessage.checkaddrpattern(“/output_1”)==true)
{
output = 1;
}
else if (theoscmessage.checkaddrpattern(“/output_2”)==true)
{
output = 2;
}
else if (theoscmessage.checkaddrpattern(“/output_3”) == true)
{
output = 3;
}
else
{
}
}
void draw()
{
// nothing to be drawn for this example
}
医疗废物在线管理系统架构
S7-200 PLC如何使用SCR指令
超详细的常见电源电路图及原理讲解!
在运营商领域再获突破!联想与广东电信签署战略协议
美国有近8%的人表示他们计划在未来购买数字货币
怎样用声音控制RGBLED的颜色
华为全面屏手机新专利将要把听筒设置在屏幕内
高可靠低时延通信技术专利预警分析报告
小米MIX 2S相机评测机“双核对焦”详解
嵌入式C编码需要遵循的规范有哪些?
什么是无人值守巡检系统,它都有哪些优势
划片机的性能决定了芯片产品的质量!
基于CXL技术的大内存池化方案解析
泄漏揭示了有关A93 5G显示屏的重要细节
接近开关的工作原理是什么
两岸产业优势互补携手共创IC封测新局
5G为何这么快?得从这五大发明说起
关于非洲猪瘟检测器技术参数的详细介绍
发展国产电动机伺服有前途
高压线束零部件——连接器