亿迅智能制造网
工业4.0先进制造技术信息网站!
首页 | 制造技术 | 制造设备 | 工业物联网 | 工业材料 | 设备保养维修 | 工业编程 |
home  MfgRobots >> 亿迅智能制造网 >  >> Manufacturing Technology >> 制造工艺

电视剧/动漫新剧集发布日期通知器

组件和用品

JLCPCB定制PCB
× 1
Arduino Nano 33 IoT
× 1
Raspberry Pi 3 B 型
Raspberry Pi 3 或 Raspberry Pi 4
× 1
Raspberry Pi 4 B 型
Raspberry Pi 3 或 Raspberry Pi 4
× 1
SparkFun Nokia 5110 屏幕
× 1
OPEN-SMART 的串行 MP3 播放器
× 1
RGB 扩散共阳极
× 1
闪存卡、SD 卡
× 2
电阻 220 ohm
× 12
按钮开关 6x6x5
× 4
TaydaElectronics DC POWER JACK 2.1MM BARREL-TYPE PCB MOUNT
× 1

必要的工具和机器

烙铁(通用)
热胶枪(通用)

应用和在线服务

Arduino IDE
KiCad
NotePad++

关于这个项目

说明

虽然有无数的网络和移动应用程序来跟踪最喜欢节目的发布日期,但我想创建一个设备,当我的列表中的新剧集或动画从头开始发布时通知我 - 硬件和软件 - 与各种功能。

首先,我在 PHP 中创建了一个 Web 应用程序 - TV Series / Anime Release Date Tracker - 以创建系列/动漫列表并收集有关其发布日期的信息。在这方面,我使用了 TVMAZE REST API,该 API 允许应用程序按发布日期准确获取剧集信息,尽管没有杂项和复杂的编码步骤。然后,我在 Raspberry Pi 上设置了一个 LAMP(带有 MariaDB)服务器来运行该应用程序。但是,对于那些没有 Raspberry Pi 也不想使用 Raspberry Pi 作为主机的人,我在我的网站上发布了具有用户友好界面的免费版本的应用程序。另外,您可以在下面找到该应用程序的源代码。

完成与web应用程序的信息传输后,如果有新的发布,我决定使用Arduino Nano 33 IoT作为开发板来整理应用程序生成的数据。您可以在下面找到有关我如何使用分隔符整理应用程序传输的响应的更多信息。而且,为了管理我在 Nano 33 IoT 上实现的功能和模式,我设计了一个带有诺基亚 5110 屏幕和按钮的用户界面(菜单)。

最后,为了在我的列表中发布新剧集及其开场曲时获得通知,我使用了串行 MP3 播放器模块 (OPEN-SMART),因为它具有简单易用的 UART 命令列表。此外,它让我添加了 MP3 播放器模式来播放所有开场歌曲,这使该设备成为我房间的有趣配件:)

在面包板上完成我的设计并测试代码后,我设计了一个具有独特复古电话形状的 PCB(电视剧/动漫发布日期通知器),以创建一个全新的外观和易于使用的设备。

非常感谢 JLCPCB 赞助这个项目。

步骤 1:设计和焊接电视连续剧/动漫发布日期通知器 PCB

我使用 KiCad 设计了电视剧/动漫发布日期通知程序 PCB。我在下面附上了 PCB 的 Gerber 文件,所以如果你愿意,你可以从 JLCPCB 订购这个 PCB 来复制这个项目,以便在你最喜欢的节目有新剧集发布时得到通知:)

首先,通过使用烙铁,我连接了接头、按钮、220Ω电阻、电源插孔、5mm阳极RGB LED。

PCB上的元件列表:

A1(Arduino Nano 33 IoT 的标头)

J1(串行 MP3 播放器的标题)

J2(DS3231 的标头 - 不需要)

J3(诺基亚 5110 屏幕标题)

J4(电源插孔)

D1(5 毫米阳极 RGB LED)

K1、K2、K3、K4(按钮)

R1、R2、R3、R4、R5、R6、R7、R8、R9、R10、R11、R12(220Ω电阻)

第 2 步:在 Raspberry Pi 上使用 MariaDB 设置 LAMP Web 服务器

如果您是使用 Raspberry Pi 编程的新手,您可以在 Raspberry Pi 官方网站上查看解释清楚的说明和教程。

要转到官方 Raspberry Pi 设置教程,请单击此处。

  • 从菜单中选择附件> 终端打开终端窗口。
  • 通过在终端中键入以下命令并按 Enter 来安装 apache2 包:

sudo apt-get install apache2 -y

  • 要测试服务器,请通过从菜单中选择 Internet> Chromium Web Browser 并输入 http://localhost 来打开 Chromium。
  • 如果需要,您也可以使用 Raspberry Pi 的 IP 地址。

主机名 -I

  • 使用以下命令安装 PHP 包:
  • 不要忘记更新 Pi。

sudo apt-get 更新

sudo apt-get install php -y

  • 通过在终端窗口中输入以下命令来安装 MySQL 服务器 (MariaDB) 和 PHP-MySQL 包:

