산업 제조
산업용 사물 인터넷 | 산업자재 | 장비 유지 보수 및 수리 | 산업 프로그래밍 |
home  MfgRobots >> 산업 제조 >  >> Manufacturing Technology >> 제조공정

TV 시리즈/애니 새 에피소드 출시일 알림

구성품 및 소모품

JLCPCB 맞춤형 PCB
× 1
Arduino Nano 33 IoT
× 1
라즈베리 파이 3 모델 B
라즈베리 파이 3 또는 라즈베리 파이 4
× 1
라즈베리 파이 4 모델 B
라즈베리 파이 3 또는 라즈베리 파이 4
× 1
SparkFun Nokia 5110 화면
× 1
OPEN-SMART의 직렬 MP3 플레이어
× 1
RGB 확산 공통 양극
× 1
플래시 메모리 카드, SD 카드
× 2
저항 220옴
× 12
푸시버튼 스위치 6x6x5
× 4
TaydaElectronics DC 전원 잭 2.1MM 배럴형 PCB 마운트
× 1

필요한 도구 및 기계

납땜 인두(일반)
뜨거운 글루건(일반)

앱 및 온라인 서비스

Arduino IDE
KiCad
메모장++

이 프로젝트 정보

설명

좋아하는 프로그램의 출시 날짜를 추적할 수 있는 웹 및 모바일 응용 프로그램이 무수히 많지만 목록에 있는 시리즈 또는 애니메이션의 새 에피소드가 처음부터 하드웨어 및 소프트웨어에서 출시될 때 알려주는 장치를 만들고 싶었습니다. 다양한 기능.

먼저, 웹 애플리케이션인 TV 시리즈/애니 출시 날짜 추적기를 PHP로 만들어 시리즈/애니 목록을 만들고 출시 날짜에 대한 정보를 수집했습니다. 그런 면에서 저는 복잡하고 잡다한 코딩 단계 없이 애플리케이션이 출시 날짜별로 에피소드 정보를 정확하게 얻을 수 있도록 해주는 TVMAZE REST API를 활용했습니다. 그런 다음 Raspberry Pi에 LAMP(w/ MariaDB) 서버를 설정하여 애플리케이션을 실행합니다. 그러나 Raspberry Pi가 없거나 호스트로 사용하고 싶지 않은 사람들을 위해 내 웹 사이트에 사용자 친화적인 인터페이스가 있는 무료 버전의 응용 프로그램을 게시했습니다. 또한 아래에서 애플리케이션의 소스 코드를 찾을 수 있습니다.

웹 애플리케이션으로 정보 전달을 완료한 후 새로운 에피소드가 출시되면 애플리케이션에서 생성된 데이터를 대조하기 위해 Arduino Nano 33 IoT를 개발 보드로 사용하기로 결정했습니다. 구분 기호를 사용하여 애플리케이션에서 전송한 응답을 정렬한 방법에 대한 자세한 정보는 아래에서 확인할 수 있습니다. 그리고 Nano 33 IoT에서 구현한 기능과 모드를 관리하기 위해 Nokia 5110 화면과 푸시버튼으로 사용자 인터페이스(메뉴)를 디자인했습니다.

마지막으로, 내 목록에 있는 쇼의 새 에피소드가 오프닝 곡과 함께 출시될 때 정보를 얻기 위해 사용하기 쉬운 UART 명령 목록으로 인해 직렬 MP3 플레이어 모듈(OPEN-SMART)을 사용했습니다. 또한 MP3 플레이어 모드를 추가하여 모든 오프닝 곡을 재생할 수 있게 해주므로 장치가 내 방에 대한 흥미로운 액세서리로 바뀌었습니다 :)

브레드보드에서 디자인을 완료하고 코드를 테스트한 후 독특한 복고풍 전화기 모양의 PCB(TV 시리즈 / Anime Release Date Notifier)를 디자인하여 완전히 새롭고 사용하기 쉬운 장치를 만들었습니다.

이 프로젝트를 후원해 주신 JLCPCB에 큰 감사를 드립니다.

1단계:TV 시리즈/애니 출시일 알림 PCB 설계 및 납땜

KiCad를 사용하여 TV 시리즈 / 애니메이션 출시일 알림 PCB를 설계했습니다. 아래에 PCB의 Gerber 파일을 첨부했으므로 원하는 경우 JLCPCB에서 이 PCB를 주문하여 이 프로젝트를 복제하여 좋아하는 프로그램의 새 에피소드가 출시될 때 알림을 받을 수 있습니다. :)

먼저 납땜인두를 이용하여 헤더, 푸시버튼, 220Ω 저항, 전원잭, 5mm Anode RGB LED를 부착했습니다.

PCB의 구성 요소 목록:

A1(Arduino Nano 33 IoT용 헤더)

J1(직렬 MP3 플레이어용 헤더)

J2(DS3231용 헤더 - 필수 사항 아님)

J3(Nokia 5110 화면용 헤더)

J4(전원 잭)

D1(5mm 양극 RGB LED)

K1, K2, K3, K4(푸시버튼)

R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12(220Ω 저항기)

2단계:Raspberry Pi에서 MariaDB로 LAMP 웹 서버 설정

Raspberry Pi로 프로그래밍하는 초보자라면 공식 Raspberry Pi 웹사이트에서 잘 설명된 지침과 자습서를 확인할 수 있습니다.

공식 Raspberry Pi 설정 자습서로 이동하려면 여기를 클릭하십시오.

<울>
  • 메뉴에서 액세서리> 터미널을 선택하여 터미널 창을 엽니다.
  • 터미널에 다음 명령을 입력하고 Enter 키를 눌러 apache2 패키지를 설치합니다.
  • sudo apt-get install apache2 -y

    <울>
  • 서버를 테스트하려면 메뉴에서 인터넷> Chromium 웹 브라우저를 선택하여 Chromium을 열고 http://localhost를 입력합니다.
  • 원하는 경우 Raspberry Pi의 IP 주소도 사용할 수 있습니다.
  • 호스트 이름 -I

    <울>
  • 다음 명령을 사용하여 PHP 패키지를 설치합니다.
  • Pi 업데이트를 잊지 마세요.
  • sudo apt-get 업데이트

    sudo apt-get install php -y

    <울>
  • 터미널 창에 다음 명령을 입력하여 MySQL 서버(MariaDB) 및 PHP-MySQL 패키지를 설치합니다.
  • sudo apt-get 설치 mariadb-server php-mysql -y

    <울>
  • 새 사용자를 생성하려면 터미널 창에서 MySQL 보안 설치 명령을 실행하세요.
  • sudo mysql_secure_installation

    <울>
  • 루트의 현재 비밀번호를 입력하라는 메시지가 표시됩니다(없음의 경우 입력): — Enter 키를 누릅니다.
  • Y를 입력하고 Enter 키를 눌러 루트 비밀번호 설정 .
  • 입력 새 비밀번호: 프롬프트를 표시하고 Enter 키를 누릅니다.
  • Y를 입력하여 익명 사용자 제거 .
  • Y를 입력하여 원격으로 루트 로그인을 허용하지 않음 .
  • Y를 입력하여 테스트 데이터베이스를 제거하고 액세스합니다. .
  • Y를 입력하여 지금 권한 테이블을 새로고침 .
  • 완료되면 다음 메시지가 표시됩니다. 모두 완료되었습니다! MariaDB를 사용해 주셔서 감사합니다!
  • <울>
  • TVMAZE REST API에 의해 생성된 변수를 저장할 데이터베이스(tvseries)를 생성하려면 터미널 창에서 다음 MySQL 명령을 실행하십시오.
  • sudo mysql -uroot -p

    <울>
  • 루트 비밀번호 입력 -
  • MariaDB 모니터에 오신 것을 환영합니다 메시지가 표시됩니다. .
  • MariaDB [(none)]> 뒤에 있는 아래 줄을 따르십시오. :tvseries 생성 프롬프트 MariaDB의 데이터베이스:
  • 데이터베이스 TV 시리즈 생성

    tvseries에 대한 모든 권한 부여.* 'bot'으로 식별되는 'root'@'localhost'에

    플러시 특권;

    <울>
  • Ctrl + D를 눌러 MariaDB 프롬프트를 종료합니다.
  • <울>
  • file_get_contents()를 사용하여 TVMAZE REST API에서 데이터를 얻으려면 PHP에서 함수를 사용하려면 php-curl 패키지를 설치하세요.
  • sudo apt-get php-curl 설치

    <울>
  • 그런 다음 localhost에 설치된 패키지를 사용할 수 있도록 Apache 서버를 다시 시작합니다.
  • sudo 서비스 apache2 재시작

    3단계:좋아하는 시리즈/애니메이션의 TVMAZE REST API에서 정보 얻기

    TVMAZE는 사용자가 이름, 날짜, 에피소드 번호 등으로 프로그램을 검색할 수 있는 사용하기 쉬운 무료 REST API를 제공합니다. 사용 가능한 끝점 및 쿼리를 검사할 수 있습니다.

    TVMAZE REST API로 이동합니다.

    Episode by Date를 사용했습니다. 특정 날짜에 방송된 특정 프로그램의 모든 에피소드를 검색하는 옵션입니다.

    출시일별 정보를 얻으려면 TVMAZE에서 좋아하는 프로그램을 검색하고 해당 링크에 표시된 TV ID를 사용해야 합니다.

    <울>
  • URL:/shows/:id/episodesbydate?date=:date
  • 날짜:ISO 8601 형식
  • 예:http://api.tvmaze.com/shows/1/episodesbydate?date=2013-07-01
  • 지정된 날짜에 방송된 에피소드가 있는 경우 API는 전체 에피소드 정보의 배열을 반환합니다.

    그렇지 않으면 API가 HTTP 404를 반환합니다.

    아래에서 내가 만든 가장 좋아하는 시리즈/애니 목록을 살펴보고 내 프로젝트와 함께 출시되는 새 에피소드가 있는지 추적할 수 있습니다.

    일일 쇼이기 때문에 내 코드를 테스트하기 위해 Late Late Show를 추가했습니다.

    1) 원피스

    TV ID:1505

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

    2) 나의 히어로 아카데미아

    TV ID:13615

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

    3) 웨스트월드

    TV ID:1371

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

    4) 심슨 가족

    TV ID:83

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

    5) James Corden의 레이트 레이트 쇼

    TV ID:2831

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

    4단계:PHP의 Raspberry Pi에서 실행되는 TV 시리즈/애니메이션 출시 날짜 추적기(애플리케이션) 개발 및 데이터 삽입을 위한 시리즈 테이블 생성

    저는 TV 시리즈/애니메이션 출시일 추적기를 PHP로 개발했으며 관심 있는 분들을 위해 아래 코드 설명 섹션에서 애플리케이션의 소스 코드를 설명했습니다.

    그러나 PHP를 사용한 웹 개발을 좋아하지 않는다면 다운로드에서 TV-Series-Anime-Episode-Tracker.zip이라는 애플리케이션을 다운로드하고 PHP 코딩에 뛰어들지 않고도 Raspberry Pi에 업로드할 수 있습니다.

    업로드 :

    다음 단계에 따라 로컬 호스트에 TV 시리즈/애니 출시 날짜 추적기를 설치하십시오.

    <울>
  • 응용 프로그램 다운로드 - TV-Series-Anime-Episode-Tracker.zip - index.php 및 query.php 파일 포함
  • <울>
  • TV-Series-Anime-Episode-Tracker.zip 압축을 풉니다.
  • <울>
  • apache 서버는 보호된 위치이므로 터미널을 사용하여 Downloads에서 응용 프로그램 폴더(TV-Series-Anime-Episode-Tracker)를 서버(/var/www/html)로 이동합니다.
  • sudo mv /home/pi/Downloads/TV-Series-Anime-Episode-Tracker/ /var/www/html/

    <울>
  • TV 시리즈/애니 출시 날짜 추적기로 이동:
  • http://localhost/TV-Series-Anime-Episode-Tracker/

    기능 :

    1) 설치 후 애플리케이션을 열어 데이터베이스(tvseries)에 시리즈라는 테이블을 생성합니다. index.php 파일을 처음 열면 애플리케이션이 자동으로 series라는 테이블을 생성하고 사용자에게 알립니다. - Database Table Created!

    2) 데이터베이스 테이블(시리즈)이 데이터베이스에 성공적으로 생성되면 애플리케이션이 사용자에게 알립니다. - Database Table Found!

    3) 데이터베이스 테이블(시리즈)을 생성한 후 목록의 각 프로그램에 대해 TVMAZE REST API에 필요한 변수를 삽입하려면 다음 단계를 수행하십시오.

    <울>
  • 터미널 창에서 다음 MySQL 명령 실행:
  • sudo mysql -uroot -p

    <울>
  • 루트 비밀번호 입력 -
  • TV 시리즈 선택 데이터베이스:
  • TV 시리즈 사용

    <울>
  • 필요한 변수(시리즈 이름, TV ID, 상태)를 각 프로그램의 테이블에 삽입합니다. 상태 변수는 지정된 날짜에 새 에피소드가 출시될 때 반복 없이 사용자에게 알리기 위해 애플리케이션에서 사용됩니다.
  • INSERT INTO `series`(`series_name`, `tv_id`, `status`) VALUES('원피스', '1505', '보류 중');

    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) 그렇지 않으면 애플리케이션은 No Entry Found!를 인쇄합니다.

    코드 설명 :

    1) index.php

    <울>
  • 데이터베이스 연결 설정("localhost", "root", "bot", "tvseries")을 정의합니다.
  • checkDatabase() 함수, 주어진 이름 - 시리즈에 데이터베이스 테이블이 있는지 감지합니다.
  • createTable() 함수, 데이터베이스에서 찾을 수 없는 경우 시리즈 테이블을 만들고 사용자에게 알립니다.
  • 2) query.php

    <울>
  • 쿼리에서 클래스에서 TVMAZE API에 대한 경로를 정의하여 요청합니다.
  • define_user() 함수, 연결 설정 및 테이블 이름을 가져옵니다.
  • check_ep_release_date() 함수, file_get_contents() 사용 기능을 사용하여 현재 날짜에 지정된 TV ID에 대해 새 에피소드가 출시되는지 여부를 감지합니다. 재발을 방지하기 위해 새 에피소드가 출시되는 경우 데이터베이스의 상태 변수를 보류 중에서 출시됨으로 변경합니다.
  • track_db_entries() 함수, check_ep_release_date() 실행 데이터베이스 테이블에 등록된 각 쇼에 대해 - 시리즈.
  • 4.1단계:Raspberry Pi 없이 웹 애플리케이션 실행

    내 웹사이트(TheAmplituhedron) 구독자를 위해 Raspberry Pi가 없거나 이 프로젝트의 호스트로 사용하려는 사람들을 위해 무료 버전의 TV 시리즈/애니 출시 날짜 추적기를 개발했습니다.

    데이터베이스 관리를 위한 사용자 친화적인 인터페이스를 제공합니다. 데이터를 삽입하기 위해 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 라이브러리를 다운로드하십시오.

    Nokia 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) 레이트 레이트 쇼 - 오프닝 | 들어봐

    원하는 경우 압축 폴더(opening_songs.zip)에 내 재생 목록을 다운로드할 수 있습니다.

    올바른 기능을 트리거하는 데 필요한 UART 명령을 알고 있는 한 Arduino Nano 33 IoT와 함께 직렬 MP3 플레이어를 사용하는 것은 어렵지 않습니다. OPEN-SMART의 스피커와 함께 직렬 MP3 플레이어 모듈을 사용했습니다. 따라서 브랜드 이름이 다른 직렬 MP3 플레이어가 있는 경우 아래에 표시된 명령이 작동하지 않습니다.

    지침의 지침을 따르십시오:

    "이 모듈은 고품질 MP3 오디오 칩을 기반으로 하는 일종의 간단한 MP3 플레이어 장치입니다. 8kHz ~ 48kHz 샘플링 주파수 MP3 및 WAV 파일 형식을 지원할 수 있습니다. 보드에 TF 카드 소켓이 있습니다. , 그래서 당신은 오디오 파일을 저장하는 마이크로 SD 카드를 연결할 수 있습니다.MCU는 노래 전환, 볼륨 및 재생 모드 변경 등과 같은 UART 포트를 통해 모듈에 명령을 보내 MP3 재생 상태를 제어할 수 있습니다. UART 모듈에 USB를 통해 모듈을 디버그합니다. Arduino/AVR/ARM/PIC와 호환됩니다."

    "마이크로 SD 카드가 FAT16 또는 FAT32로 포맷되어 있고 그 안에 노래가 있는지 확인하십시오. "01" 및 "02" 폴더를 만들고 001xxx.mp3 / 002xxx.mp3라는 이름의 노래를 넣어야 합니다. / 003xxx.mp3."

    즉 001One Piece-Opening.mp3, 002My Hero Academia-Opening.mp3 등의 곡명에 연속적인 숫자를 추가하여 명령어를 정확하게 실행하려면 '01'이라는 폴더에 곡을 저장해야 합니다.

    Arduino Nano 33 IoT를 사용하여 직렬 MP3 플레이어에 UART 명령을 보내기 위해 send_command_to_MP3_player라는 함수를 만들었습니다. . 요청된 명령의 각 바이트를 RX0 및 TX1 핀의 두 번째 직렬 포트(직렬1)를 통해 직렬 MP3 플레이어로 전송합니다. - 요청된 명령의 길이에 따라 - 4, 5 또는 6.

    아래와 같이 Serial MP3 Player로 보내고자 하는 명령어를 바이트로 구분 - 0x7e. 모든 명령은 '7E'로 시작하고 'EF'로 끝납니다. 두 번째 바이트는 '02', '03', '04' 사이의 바이트 수입니다. 아래에서 OPEN-SMART의 Serial MP3 Player 설명서를 다운로드하여 모든 명령을 검사하고 자세한 지침을 얻으십시오.

    // 필요한 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 및 비밀번호를 정의합니다.
  • 라즈베리 파이의 IP 주소를 입력합니다.
  • Raspberry Pi에서 애플리케이션(query.php)의 경로를 정의합니다.
  • 이더넷 클라이언트 라이브러리를 초기화합니다.
  • Nokia 5110 화면 설정을 정의합니다.
  • TV 및 음악과 같은 관련 화면 모드에 대한 그래픽을 정의합니다.
  • 다른 그래픽(흑백 이미지)을 만들려면 흑백 이미지 변환기로 이동하십시오.
  • 필요한 MP3 플레이어 명령을 정의합니다.
  • 휘발성 부울을 사용하여 메뉴 옵션 및 모드를 정의합니다.
  • 제어 버튼과 RGB LED 핀을 정의합니다.
  • 두 번째 직렬 포트 - Serial1에서 직렬 MP3 플레이어 모듈에 대한 직렬 통신 시작 .
  • WiFi 네트워크에 연결합니다.
  • 시리얼 모니터와 Nokia 5110 화면 모두에서 연결을 확인합니다.
  • read_buttons() 기능, 제어 버튼(오른쪽, 확인, 왼쪽 및 종료)에서 데이터를 가져옵니다.
  • change_menu_options() , 오른쪽 및 왼쪽 버튼을 사용하여 옵션 번호를 늘리거나 줄입니다.
  • 인터페이스()에서 기능, 인터페이스(메뉴)를 인쇄합니다.
  • 초기화 추적기 모드가 선택되면 TV Series / Anime Release Date Tracker라는 웹 애플리케이션에 연결합니다.
  • 사용 가능한 수신 바이트가 있으면 웹 애플리케이션에서 응답을 받습니다.
  • endsWith() 사용 함수에서 응답에 백분율 기호(구분자)가 있는지 여부를 감지합니다.
  • 포함된 경우 간단한 방법으로 미리 정의된 구분 기호로 응답 문자열을 분할합니다. '%'(백분율) 이 프로젝트의 구분 기호로 정의됩니다.
  • 하위 문자열로 정보 수집 - Series_Name, Season, Episode, Episode_Name.
  • 정보를 인쇄하고 출시된 시리즈/애니메이션의 오프닝 곡을 중단될 때까지 재생합니다.
  • 종료 버튼을 누를 때까지 기다립니다.
  • 빈 응답이 있는 경우 발견된 에피소드 없음 :(을 인쇄하십시오.
  • 새 요청을 세면서 TV 아이콘을 그립니다.
  • 다음 요청까지 기다리세요.
  • MP3 플레이어 모드 선택한 경우 음악 플레이어 아이콘을 그립니다. 제어 버튼(오른쪽, 왼쪽, 확인)으로 MP3 플레이어를 제어합니다.
  • 절전 모드 가 선택되면 10초 후에 절전 모드를 활성화하고 남은 초를 인쇄합니다.
  • Connections and Adjustments

    // 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 :)

    <섹션 클래스="섹션 컨테이너 섹션 축소 가능" id="코드">

    코드

    <울>
  • 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); while (true); } // 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); delay(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); delay(500); adjustColor(0,255,0); delay(500); adjustColor(0,0,255); delay(500); adjustColor(255,255,0); delay(500); adjustColor(80,0,80); delay(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. Raspberry Pi 범용 리모컨
    2. 라즈베리 파이 한 조각
    3. 사이클 체이서
    4. 라즈베리 파이 도둑 탐지기
    5. 라즈베리 파이 온도 센서
    6. RASPBERRY PI 홈 자동화
    7. 새로운 RASPBERRY PI 3 모델 B + 기능 및 구매
    8. 라즈베리 파이 CD 상자 로봇
    9. RaspiRobot 보드 V2
    10. Rover