・使用部品
1
|
|
2
|
|
1
|
|
1
|
|
5
|
|
1
|
|
2
|
・回路図
・ケースのデザイン
各パーツの個別のデザインは、以下のURLとなっています。
Front:https://tinkercad.com/things/2pqQ1itYLj3
1
|
|
2
|
|
1
|
|
1
|
|
5
|
|
1
|
|
2
|
モード
|
IN1
|
IN2
|
IN3
|
IN4
|
|
モーターA
|
正転
|
H/PWM
|
L
|
||
逆転
|
L
|
H/PWM
|
|||
スタンバイ
|
L
|
L
|
|||
ブレーキ
|
H
|
H
|
|||
モーターB
|
正転
|
H/PWM
|
L
|
||
逆転
|
L
|
H/PWM
|
|||
スタンバイ
|
L
|
L
|
|||
ブレーキ
|
H
|
H
|
1
|
|
カメラモジュール
|
1
|
1
|
|
1
|
|
1
|
|
1
|
|
10kΩ抵抗
|
1
|
1列ピンソケット4P
|
1
|
ミンティアドライハードのケース
|
1
|
#define CONTROL 4 | |
#define SW 3 | |
#define STILL 100 | |
#define VIDEO 500 | |
int key=-1; | |
int oldkey=-1; | |
unsigned int pcount; | |
unsigned int wait=20000; | |
int get_key() { | |
pcount = 0; | |
if(digitalRead(SW)==LOW) { | |
delay(50); | |
while(digitalRead(SW)==LOW){ | |
pcount++; | |
} | |
if(pcount > wait) { | |
return 1; | |
} else { | |
return 0; | |
} | |
} | |
return -1; | |
} | |
void setup() { | |
pinMode(SW, INPUT_PULLUP); | |
pinMode(CONTROL, OUTPUT); | |
delay(100); | |
digitalWrite(CONTROL,HIGH); | |
} | |
void loop() { | |
int key = get_key(); | |
if (key != oldkey) { | |
oldkey = key; | |
if (key >=0) { | |
switch(key) | |
{ | |
case 0:digitalWrite(CONTROL,LOW); | |
delay(STILL); | |
digitalWrite(CONTROL,HIGH); | |
break; | |
case 1:digitalWrite(CONTROL,LOW); | |
delay(VIDEO); | |
digitalWrite(CONTROL,HIGH); | |
break; | |
} | |
} | |
} | |
delay(100); | |
} |
1
|
|
1
|
|
1
|
|
1
|
|
1
|
|
抵抗20kΩ
|
1
|
M2タッピングネジ
|
2
|
<!DOCTYPE HTML> | |
<html lang="ja"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>MP3 TEST</title> | |
<script src="https://cdn.socket.io/socket.io-1.4.5.js"></script> | |
</head> | |
<body> | |
<script> | |
var socket = io(); | |
function play() { | |
socket.emit('msg', 'play'); | |
} | |
function pause() { | |
socket.emit('msg', 'pause'); | |
} | |
function resume() { | |
socket.emit('msg', 'resume'); | |
} | |
function prev() { | |
socket.emit('msg', 'prev'); | |
} | |
function next() { | |
socket.emit('msg', 'next'); | |
} | |
function up() { | |
socket.emit('msg', 'up'); | |
} | |
function down() { | |
socket.emit('msg', 'down'); | |
} | |
function loop() { | |
socket.emit('msg', 'loop'); | |
} | |
function seteq() { | |
socket.emit('msg', 'eq'); | |
} | |
function repon() { | |
socket.emit('msg', 'repon'); | |
} | |
function repoff() { | |
socket.emit('msg', 'repoff'); | |
} | |
</script> | |
<form> | |
<input type="button" value="PLAY" onclick="play()"/> | |
<input type="button" value="PAUSE" onclick="pause()"/> | |
<input type="button" value="RESUME" onclick="resume()"/> | |
<input type="button" value="<<" onclick="prev()"/> | |
<input type="button" value=">>" onclick="next()"/> | |
<input type="button" value="Vol Down" onclick="down()"/> | |
<input type="button" value="Vol Up" onclick="up()"/> | |
<input type="button" value="LOOP" onclick="loop()"/> | |
<input type="button" value="EQ" onclick="seteq()"/> | |
<input type="button" value="REP ON" onclick="repon()"/> | |
<input type="button" value="REP OFF" onclick="repoff()"/> | |
</form> | |
</body> | |
</html> |
var serialport = require('serialport'); | |
var port = new serialport.SerialPort( | |
'COM6', { | |
baudrate: 9600, | |
parser: serialport.parsers.readline('\r\n') | |
} | |
); | |
var html = require('fs').readFileSync('index.html'); | |
var http = require('http').createServer(function(req, res) { | |
res.writeHead(200, { | |
'Content-Type': 'text/html' | |
}); | |
res.end(html); | |
}); | |
var io = require('socket.io')(http); | |
http.listen(3000); | |
var eqmode = 0; | |
port.on('open', function () { | |
SelectPlayerDevice(0x02); | |
SetVolume(1); | |
SetEQ(0); | |
io.on('connection', function(socket) { | |
socket.on('msg', function(data) { | |
console.log(data); | |
if(data == "play"){ | |
SpecifyMusicPlay(1); | |
} | |
if(data == "pause"){ | |
PlayPause(); | |
} | |
if(data == "resume"){ | |
PlayResume(); | |
} | |
if(data == "prev"){ | |
PlayPrevious(); | |
} | |
if(data == "next"){ | |
PlayNext(); | |
} | |
if(data == "loop"){ | |
PlayLoop(); | |
} | |
if(data == "down"){ | |
DecreaseVolume(); | |
} | |
if(data == "up"){ | |
IncreaseVolume(); | |
} | |
if(data == "repon"){ | |
StartRepeat(); | |
} | |
if(data == "repoff"){ | |
StopRepeat(); | |
} | |
if(data == "eq"){ | |
eqmode ++; | |
if (eqmode > 5) eqmode = 0; | |
SetEQ(eqmode); | |
} | |
}); | |
}); | |
}); | |
function SelectPlayerDevice(device) { | |
var buf = new Buffer([0x7E,0xFF,0x06,0x09,0x00,0,device,0xEF]); | |
setTimeout(port.write(buf),100); | |
} | |
function SpecifyMusicPlay(index) { | |
var hbyte = parseInt(index / 256); | |
var lbyte = parseInt(index % 256); | |
var buf = new Buffer([0x7E,0xFF,0x06,0x03,0x00,hbyte,lbyte,0xEF]); | |
setTimeout(port.write(buf),1000); | |
} | |
function PlayPause() { | |
var buf = new Buffer([0x7E,0xFF,0x06,0x0E,0x00,0x00,0x00,0xEF]); | |
setTimeout(port.write(buf),1000); | |
} | |
function PlayResume() { | |
var buf = new Buffer([0x7E,0xFF,0x06,0x0D,0x00,0x00,0x00,0xEF]); | |
setTimeout(port.write(buf),1000); | |
} | |
function PlayNext() { | |
var buf = new Buffer([0x7E,0xFF,0x06,0x01,0x00,0x00,0x00,0xEF]); | |
setTimeout(port.write(buf),1000); | |
} | |
function PlayPrevious() { | |
var buf = new Buffer([0x7E,0xFF,0x06,0x02,0x00,0x00,0x00,0xEF]); | |
setTimeout(port.write(buf),1000); | |
} | |
function PlayLoop() { | |
var buf = new Buffer([0x7E,0xFF,0x06,0x11,0x00,0x00,0x01,0xEF]); | |
setTimeout(port.write(buf),1000); | |
} | |
function SetVolume(volume) { | |
var buf = new Buffer([0x7E,0xFF,0x06,0x06,0x00,0x00,volume,0xEF]); | |
setTimeout(port.write(buf),1000); | |
} | |
function IncreaseVolume() { | |
var buf = new Buffer([0x7E,0xFF,0x06,0x04,0x00,0x00,0x00,0xEF]); | |
setTimeout(port.write(buf),1000); | |
} | |
function DecreaseVolume() { | |
var buf = new Buffer([0x7E,0xFF,0x06,0x05,0x00,0x00,0x00,0xEF]); | |
setTimeout(port.write(buf),1000); | |
} | |
function StartRepeat() { | |
var buf = new Buffer([0x7E,0xFF,0x06,0x19,0x00,0x00,0x00,0xFE,0xE2,0xEF]); | |
setTimeout(port.write(buf),1000); | |
} | |
function StopRepeat() { | |
var buf = new Buffer([0x7E,0xFF,0x06,0x19,0x00,0x00,0x01,0xFE,0xE1,0xEF]); | |
setTimeout(port.write(buf),1000); | |
} | |
function SetEQ(mode) { | |
var buf = new Buffer([0x7E,0xFF,0x06,0x07,0x00,0x00,mode,0xEF]); | |
setTimeout(port.write(buf),1000); | |
} |
#include <SoftwareSerial.h> | |
#define ARDUINO_RX 8 //should connect to TX of the Serial MP3 Player module | |
#define ARDUINO_TX 9 //connect to RX of the module | |
SoftwareSerial mp3(ARDUINO_RX, ARDUINO_TX); | |
unsigned char playmode = 1; | |
#define PLAY 1 | |
#define PAUSE 0 | |
unsigned char repmode = 1; | |
#define REP_ON 1 | |
#define REP_OFF 0 | |
static int8_t Send_buf[8] = {0}; | |
unsigned int count=12000; | |
int key=-1; | |
int oldkey=-1; | |
#define DOWN_BTN 4 | |
#define CENTER_BTN 2 | |
#define UP_BTN 5 | |
#define LED 13 | |
#define REP_LED 10 | |
/************Command byte**************************/ | |
#define CMD_NEXT_SONG 0X01 | |
#define CMD_PREV_SONG 0X02 | |
#define CMD_PLAY_W_INDEX 0X03 | |
#define CMD_VOLUME_UP 0X04 | |
#define CMD_VOLUME_DOWN 0X05 | |
#define CMD_SET_VOLUME 0X06 | |
#define CMD_SINGLE_CYCLE_PLAY 0X08 | |
#define CMD_SEL_DEV 0X09 | |
#define DEV_TF 0X02 | |
#define CMD_SLEEP_MODE 0X0A | |
#define CMD_WAKE_UP 0X0B | |
#define CMD_RESET 0X0C | |
#define CMD_PLAY 0X0D | |
#define CMD_PAUSE 0X0E | |
#define CMD_PLAY_FOLDER_FILE 0X0F | |
#define CMD_STOP_PLAY 0X16 | |
#define CMD_FOLDER_CYCLE 0X17 | |
#define CMD_SET_SINGLE_CYCLE 0X19 | |
#define SINGLE_CYCLE_ON 0X00 | |
#define SINGLE_CYCLE_OFF 0X01 | |
#define CMD_SET_DAC 0X1A | |
#define DAC_ON 0X00 | |
#define DAC_OFF 0X01 | |
#define CMD_PLAY_W_VOL 0X22 | |
void sendCommand(int8_t command, int16_t dat) | |
{ | |
delay(20); | |
Send_buf[0] = 0x7e; // | |
Send_buf[1] = 0xff; // | |
Send_buf[2] = 0x06; // | |
Send_buf[3] = command; // | |
Send_buf[4] = 0x00;// | |
Send_buf[5] = (int8_t)(dat >> 8);//datah | |
Send_buf[6] = (int8_t)(dat); //datal | |
Send_buf[7] = 0xef; // | |
for(uint8_t i=0; i<8; i++)// | |
{ | |
mp3.write(Send_buf[i]) ; | |
} | |
} | |
int get_key() { | |
unsigned int pcount = 0; | |
bool wait = 0; | |
if(digitalRead(DOWN_BTN)==LOW) { | |
delay(50); | |
while(digitalRead(DOWN_BTN)==LOW){ | |
pcount++; | |
if(pcount > count){ | |
wait = 1; | |
digitalWrite(LED,HIGH); | |
} | |
} | |
if(wait == 1) { | |
return 0; | |
} else return 2; | |
} | |
if(digitalRead(CENTER_BTN)==LOW) { | |
delay(50); | |
while(digitalRead(CENTER_BTN)==LOW){ | |
pcount++; | |
if(pcount > count){ | |
wait = 1; | |
digitalWrite(LED,HIGH); | |
} | |
} | |
if(wait == 1) { | |
return 5; | |
} else return 4; | |
} | |
if(digitalRead(UP_BTN)==LOW) { | |
delay(50); | |
while(digitalRead(UP_BTN)==LOW){ | |
pcount++; | |
if(pcount > count){ | |
wait = 1; | |
digitalWrite(LED,HIGH); | |
} | |
} | |
if(wait == 1) { | |
return 1; | |
} else return 3; | |
} | |
return -1; | |
} | |
void setup() { | |
mp3.begin(9600); | |
Serial.begin(9600); | |
pinMode(DOWN_BTN, INPUT_PULLUP); | |
pinMode(CENTER_BTN, INPUT_PULLUP); | |
pinMode(UP_BTN, INPUT_PULLUP); | |
pinMode(LED, OUTPUT); | |
pinMode(REP_LED, OUTPUT); | |
delay(500); | |
sendCommand(CMD_SEL_DEV, DEV_TF); // Select SD card as the player device. | |
delay(200); | |
sendCommand(CMD_PLAY_W_VOL, 0X0F01); // Set the volume(0x0F) and play first song | |
} | |
void loop() { | |
delay(100); | |
digitalWrite(LED,LOW); | |
int key = get_key(); | |
Serial.println(key); | |
if (key != oldkey) { | |
oldkey = key; | |
if (key >=0) { | |
switch(key) | |
{ | |
case 0:Serial.println("Prev"); | |
sendCommand(CMD_PREV_SONG, 0); | |
digitalWrite(REP_LED,LOW); | |
break; | |
case 1:Serial.println("Next"); | |
sendCommand(CMD_NEXT_SONG, 0); | |
digitalWrite(REP_LED,LOW); | |
break; | |
case 2:Serial.println("Vol Down"); | |
sendCommand(CMD_VOLUME_DOWN, 0); | |
break; | |
case 3:Serial.println("Vol Up"); | |
sendCommand(CMD_VOLUME_UP, 0); | |
break; | |
case 4:if(playmode == PLAY){ | |
playmode = PAUSE; | |
sendCommand(CMD_PAUSE,0); | |
Serial.println("Pause"); | |
} else { | |
playmode = PLAY; | |
sendCommand(CMD_PLAY,0); | |
Serial.println("Play"); | |
} | |
break; | |
case 5:if(repmode == REP_ON){ | |
repmode = REP_OFF; | |
sendCommand(CMD_SET_SINGLE_CYCLE, SINGLE_CYCLE_OFF); | |
Serial.println("Repert off"); | |
digitalWrite(REP_LED,LOW); | |
} else { | |
repmode = REP_ON; | |
digitalWrite(REP_LED,HIGH); | |
sendCommand(CMD_SET_SINGLE_CYCLE, SINGLE_CYCLE_ON); | |
Serial.println("Repert on"); | |
} | |
break; | |
} | |
} | |
} | |
} |
1
|
|
1
|
|
1
|
|
1
|
|
1
|
|
1
|
|
3
|
|
1
|
|
1
|
|
2
|
|
1
|
|
1
|
|
20kΩ半固定抵抗、または20kΩ抵抗
|
1
|
電解コンデンサ4.7μF
|
2
|
ミンティアブリーズケース
|
1
|
#include <Arduino.h> | |
#include <Wire.h> | |
#include <radio.h> | |
#include <RDA5807M.h> | |
#include <Adafruit_SSD1306.h> | |
#include <EEPROM.h> | |
#define OLED_RESET 4 | |
Adafruit_SSD1306 display(OLED_RESET); | |
#define DOWN_BTN 4 | |
#define CENTER_BTN 5 | |
#define UP_BTN 6 | |
#define LED 13 | |
#define STATION_ADDRESS 0 | |
// ----- Fixed settings here. ----- | |
#define FIX_BAND RADIO_BAND_FMWORLD ///< The band that will be tuned by this sketch is FM. | |
#define FIX_STATION 8180 ///< The station that will be tuned by this sketch is 81.80 MHz. | |
#define FIX_VOLUME 4 ///< The volume that will be set by this sketch is level 4. | |
RDA5807M radio; // Create an instance of Class for RDA5807M Chip | |
int key=-1; | |
int oldkey=-1; | |
unsigned int count=20000; | |
int get_key() { | |
unsigned int pcount = 0; | |
bool wait = 0; | |
if(digitalRead(DOWN_BTN)==LOW) { | |
delay(50); | |
while(digitalRead(DOWN_BTN)==LOW){ | |
pcount++; | |
if(pcount > count){ | |
wait = 1; | |
digitalWrite(LED,HIGH); | |
} | |
} | |
if(wait == 1) { | |
return 0; | |
} else return 2; | |
} | |
if(digitalRead(CENTER_BTN)==LOW) { | |
delay(50); | |
while(digitalRead(CENTER_BTN)==LOW){ | |
pcount++; | |
if(pcount > count*5){ | |
wait = 1; | |
digitalWrite(LED,HIGH); | |
} | |
} | |
if(wait == 1) { | |
return 5; | |
} else return 4; | |
} | |
if(digitalRead(UP_BTN)==LOW) { | |
delay(50); | |
while(digitalRead(UP_BTN)==LOW){ | |
pcount++; | |
if(pcount > count){ | |
wait = 1; | |
digitalWrite(LED,HIGH); | |
} | |
} | |
if(wait == 1) { | |
return 1; | |
} else return 3; | |
} | |
return -1; | |
} | |
void setFrequency(){ | |
uint16_t currentFreq; | |
EEPROM.get(STATION_ADDRESS, currentFreq); | |
if(currentFreq > radio.getMinFrequency() && currentFreq < radio.getMaxFrequency()){ | |
radio.setFrequency(currentFreq); | |
} else { | |
radio.setFrequency(FIX_STATION); | |
} | |
} | |
/// Setup a FM only radio configuration | |
/// with some debugging on the Serial port | |
void setup() { | |
pinMode(4, INPUT_PULLUP); | |
pinMode(5, INPUT_PULLUP); | |
pinMode(6, INPUT_PULLUP); | |
pinMode(13, OUTPUT); | |
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!) | |
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64) | |
// init done | |
delay(2000); | |
// Clear the buffer. | |
display.clearDisplay(); | |
// open the Serial port | |
Serial.begin(57600); | |
//Serial.println("Radio..."); | |
delay(200); | |
// Initialize the Radio | |
radio.init(); | |
// Enable information to the Serial port | |
//radio.debugEnable(); | |
// Set all radio setting to the fixed values. | |
radio.setBand(FIX_BAND); | |
setFrequency(); | |
//radio.setBandFrequency(FIX_BAND, FIX_STATION); | |
radio.setVolume(FIX_VOLUME); | |
radio.setMono(false); | |
radio.setMute(false); | |
} // setup | |
/// show the current chip data every 3 seconds. | |
void loop() { | |
char s[12]; | |
radio.formatFrequency(s, sizeof(s)); | |
display.clearDisplay(); | |
display.setTextSize(2); | |
display.setTextColor(WHITE); | |
display.setCursor(0,0); | |
display.println(s); | |
display.setCursor(12,16); | |
display.print("Vol:"); | |
display.setCursor(64,16); | |
display.println(radio.getVolume()); | |
display.display(); | |
digitalWrite(LED,LOW); | |
int key = get_key(); | |
if (key != oldkey) { | |
oldkey = key; | |
if (key >=0) { | |
int v; | |
switch(key) | |
{ | |
case 0:radio.seekDown(true); | |
break; | |
case 1:radio.seekUp(true); | |
break; | |
case 2:v = radio.getVolume(); | |
if (v > 0) radio.setVolume(--v); | |
break; | |
case 3: v = radio.getVolume(); | |
if (v < 15) radio.setVolume(++v); | |
break; | |
case 4:setFrequency(); | |
break; | |
case 5:EEPROM.put(STATION_ADDRESS, radio.getFrequency()); | |
break; | |
} | |
} | |
} | |
delay(100); | |
} // loop |