sudo apt-get install mariadb-server php-mysql -y

  • 要创建新用户,请在终端窗口中运行 MySQL 安全安装命令。

sudo mysql_secure_installation

  • 您将被要求输入当前 root 密码(输入无): — 按 Enter。
  • 输入 Y 并按 Enter 以设置 root 密码 .
  • 输入机器人新密码: 提示,然后按 Enter。
  • 输入 Y 以删除匿名用户 .
  • 输入 Y 以禁止远程 root 登录 .
  • 输入 Y 以删除测试数据库并访问它 .
  • 输入 Y 以立即重新加载权限表 .
  • 完成后,您将看到此消息 - 全部完成!并感谢您使用 MariaDB!

  • 要创建一个数据库 (tvseries) 来保存 TVMAZE REST API 生成的变量,请在终端窗口中运行此 MySQL 命令:

sudo mysql -uroot -p

  • 输入 root 密码 - bot
  • 您将收到消息欢迎使用 MariaDB 监视器 .
  • MariaDB [(none)]> 后面遵循以下几行 :提示创建 tvseries MariaDB 中的数据库:

创建数据库tvseries;

授予 tvseries 上的所有权限。* 给 'root'@'localhost' 由 'bot' 识别;

同花顺特权;

  • 使用 Ctrl + D 退出 MariaDB 提示符。

  • 仅使用 file_get_contents() 从 TVMAZE REST API 获取数据 PHP 中的函数,安装 php-curl 包:

sudo apt-get install php-curl

  • 然后,重新启动 apache 服务器,以便能够使用本地主机上安装的软件包:

sudo 服务 apache2 重启

第 3 步:从 TVMAZE REST API 获取有关您最喜欢的系列/动漫的信息

TVMAZE 提供免费且易于使用的 REST API,允许用户按名称、日期、剧集编号等搜索节目。您可以检查可用的端点和查询:

转到 TVMAZE REST API。

我使用了按日期显示的剧集 选项来检索给定节目中在特定日期播出的所有剧集。

为了能够按发布日期获取信息,您需要在 TVMAZE 上搜索您喜欢的节目并使用其链接中指定的电视 ID。

  • 网址:/shows/:id/episodesbydate?date=:date
  • 日期:ISO 8601 格式
  • 示例:http://api.tvmaze.com/shows/1/episodesbydate?date=2013-07-01

如果有在给定日期播出的剧集,API 将返回完整剧集信息的数组。

否则,API 将返回 HTTP 404。

在下面,您可以查看我创建的我最喜欢的系列/动漫列表,以跟踪其中是否有与我的项目一起发布的新剧集。

我添加了 The Late Late Show 来测试我的代码,因为它是一个日常节目。

1) 一件

电视 ID:1505

https://www.tvmaze.com/shows/1505/one-piece

2) 我的英雄学院

电视 ID:13615

https://www.tvmaze.com/shows/13615/boku-no-hero-academia

3) 西部世界

电视 ID:1371

https://www.tvmaze.com/shows/1371/westworld

4) 辛普森一家

电视 ID:83

https://www.tvmaze.com/shows/83/the-simpsons

5) James Corden 的深夜秀

电视 ID:2831

https://www.tvmaze.com/shows/2831/the-late-late-show-with-james-corden

第 4 步:使用 PHP 开发在 Raspberry Pi 上运行的电视剧/动漫发布日期跟踪器(应用程序)并创建系列表以插入数据

我用 PHP 开发了电视剧/动漫发布日期跟踪器,并在下面的代码说明部分为感兴趣的人解释了应用程序的源代码。

但是,如果您不喜欢使用 PHP 进行 Web 开发,则可以在下载中下载该应用程序 - 名为 TV-Series-Anime-Episode-Tracker.zip - 并将其上传到 Raspberry Pi,无需深入研究 PHP 编码。

上传 <代码>:

通过以下步骤,在本地主机上安装电视剧/动漫发布日期跟踪器:

  • 下载应用程序 - TV-Series-Anime-Episode-Tracker.zip - 包括 index.php 和 query.php 文件。

  • 提取 TV-Series-Anime-Episode-Tracker.zip。

  • 使用终端将应用程序文件夹 (TV-Series-Anime-Episode-Tracker) 从下载移动到服务器 (/var/www/html),因为 apache 服务器是受保护的位置。

sudo mv /home/pi/Downloads/TV-Series-Anime-Episode-Tracker/ /var/www/html/

  • 转到电视剧/动漫发布日期跟踪器:

http://localhost/TV-Series-Anime-Episode-Tracker/

特点 <代码>:

1)安装完成后,打开应用程序,在数据库中创建一个名为series的表(tvseries)。当您第一次打开 index.php 文件时,应用程序会自动创建名为 series 的表并通知用户 - Database Table Created!

2) 如果数据库表(系列)在数据库中创建成功,应用程序通知用户 - Database Table Found!

3) 创建数据库表(系列)后,为列表中的每个节目插入 TVMAZE REST API 所需的变量,请执行以下步骤:

  • 在终端窗口中运行此 MySQL 命令:

sudo mysql -uroot -p

  • 输入 root 密码 - bot
  • 选择电视剧 数据库:

使用电视连续剧;

  • 将所需的变量 - 系列名称、电视 ID、状态 - 插入每个节目的表格中。应用程序使用状态变量在给定日期发布新剧集时通知用户而不会重复。

INSERT INTO `series` (`series_name`, `tv_id`, `status`) VALUES ('One Piece', '1505', 'Pending');

5) 在 query.php 上,应用程序向 TVMAZE REST API 发出请求,以检测数据库中的新剧集是否正在发布。如果 TVMAZE REST API 返回已发布剧集的完整剧集信息数组,该应用程序将打印一次可由 Arduino Nano 33 IoT 整理的信息,以防止再次发生。

http://localhost/TV-Series-Anime-Episode-Tracker/query.php

%Series_Name%Season%Episode_Number%Episode_Name%

%The Late Late Show%2020%91%Jason Schwartzman, Alicia Key%

6) 否则,应用程序打印未找到条目!

代码说明 <代码>:

1) index.php

  • 定义数据库连接设置 - “localhost”、“root”、“bot”、“tvseries”。
  • checkDatabase() 函数,检测给定名称-series中是否存在数据库表。
  • createTable() 函数,如果在数据库中没有找到,则创建系列表并通知用户。

2) query.php

  • 查询中 类,定义 TVMAZE API 的路径以发出请求。
  • define_user() 函数,获取连接设置和表名。
  • check_ep_release_date() 函数,使用 file_get_contents() 功能,检测当前日期是否有给定电视 ID 的新剧集正在发布。如果新剧集正在发布,请将数据库中的状态变量从 Pending 更改为 Released,以防止再次发生。
  • track_db_entries() 函数,执行check_ep_release_date() 对于在数据库表中注册的每个节目 - 系列。

步骤 4.1:在没有 Raspberry Pi 的情况下执行 Web 应用程序

对于我的网站 (TheAmplituhedron) 的订阅者,我为那些没有 Raspberry Pi 也不想将其用作此项目的主机的人开发了免费版本的电视剧/动漫发布日期跟踪器。

它提供了一个用户友好的界面来管理数据库。如果你想在你的项目中使用这个接口,而不是使用树莓派上的终端来插入数据,请联系我。

转到应用程序:

https://www.theamplituhedron.com/dashboard/TV-Series-Anime-Episode-Tracker/

第 5 步:设置 Arduino Nano 33 IoT

如果您是使用 Arduino Nano 33 IoT 编程的新手:别担心,使用 Arduino IDE 很简单。只需下载所需的驱动程序 - Arduino SAMD Core - 此处也有说明。

为了能够通过 Arduino Nano 33 IoT 连接到 WiFi,请从这里下载 WiFiNINA 库。

要在诺基亚 5110 屏幕上打印文本和绘制图形,请从此处下载 LCD5110_Basic 库。

我使用 Arduino Nano 33 IoT 上的第二个串行端口 (Serial1) 与串行 MP3 播放器通信。

Arduino Nano 33 IoT 上的串行端口

“板子的USB连接器直接连接到SAMD21的USB主机引脚。此路由使您可以将Arduino NANO 33 IoT用作客户端USB外设(充当连接到计算机的鼠标或键盘) ) 或作为 USB 主机设备,以便鼠标、键盘或 Android 手机等设备可以连接到 Arduino NANO 33 IoT。该端口也可以用作使用 Arduino 编程语言中的 Serial 对象的虚拟串口. RX0 和 TX1 引脚是作为 Serial1 可用的第二个串行端口。”

然后,Arduino Nano 33 IoT 就可以执行项目代码了 :)

步骤 6:向串行 MP3 播放器 (OPEN-SMART) 发送命令

我创建了一个播放列表,其中包含这个项目中我最喜欢的系列/动漫列表的开场歌曲:

1) 一件 - 开场 |听着

2) 我的英雄学院 - 开幕 |听着

3) 西部世界 - 开幕 |听着

4) 辛普森一家 - 开幕 |听着

5) The Late Late Show - 开幕 |听着

如果你愿意,你可以在一个压缩文件夹中下载我的播放列表 - opening_songs.zip。

只要您知道触发正确功能所需的 UART 命令,就可以毫不费力地将串行 MP3 播放器与 Arduino Nano 33 IoT 结合使用。我使用了 OPEN-SMART 的带有扬声器的串行 MP3 播放器模块。因此,如果您有一个不同品牌的串行 MP3 播放器,下面显示的这些命令将不适合您。

按照指南中的说明进行操作:

"该模块是一种基于高品质MP3音频芯片的简单MP3播放设备,可支持8k Hz~48k Hz采样频率的MP3和WAV文件格式。板载TF卡插槽, 这样你就可以插上存储音频文件的micro SD卡了,MCU可以通过UART口向模块发送命令来控制MP3播放状态,比如切换歌曲、改变音量和播放模式等。你也可以通过USB转UART模块调试模块,兼容Arduino/AVR/ARM/PIC。"

“确保你的micro SD卡格式为FAT16或FAT32,里面有一些歌曲。你应该创建文件夹“01”和“02”,并放置一些名称为001xxx.mp3 / 002xxx.mp3的歌曲/003xxx.mp3 在其中。”

换句话说,为了能够准确地执行命令,请将您的歌曲保存在名为“01”的文件夹中,并在歌曲名称中添加连续数字 - 001One Piece-Opening.mp3、002My Hero Academia-Opening.mp3 等。

为了使用 Arduino Nano 33 IoT 向串行 MP3 播放器发送 UART 命令,我创建了一个名为 send_command_to_MP3_player 的函数 .它通过 RX0 和 TX1 引脚上的第二个串行端口将请求命令中的每个字节传输到串行 MP3 播放器 - Serial1 - 取决于所请求命令的长度 - 4、5 或 6。

如下图,将要发送到串行 MP3 播放器的命令按字节分隔 - 0x7e。所有命令都以“7E”开头并以“EF”结尾。第二个字节是介于 '02'、'03'、'04' 之间的字节数。下面,下载 OPEN-SMART 的串行 MP3 播放器手册以检查所有命令并获得更详细的说明。

// 定义所需的 MP3 播放器命令。
// 您可以从项目页面检查所有给定的命令:
// 选择存储设备到 TF 卡
static int8_t select_SD_card[] ={0x7e, 0x03, 0X35, 0x01, 0xef}; // 7E 03 35 01 EF
// 播放带有目录的歌曲:/01/001xxx.mp3
static int8_t play_song_1[] ={0x7e, 0x04, 0x41, 0x00, 0x01, 0xef}; // 7E 04 41 00 01 EF
// 播放带有目录的歌曲:/01/002xxx.mp3
static int8_t play_song_2[] ={0x7e, 0x04, 0x41, 0x00, 0x02, 0xef}; // 7E 04 41 00 02 EF
// 播放带有目录的歌曲:/01/003xxx.mp3
static int8_t play_song_3[] ={0x7e, 0x04, 0x41, 0x00, 0x03, 0xef}; // 7E 04 41 00 03 EF
// 播放带有目录的歌曲:/01/004xxx.mp3
static int8_t play_song_4[] ={0x7e, 0x04, 0x41, 0x00, 0x04, 0xef}; // 7E 04 41 00 04 EF
// 播放带有目录的歌曲:/01/005xxx.mp3
static int8_t play_song_5[] ={0x7e, 0x04, 0x41, 0x00, 0x05, 0xef}; // 7E 04 41 00 05 EF
// 播放歌曲。
static int8_t play[] ={0x7e, 0x02, 0x01, 0xef}; // 7E 02 01 EF
// 暂停歌曲。
static int8_t pause[] ={0x7e, 0x02, 0x02, 0xef}; // 7E 02 02 EF
// 下一首歌曲。
static int8_t next_song[] ={0x7e, 0x02, 0x03, 0xef}; // 7E 02 03 EF
// 上一首歌曲。
static int8_t previous_song[] ={0x7e, 0x02, 0x04, 0xef}; // 7E 02 04 EF

第 7 步:编程 Arduino Nano 33 IoT

  • 包括所需的库。
  • 定义您的 WiFi 设置 - SSID 和密码。
  • 输入 Raspberry Pi 的 IP 地址。
  • 在 Raspberry Pi 中定义应用程序 (query.php) 的路径。
  • 初始化以太网客户端库。
  • 定义诺基亚 5110 屏幕设置。
  • 定义相关屏幕模式的图形 - 电视和音乐。
  • 要创建不同的图形(单色图像),请转到单色图像转换器。
  • 定义所需的 MP3 播放器命令。
  • 使用可变布尔值定义菜单选项和模式。
  • 定义控制按钮和 RGB LED 引脚。
  • 为第二个串行端口上的串行 MP3 播放器模块启动串行通信 - Serial1 .
  • 连接到 WiFi 网络。
  • 验证串行监视器和诺基亚 5110 屏幕上的连接。
  • read_buttons() 功能,从控制按钮获取数据 - 右、确定、左和退出。
  • change_menu_options() , 使用向右和向左按钮增加或减少选项编号。
  • interface() 功能,打印界面(菜单)。
  • 如果 Init Tracker 选择模式,连接到名为 TV Series/Anime Release Date Tracker 的 Web 应用程序。
  • 如果有可用的传入字节,则从 Web 应用程序获取响应。
  • 使用 endsWith() 函数,检测响应中是否包含百分比符号(分隔符)。
  • 如果包含,则通过预定义的分隔符以简单的方式拆分响应字符串。 '%'(百分比) 在此项目中被定义为分隔符。
  • 将信息作为子字符串收集 - Series_Name、Season、Episode、Episode_Name。
  • 打印信息并播放已发布系列/动漫的开场曲直到停止。
  • 等待退出按钮被按下。
  • 如果有空白响应,请打印未检测到已发布的剧集:(
  • 在计算新请求时绘制电视图标。
  • 等到下一个请求。
  • 如果 MP3 播放器模式 选中后,绘制音乐播放器图标。使用控制按钮(右、左、确定)控制 MP3 播放器。
  • 如果睡眠模式 被选中,在 10 秒内激活睡眠模式并打印剩余的秒数。

连接和调整

// Connections
// Arduino Nano 33 IoT:
// Nokia 5110 Screen
// D2 -------------------------- SCK (Clk)
// D3 -------------------------- MOSI (Din)
// D4 -------------------------- DC
// D5 -------------------------- RST
// D6 -------------------------- CS (CE)
// RGB
// D9 -------------------------- R
// D10 -------------------------- G
// D11 -------------------------- B
// LEFT_BUTTON
// A0 --------------------------- S
// OK_BUTTON
// A1 --------------------------- S
// RIGHT_BUTTON
// A2 --------------------------- S
// EXIT_BUTTON
// A3 --------------------------- S
// DS3231 (Optional for Nano and Not Required for Nano 33 IoT)
// A4 --------------------------- SDA
// A5 --------------------------- SCL

After finishing and uploading the code to the Arduino Nano 33 IoT, I attached all required components to the board via headers.

I also provided a connection slot for a DS3231 RTC Module for those who want to change the Arduino Nano 33 IoT with the Arduino Nano. But, you need to enter release dates manually for each show to the Arduino Nano without being able to obtain data from the web application to create a countdown timer with the RTC.

Note:You can connect either a speaker or headphones to the Serial MP3 Player to listen to soundtracks in the playlist. I connected the speaker delivered in addition to the Serial MP3 Player (OPEN-SMART).

Modes and Features

1) While the device tries to connect to the WiFi network, it displays Waiting... Attempting to connect to WiFi .

2) After establishing a successful connection, the device informs the user with this message - Connected to WiFi!!!

3) Then, the device prints the interface (menu) presenting available modes - A.Init Tracker, B.MP3 Player , and C.Sleep . To switch among modes, use the Right and Left buttons. Subsequently, press the OK button to select a mode.

A.Init Tracker

A.1) After selecting the A.Init Tracker mode, the device attempts to connect to the localhost hosted by the Raspberry Pi. If successful, it informs the user with this message - Connected to the server!!! Conversely, the device displays this message - Connection Error!!!

A.2) If the application (TV Series / Anime Release Date Tracker) sends a data string that of a released episode of a registered series/anime in the database, then the device:

  • Prints the episode information - Series Name, Season, Episode Number, and Episode Name:

One Piece, 10x54, Luffy's Determination

  • Plays the opening song of the released series/anime,
  • And, turns the RGB to the color assigned to the released series/anime.

For instance, I assigned these colors below for each show in my list:

  • One Piece -> Red
  • My Hero Academia -> Green
  • Westworld -> Blue
  • The Simpsons -> Yellow
  • The Late Late Show -> Purple

Unless the Exit button is pressed, the device keeps displaying the episode information and showing the assigned color.

The device notifies the user for once for each released episode to prevent any recurrence.

A.3) After the Exit button is pressed, the device draws the television icon while waiting for the next request to the application.

A.4) If there is no released episode of a registered series/anime in the database, the device displays this message - No Released Episode Detected :( - and then; draws the television icon until the next request to the application.

A.5) The device returns to the interface (menu) if the Exit button is pressed while displaying the television icon.

B. MP3 Player

I implemented this feature as a subsidiary and fun one to turn this device into an intriguing accessory for my room.

B.1) After selecting the B.MP3 Player mode, the device draws the music note icon and lets the user play all opening songs by using the control buttons:

  • Right - Next Song
  • Left - Previous Song
  • OK - Pause

B.2) The device returns to the interface (menu) if the Exit button is pressed.

C.Sleep

C.1) After selecting the C.Sleep mode, the device enables the sleep mode in 10 seconds and prints the remaining seconds on the screen.

C.2) While maintaining the sleep mode, the device applies a given color pattern to the RGB as a nightlight.

C.3) The device returns to the interface (menu) if the Exit button is pressed.

Videos and Conclusion

After completing all steps above, I decided to fasten the device to my bookcase by using a hot glue gun. It works stupendously :)

代码

  • Series_Release_Date_Notifier.ino
  • index.php
  • query.php
