Guy on Simulink

Simulink & Model-Based Design

在LED中放一些颜色:使用Simulink从iPhone控制Raspberry Pi金宝app

本周,Mariano Lizarraga Fernandez又回来描述了他想出的一些很酷的东西iPhone and iPad Support from Simulinkin combination with theSimulink的Rasp金宝appberry Pi支持金宝app

Introduction

Color-controlled lighting has become increasingly popular, and, although sometimes it is purely ornamental, there is enough scientific evidence to show that the光的颜色在您的环境中直接影响您的circadian rhythm

There are multiple options in the market to buy off-the-shelf "Smart" lightbulbs and LED strips, that you can control with your mobile phone. However, wouldn't it be fun tobuild your own with Simulink?

在这篇文章中,我们将向您展示如何使用simulink,raspberry pi与金宝app感觉帽子add-on board, and your iPhone.

Producing Color Light using the Raspberry Pi's Sense HAT

Sense Hat是专门为专门开发的完整的附加板Astro Pi任务。It has a 9-DOF IMU (3 Accelerometers, 3 Gyros, and 3 magnetometers), a humidity sensor, a temperature sensor, a barometric pressure sensor and an 8 x 8 RGB LED matrix. In R2017a we introduced金宝app支持所有这些in our popular硬件支持包金宝app

LED矩金宝app阵的模型块允许您to control the RGB value of each LED individually or all together. To test this, you can create a Model that would allow you to either change the RGB value of the LEDs running in External mode, or by reading in an UDP datagram:

感觉帽子model

通过这种方式,您可以直接从Simulink开始播放和与LED进行交互,或将其部署到目标,并从同一网络上的另一个设备控制LED。金宝app

从iPhone控制覆盆子Pi

Now it is time to control those LEDs directly from your iPhone. Using theiPhone Support Packagewe can lay out a model where using three滑块and aUDP Sendblock we can send the datagram to the Raspberry Pi. It really is that simple!

简单的模型将在iPhone上部署

现在是时候为模型添加更多功能了。让我们尝试根据iPhone的后置摄像头的平均颜色来更改这些LED的颜色。为此,我们需要使用Camera block在视频流中阅读。因此,我们可以计算每个通道的平均值,并将其作为命令发送到LED。为了减少LED的闪烁,我们可以添加5 Hz单孔低通滤波器。

Putting it all Together

最后,我们可以在单个模型中同时使用滑块和图像平衡,并直接控制将LED的颜色设置为按钮

要查看发送给Raspberry Pi的实际值,我们可以使用R2017A中引入的新功能:金宝app移动应用中的Simulink范围

Full model to be deployed on iPhone

您可以在以下视频中自己看到它:

Now it's your turn

如果您在Raspberry Pi项目中使用Sense Hat,则可以充分利用R2017A中引入的支持。金宝app在iOS支持软件包上,金宝app新引入了对示波器块的支持,可直接在iPhone屏幕上访问变量的绘图。

尝试一下,让我们知道您的想法,通过在下面发表评论。

|

Comments

要发表评论,请单击here登录您的数学帐户或创建一个新帐户。