반응형

DFPlayer Mini MP3 Player For Arduino를 이용해 아두이노로 MP3 파일을 재생할 수 있다.


마이크로 SD 카드보다 약간 크다.


DFPlayer Mini Pin Map


Pin Description


배터리, 스피커, 푸시버튼을 연결해 아두이노 없이도 사용할 수 있다.


Specifications

  • supported sampling rates (kHz): 8/11.025/12/16/22.05/24/32/44.1/48

  • 24 -bit DAC output, support for dynamic range 90dB, SNR support 85dB

  • fully supports FAT16, FAT32 file system, maximum support 32G of the TF card, support 32G of U disk, 64M bytes NORFLASH

  • a variety of control modes, I/O control mode, serial mode, AD button control mode

  • advertising sound waiting function, the music can be suspended. when advertising is over in the music continue to play

  • audio data sorted by folder supports up to 100 folders, every folder can hold up to 255 songs

  • 30 level adjustable volume, 6 -level EQ adjustable


위 다이어그램과 같이 연결한다. MP3 파일 재생시 노이즈가 심하다면 RX에 1KΩ 저항을 연결한다.



아두이노IDE - Library manager에서 DFRobotDFPlayerMini를 검색하고 설치한다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/***************************************************
DFPlayer - A Mini MP3 Player For Arduino
 <https://www.dfrobot.com/product-1121.html>
 
 ***************************************************
 This example shows the basic function of library for DFPlayer.
 
 Created 2016-12-07
 By [Angelo qiao](Angelo.qiao@dfrobot.com)
 
 GNU Lesser General Public License.
 See <http://www.gnu.org/licenses/> for details.
 All above must be included in any redistribution
 ****************************************************/
 
/***********Notice and Trouble shooting***************
 1.Connection and Diagram can be found here
 <https://www.dfrobot.com/wiki/index.php/DFPlayer_Mini_SKU:DFR0299#Connection_Diagram>
 2.This code is tested on Arduino Uno, Leonardo, Mega boards.
 ****************************************************/
 
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
 
SoftwareSerial mySoftwareSerial(1011); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);
 
void setup()
{
  mySoftwareSerial.begin(9600);
  Serial.begin(115200);
  
  Serial.println();
  Serial.println(F("DFRobot DFPlayer Mini Demo"));
  Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
  
  if (!myDFPlayer.begin(mySoftwareSerial)) {  //Use softwareSerial to communicate with mp3.
    Serial.println(F("Unable to begin:"));
    Serial.println(F("1.Please recheck the connection!"));
    Serial.println(F("2.Please insert the SD card!"));
    while(true){
      delay(0); // Code to compatible with ESP8266 watch dog.
    }
  }
  Serial.println(F("DFPlayer Mini online."));
  
  myDFPlayer.volume(20);  //Set volume value. From 0 to 30
  myDFPlayer.play(1);  //Play the first mp3
}
 
void loop()
{
  static unsigned long timer = millis();
  
  if (millis() - timer > 30000) {
    timer = millis();
    myDFPlayer.next();  //Play next mp3 every 30 second.
  }
  
  if (myDFPlayer.available()) {
    printDetail(myDFPlayer.readType(), myDFPlayer.read()); //Print the detail message from DFPlayer to handle different errors and states.
  }
}
 
void printDetail(uint8_t type, int value){
  switch (type) {
    case TimeOut:
      Serial.println(F("Time Out!"));
      break;
    case WrongStack:
      Serial.println(F("Stack Wrong!"));
      break;
    case DFPlayerCardInserted:
      Serial.println(F("Card Inserted!"));
      break;
    case DFPlayerCardRemoved:
      Serial.println(F("Card Removed!"));
      break;
    case DFPlayerCardOnline:
      Serial.println(F("Card Online!"));
      break;
    case DFPlayerUSBInserted:
      Serial.println("USB Inserted!");
      break;
    case DFPlayerUSBRemoved:
      Serial.println("USB Removed!");
      break;
    case DFPlayerPlayFinished:
      Serial.print(F("Number:"));
      Serial.print(value);
      Serial.println(F(" Play Finished!"));
      break;
    case DFPlayerError:
      Serial.print(F("DFPlayerError:"));
      switch (value) {
        case Busy:
          Serial.println(F("Card not found"));
          break;
        case Sleeping:
          Serial.println(F("Sleeping"));
          break;
        case SerialWrongStack:
          Serial.println(F("Get Wrong Stack"));
          break;
        case CheckSumNotMatch:
          Serial.println(F("Check Sum Not Match"));
          break;
        case FileIndexOut:
          Serial.println(F("File Index Out of Bound"));
          break;
        case FileMismatch:
          Serial.println(F("Cannot Find File"));
          break;
        case Advertise:
          Serial.println(F("In Advertise"));
          break;
        default:
          break;
      }
      break;
    default:
      break;
  }
  
}