Series_Release_Date_Notifier.inoArduino
 //////////////////////////////////////////////////// // TV Series / Anime New Episode // // Release Date Notifier // // ------------------------- // // Arduino Nano 33 IoT // // by Kutluhan Aktar // // // ////////////////////////////////////////////////////// Get informed when new episodes of your favorite shows are on release with their opening songs via Nano 33 IoT and Raspberry Pi. //// I developed a corroborating web application in PHP for this project, named TV Series / Anime Release Date Tracker. // You can either use a Raspberry Pi as the server, explained in the project tutorial, or TheAmplituhedron with the real-time database interface if you are a member. //// For more information:// https://www.theamplituhedron.com/projects/TV-Series-Anime-New-Episode-Release-Date-Notifier/// // You can use the mentioned web application in free version on TheAmplituhedron as the host server if you are a subscriber:// https://www.theamplituhedron.com/dashboard/TV-Series-Anime-Episode-Tracker///// Connections// Arduino Nano 33 IoT:// Nokia 5110 Screen// D2 --------------------------- SCK (Clk)// D3 --------------------------- MOSI (Din) // D4 --------------------------- DC // D5 --------------------------- RST// D6 --------------------------- CS (CE)// RGB// D9 --------------------------- R// D10 --------------------------- G// D11 --------------------------- B// LEFT_BUTTON// A0 --------------------------- S// OK_BUTTON// A1 --------------------------- S// RIGHT_BUTTON// A2 --------------------------- S// EXIT_BUTTON// A3 --------------------------- S// DS3231 (Optional for Nano and Not Required for Nano 33 IoT)// A4 --------------------------- SDA // A5 --------------------------- SCL// Include required libraries:#include #include #include char ssid[] ="[_SSID_]"; // your network SSID (name)char pass[] ="[_PASSWORD_]"; // your network password (use for WPA, or use as key for WEP)int keyIndex =0; // your network key Index number (needed only for WEP)int status =WL_IDLE_STATUS;// Note:Uncomment equivalent connection settings provided under related lines for using the web application hosted on TheAmplituhedron if you are a subscriber.// Enter the IPAddress of your Raspberry Pi.IPAddress server(192, 168, 1, 22);/* // name address for TheAmplituhedron. Change it with your server if you are using a different host server than TheAmplituhedron.char server[] ="www.theamplituhedron.com";*/// Define the pathway of the application in Raspberry Pi.String application ="/TV-Series-Anime-Episode-Tracker/query.php";/*// Define your hedron if you are using TheAmplituhedron as the host server for this project:String HEDRON ="[_HEDRON_]";// Define the pathway of the web application. If you are using TheAmplituhedron as the host server for this project as I did, just enter your hedron. Otherwise, enter the pathway on your server.String application ="/dashboard/TV-Series-Anime-Episode-Tracker/" + HEDRON;*/// Initialize the Ethernet client libraryWiFiClient client;/* WiFiSSLClient client; */// Define screen settings.LCD5110 myGLCD(2,3,4,5,6);extern uint8_t SmallFont[];extern uint8_t MediumNumbers[];// Define the graphics for related screen modes.extern uint8_t tv[];extern uint8_t music[];// Define the required MP3 Player Commands.// You can inspect all given commands from the project page:// Select storage device to TF cardstatic int8_t select_SD_card[] ={0x7e, 0x03, 0X35, 0x01, 0xef}; // 7E 03 35 01 EF// Play the song with the directory:/01/001xxx.mp3static int8_t play_song_1[] ={0x7e, 0x04, 0x41, 0x00, 0x01, 0xef}; // 7E 04 41 00 01 EF// Play the song with the directory:/01/002xxx.mp3static int8_t play_song_2[] ={0x7e, 0x04, 0x41, 0x00, 0x02, 0xef}; // 7E 04 41 00 02 EF// Play the song with the directory:/01/003xxx.mp3static int8_t play_song_3[] ={0x7e, 0x04, 0x41, 0x00, 0x03, 0xef}; // 7E 04 41 00 03 EF// Play the song with the directory:/01/004xxx.mp3static int8_t play_song_4[] ={0x7e, 0x04, 0x41, 0x00, 0x04, 0xef}; // 7E 04 41 00 04 EF// Play the song with the directory:/01/005xxx.mp3static int8_t play_song_5[] ={0x7e, 0x04, 0x41, 0x00, 0x05, 0xef}; // 7E 04 41 00 05 EF// Play the song.static int8_t play[] ={0x7e, 0x02, 0x01, 0xef}; // 7E 02 01 EF// Pause the song.static int8_t pause[] ={0x7e, 0x02, 0x02, 0xef}; // 7E 02 02 EF// Next song.static int8_t next_song[] ={0x7e, 0x02, 0x03, 0xef}; // 7E 02 03 EF// Previous song.static int8_t previous_song[] ={0x7e, 0x02, 0x04, 0xef}; // 7E 02 04 EF// Define menu options and modes using volatile booleans.volatile boolean TV =false;volatile boolean Music =false;volatile boolean Sleep =false;volatile boolean Activated =false;// Define the control buttons.#define B_Exit A3#define B_Right A2#define B_OK A1#define B_Left A0// Define RGB LED pins.#define redPin 9#define greenPin 10#define bluePin 11// Define data holders:int Right, OK, Left, Exit;int selected =0;void setup() { // Buttons:pinMode(B_Exit, INPUT); pinMode(B_Right, INPUT); pinMode(B_OK, INPUT); pinMode(B_Left, INPUT); // RGB:pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); adjustColor(0, 0, 0); // Black // Initiate screen. myGLCD.InitLCD(); myGLCD.setFont(SmallFont); Serial.begin(9600); // Initiate serial communication for the Serial MP3 Player Module. Serial1.begin(9600); // Select the SD Card. send_command_to_MP3_player(select_SD_card, 5); // check for the WiFi module:if (WiFi.status() ==WL_NO_MODULE) { Serial.println("Communication with WiFi module failed!"); myGLCD.print("Connection Failed!", 0, 8);同时(真); } // attempt to connect to Wifi network:while (status !=WL_CONNECTED) { Serial.print("Attempting to connect to SSID:"); Serial.println(ssid); myGLCD.print("Waiting...", 0, 8); myGLCD.print("Attempting to", 0, 16); myGLCD.print("connect to", 0, 24); myGLCD.print("WiFi !!!", 0, 32); // Connect to WPA/WPA2 network. Change this line if using open or WEP network:status =WiFi.begin(ssid, pass); // wait 10 seconds for connection:delay(10000); } // Verify connection on both the serial monitor and Nokia 5110 Screen. Serial.println("Connected to wifi"); myGLCD.clrScr(); myGLCD.print("Connected to", 0, 8); myGLCD.print("WiFi!!!", 0, 16);延迟(2000); myGLCD.clrScr();}void loop() { read_buttons(); change_menu_options(); interface(); if(TV ==true){ do{ myGLCD.invertText(true); myGLCD.print("A.Init Tracker", 0, 16); myGLCD.invertText(false);延迟(100); if(OK ==HIGH){ myGLCD.clrScr(); Activated =true; while(Activated ==true){ // Connect to the web application named TV Series / Anime Release Date Tracker. Change '80' with '443' if you are using TheAmplituhedron as the host. if (client.connect(server, 80)) { Serial.println("connected to server"); // if you get a connection, report back via serial:myGLCD.print("Connected to", 0, 8); myGLCD.print("the server!!!", 0, 16); // Make an HTTP request:client.println("GET " + application + " HTTP/1.1"); //client.println("Host:www.theamplituhedron.com"); client.println("Host:192.168.1.22"); client.println("Connection:close"); client.println(); }else{ myGLCD.print("Connection", 0, 8); myGLCD.print("Error!!!", 0, 16); } delay(2000); // Wait 2 seconds after connection... // If there are incoming bytes available, get the response from the web application. String response =""; while (client.available()) { char c =client.read(); response +=c; } if(response !="" &&response.endsWith("%")){ // Split the response string by a pre-defined delimiter in a simple way. '%'(percentage) is defined as the delimiter in this project. int delimiter, delimiter_1, delimiter_2, delimiter_3, delimiter_4; delimiter =response.indexOf("%"); delimiter_1 =response.indexOf("%", delimiter + 1); delimiter_2 =response.indexOf("%", delimiter_1 +1); delimiter_3 =response.indexOf("%", delimiter_2 +1); delimiter_4 =response.indexOf("%", delimiter_3 +1); // Glean information as substrings. String Series_Name =response.substring(delimiter + 1, delimiter_1); String Season =response.substring(delimiter_1 + 1, delimiter_2); String Episode =response.substring(delimiter_2 + 1, delimiter_3); String Episode_Name =response.substring(delimiter_3 + 1, delimiter_4); // Print information. myGLCD.clrScr(); myGLCD.print(Series_Name, 0, 0); myGLCD.print(Season + " x " + Episode, 0, 16); myGLCD.print(Episode_Name, 0, 32); // Play the opening song of the released series / anime until ceased:if(Series_Name =="One Piece") { send_command_to_MP3_player(play_song_1, 6); adjustColor(255,0,0); } if(Series_Name =="My Hero Academia") { send_command_to_MP3_player(play_song_2, 6); adjustColor(0,255,0); } if(Series_Name =="Westworld") { send_command_to_MP3_player(play_song_3, 6); adjustColor(0,0,255); } if(Series_Name =="The Simpsons") { send_command_to_MP3_player(play_song_4, 6); adjustColor(255,255,0); } if(Series_Name =="The Late Late Show") { send_command_to_MP3_player(play_song_5, 6); adjustColor(80,0,80); } // Wait until the Exit button pressed... volatile boolean song =true; while(song ==true){ read_buttons(); if(Exit ==HIGH){ song =false; send_command_to_MP3_player(pause, 4); adjustColor(0,0,0); } } myGLCD.clrScr(); }else{ // Print information. myGLCD.clrScr(); myGLCD.print("No Released", 0, 0); myGLCD.print("Episode", 0, 16); myGLCD.print("Detected :(", 0, 32); delay(5000); // Wait 5 seconds to display information... myGLCD.clrScr(); } // Draw TV icon while counting to the new request... myGLCD.drawBitmap(8, 0, tv, 60, 48); delay(10 * 1000); // Wait until next request... myGLCD.clrScr(); // Exit. read_buttons(); if(Exit ==HIGH){ Activated =false; myGLCD.clrScr(); } } } }while(TV ==false); } if(Music ==true){ do{ myGLCD.invertText(true); myGLCD.print("B.MP3 Player", 0, 24); myGLCD.invertText(false); delay(100); if(OK ==HIGH){ myGLCD.clrScr(); Activated =true; while(Activated ==true){ read_buttons(); // Draw music player icon. myGLCD.drawBitmap(8, 0, music, 60, 48); // MP3 Player:if(Right ==true) send_command_to_MP3_player(next_song, 4); if(Left ==true) send_command_to_MP3_player(previous_song, 4); if(OK ==true) send_command_to_MP3_player(pause, 4); // Exit. if(Exit ==HIGH){ Activated =false; myGLCD.clrScr(); send_command_to_MP3_player(pause, 4); } } } }while(Music ==false); } if(Sleep ==true){ do{ myGLCD.invertText(true); myGLCD.print("C.Sleep", 0, 32); myGLCD.invertText(false);延迟(100); if(OK ==HIGH){ // Activate the sleep mode in 10 seconds. myGLCD.clrScr(); myGLCD.print("Entering", CENTER, 0); myGLCD.print("Sleep Mode", CENTER, 8); myGLCD.print("in", CENTER, 16); myGLCD.print("Seconds", CENTER, 40); // Print remaining seconds. myGLCD.setFont(MediumNumbers); for (int s=10; s>=0; s--){ myGLCD.printNumI(s, CENTER, 24, 2, '0');延迟(1000); } myGLCD.enableSleep(); Activated =true; while(Activated ==true){ // Color Pattern:adjustColor(255,0,0);延迟(500); adjustColor(0,255,0);延迟(500); adjustColor(0,0,255);延迟(500); adjustColor(255,255,0);延迟(500); adjustColor(80,0,80);延迟(500); // Exit. read_buttons(); if(Exit ==HIGH){ Activated =false; myGLCD.clrScr(); myGLCD.disableSleep(); myGLCD.setFont(SmallFont); adjustColor(0,0,0); } } } }while(Sleep ==false); }}void read_buttons(){ // Read the control buttons:Right =digitalRead(B_Right); OK =digitalRead(B_OK); Left =digitalRead(B_Left); Exit =digitalRead(B_Exit);}void send_command_to_MP3_player(int8_t command[], int len){ Serial.print("\nMP3 Command => "); for(int i=0;i 3) selected =1;延迟(100); // Depending on the selected option number, change boolean status. switch(selected){ case 1:TV =true; Music =false; Sleep =false;休息; case 2:TV =false; Music =true; Sleep =false;休息; case 3:TV =false; Music =false; Sleep =true;休息; }}void adjustColor(int red, int green, int blue){ red =255 - red; green =255 - green; blue =255 - blue; analogWrite(redPin, red); analogWrite(greenPin, green); analogWrite(bluePin, blue);}
index.phpPHP
 0) ? true :false;}function createTable($table_name, $conn){ if(!checkDatabase($table_name, $conn)){ $sql ="CREATE TABLE `$table_name`( id int(11) AUTO_INCREMENT PRIMARY KEY NOT NULL, series_name varchar(255) NOT NULL, tv_id varchar(255) NOT NULL, status varchar(255) NOT NULL );"; if(mysqli_query($conn, $sql)){ echo "Database Table Created!"; }else{ echo "Error!"; } }else{ echo "Database Table Found!"; }}createTable("series", $conn_database);?>
query.phpPHP
conn =$conn; $this->table_name =$table_name; } private function check_ep_release_date($API_ID, $series_name, $status){ $date =date("Y-m-d"); $URL =self::ROOT.$API_ID.self::PATH.$date; if($get_content =json_decode(file_get_contents((String)$URL))){ if($status !="Released"){ echo "%".$series_name."%".$get_content[0]->season."%".$get_content[0]->number."%".$get_content[0]->name."%"; $sql ="UPDATE `$this->table_name` SET `status`='Released' WHERE series_name='$series_name'"; mysqli_query($this->conn, $sql); } }else{ if($status !="Pending"){ $sql ="UPDATE `$this->table_name` SET `status`='Pending' WHERE series_name='$series_name'"; mysqli_query($this->conn, $sql); } } } public function track_db_entries(){ $sql ="SELECT * FROM `$this->table_name` ORDER BY `id` DESC"; if($result =mysqli_query($this->conn, $sql)){ $check =mysqli_num_rows($result); if($check> 0){ while($row =mysqli_fetch_assoc($result)){ $this->check_ep_release_date($row['tv_id'], $row['series_name'], $row['status']); } }else{ echo "No Entry Found!"; } }else{ echo "No Database Found!"; } }}// Define the connection settings and the table name.$conn_database =mysqli_connect("localhost", "root", "bot", "tvseries");$table ="series";// Define the object to check release date for each registered series / anime.$q =new query();$q->define_user($conn_database, $table);$q->track_db_entries();?>

定制零件和外壳

gerber_ycEfXzZq6h.zip tv-series-anime-episode-tracker_gCfN0nFiA8.zip opening_songs_y2LCEw79tg.zip tv_Iz2isO8nGI.c music_SA2xR86cZw.c

示意图


制造工艺

  1. Schaffner 推出一系列新的 RFI 过滤器
  2. 在 Eclipse Hono 中发布新的基于 MongoDB 的设备注册表
  3. Raspberry Pi Universal Remote
  4. 一片树莓派
  5. Cycle Chaser
  6. Raspberry Pi Thief Detector
  7. Raspberry Pi 温度传感器
  8. RASPBERRY PI 家庭自动化
  9. 新的 RASPBERRY PI 3 型号 B + 功能和购买
  10. Raspberry Pi CD Box Robot
  11. RaspiRobot Board V2
  12. Rover