위 소스를 컴파일하고 업로드하면 모든 노래가 30초씩 플레이된다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
bool begin(Stream& stream, bool isACK = truebool doReset = true);
bool waitAvailable(unsigned long duration = 0);
bool available();
uint8_t readType();
uint16_t read();
void setTimeOut(unsigned long timeOutDuration);
void next();
void previous();
void play(int fileNumber=1);
void volumeUp();
void volumeDown();
void volume(uint8_t volume);
void EQ(uint8_t eq);
void loop(int fileNumber);
void outputDevice(uint8_t device);
void sleep();
void reset();
void start();
void pause();
void playFolder(uint8_t folderNumber, uint8_t fileNumber);
void outputSetting(bool enable, uint8_t gain);
void enableLoopAll();
void disableLoopAll();
void playMp3Folder(int fileNumber);
void advertise(int fileNumber);
void playLargeFolder(uint8_t folderNumber, uint16_t fileNumber);
void stopAdvertise();
void stop();
void loopFolder(int folderNumber);
void randomAll();
void enableLoop();
void disableLoop();
void enableDAC();
void disableDAC();
int readState();
int readVolume();
int readEQ();
int readFileCounts(uint8_t device);
int readCurrentFileNumber(uint8_t device);
int readFileCountsInFolder(int folderNumber);
int readFileCounts();
int readFolderCounts();
int readCurrentFileNumber();


그 외 다른 기능은 DFRobotDFPlayerMini.h를 참고한다.


※ 제작사 홈페이지를 보면 아래와 같은 문구가 있다.


NOTE: The order you copy the mp3 into micro SD card will affect the order mp3 played, which means play(1) function will play the first mp3 copied into micro SD card.


파일명을 0001.mp3, 0002.mp3... 이런식으로 변경해서 SD카드에 넣어도 play(1) 함수 실행 시 0001.mp3가 아닌, 제일 먼저 복사된 파일이 첫 번째로 재생되는거 같다.


반응형
Posted by J-sean
:
반응형

평소 별 필요 없지만 언젠가는 유용하게 쓰일 수 도 있는 제품, 소형 전동 드라이버다. 데스크탑 컴퓨터 조립 시 사용하는 약간 큰 제품도 있지만 샤오미 와우스틱은 별, 삼각형등 특별한 모양의 비트가 포함되어 있기 때문에 노트북이나 핸드폰등 소형 기기 분해, 조립 시 유용하게 사용 할 수 있다.


일반 전동 드라이버


알리에서 구매한 샤오미 전동 드라이버. 전용 파우치와 함께 도착 했다.

가격은 $15.57.


한글 빼고 다 있다.


전동 드라이버와 비트 세트가 각각 포장 되어 있다.



깔끔하게 포장 되어 있다.


Specification

 Material

 Aluminum Alloy

 Battery

 2 x AAA 1.5V

 Speed

 150r/min

 Torque

 0.12/3N.m

Bit Size

(4x28mm)

PH000/ PH0/ PH2

SL1.0/ SL2.0/ SL3.0

T5/ T6/ T8 

P2/ P5/ P6 

H2.5/ H3 

SQ0/ 3.0/ Y2.5/ U3.0

 Weight

 Apprex. 240g


드라이버의 뒷부분을 열고 건전지를 넣는다.


앞부분엔 비트를 넣는다. 드라이버 바디에 있는 검정색 스위치의 아래를 누르면 시계방향으로, 위를 누르면 반시계 방향으로 회전 한다.



스펙에는 18pcs라고 적혀 있었지만 20개의 비트가 들어 있다.



비트를 장착 완료.


이렇게 전용 파우치에 보관 한다.


비트가 작기 때문에 크고 단단히 잠겨 있는 나사를 풀거나 조이기는 어렵지만 소형기기 분해, 조립시 사용하기에 충분한 힘을 낸다.


반응형
Posted by J-sean
:
반응형

인터넷에서 진동 모터를 찾으면 수많은 제품들이 검색된다. 그 중 가장 흔하게 볼 수 있는 미니 진동 모터 세 종류를 알리 익스프레스에서 구매해 비교해 보았다.


미니 진동 모터



왼쪽부터...

■ Encapsulated Vibration Motor $0.58/ea

1.5~3VDC

RPM: 8000~24000

Torque: 0.3~3gf·cm

https://www.aliexpress.com/item/4000370300735.html?spm=2114.13010708.0.0.65c14c4dU5Eald


■ ERM(Eccentric Rotating Mass) Vibration Motor $0.32/ea

1.5~5VDC

1.5V - 80mA

2V - 110mA

3V - 180mA(suggested)

5V - 320mA

https://www.aliexpress.com/item/33026259454.html?spm=2114.13010708.0.0.65c14c4dU5Eald


■ Coin Vibration Motor $0.27/ea

2.5~4VDC

RPM: 12000±2500

https://www.aliexpress.com/item/32839179602.html?spm=2114.13010708.0.0.65c14c4dU5Eald



비교 테스트는 영상으로 확인하자.


반응형
Posted by J-sean
: