投幣機+mp3PLAYER
編輯歷史
| 時間 | 作者 | 版本 |
|---|---|---|
| 2015-09-24 06:13 – 06:23 | r89 – r125 | |
顯示 diff 投幣機+mp3PLAYER
-
-
- 程式碼
- 感謝偉大的阿波羅!神說有光,就有光!
- 感謝偉大的蟹老闆!感恩讚嘆!
-
- #include <DFPlayer_Mini_Mp3.h>
- #include <SoftwareSerial.h>
-
- /* pin define */
- #define COIN_INPUT 2 /* the pin to detect coin input */
- #define CUM_RX 8 /* the pin to recv from MiniMp3 */
- #define CUM_TX 9 /* the pin to send to MiniMp3 */
- #define LED_PIN 12 /* the pin to control relay */
-
- /* get coins to launch player */
- #define COIN_MAX 5 /* how many coins will work */
-
- /* setting of */
- #define ORIG_VOL 30 /* init volume */
- #define REDU_VOL 15 /* reduced volume */
- #define REDU_TICK 200 /* reduce volume tick */
- #define REDU_TIME 10000 /* length to reduce volume of music */
- #define ZERO_TIME 180000 /* length to clear counter */
- #define LED_INTERVAL 20000 /* length of music */
-
- /* configure of LED */
- #define LED_ON HIGH /* for relay, set LED on */
- #define LED_OFF LOW /* for relay, set LED off */
-
- /* for check coin signal correct */
- #define PASS_MIN_MS 25 /* the minimal millis that passing the tunnel */
- #define PASS_MAX_MS 110 /* the maximal millis that passing the tunnel */
-
- static unsigned long startTime = 0;
- static unsigned long currTime = 0;
- static unsigned long passStartTime = 0;
- static unsigned long volumeChangeTime = 0;
- static unsigned long passInterval = 0;
- static volatile int counter = 0;
- static volatile boolean coinPassing = false;
- int currVolume = ORIG_VOL;
- int ledStatus = LED_OFF;
-
- SoftwareSerial cumSerial(CUM_RX, CUM_TX);
-
- void setup()
- {
- cumSerial.begin(9600);
- Serial.begin(9600);
- mp3_set_serial(cumSerial);
- mp3_single_loop(false);
- mp3_set_reply(false);
- pinMode(COIN_INPUT, INPUT);
- pinMode(LED_PIN, OUTPUT);
- digitalWrite(LED_PIN, ledStatus);
- currTime = millis();
- attachInterrupt(0, coinStateChange, CHANGE);
- }
+ 程式碼+libs
+ libs需放到arduino資料夾底下
- void loop()
- {
- currTime = millis();
- if (counter && ledStatus == LED_OFF)
- {
- ledStatus = LED_ON;
- digitalWrite(LED_PIN, ledStatus);
- }
- if (counter == COIN_MAX)
- {
- currVolume = ORIG_VOL;
- counter = 0;
- mp3_stop();
- delay(100);
- mp3_set_volume(currVolume);
- delay(100);
- mp3_play(1);
- startTime = currTime;
- volumeChangeTime = startTime + REDU_TIME;
- }
- if (currVolume > REDU_VOL && currTime > volumeChangeTime)
- {
- currVolume--;
- volumeChangeTime += REDU_TICK;
- mp3_set_volume(currVolume);
- }
- if (currTime - startTime > LED_INTERVAL && ledStatus == LED_ON)
- {
- ledStatus = LED_OFF;
- digitalWrite(LED_PIN, ledStatus);
- }
- if (counter && currTime - passStartTime > ZERO_TIME)
- {
- counter = 0;
- }
- }
+ 投入5枚硬幣啟動音樂與LED
+ 音樂開始後10s音量漸弱
+ 30s後再投入第一枚硬幣時音量驟降
+ 第五枚硬幣時重新啟動音樂
+ https://github.com/asilyihong/OpenlabTaipei.CoinCounter
- void coinStateChange()
- {
- currTime = millis();
- coinPassing = !coinPassing;
- if (coinPassing)
- {
- passStartTime = currTime;
- }
- else
- {
- passInterval = currTime - passStartTime;
- if (passInterval > PASS_MIN_MS && passInterval < PASS_MAX_MS)
- {
- counter++;
- }
- }
- }
mp3PLAYER+Arduino
- 需下載libraries至arduino資料夾
+
*
(5 行未修改)
|
||
| 2015-09-18 17:51 – 18:19 | r64 – r88 | |
顯示 diff(3 行未修改)
程式碼
感謝偉大的阿波羅!神說有光,就有光!
+ 感謝偉大的蟹老闆!感恩讚嘆!
#include <DFPlayer_Mini_Mp3.h>
(109 行未修改)
mp3PLAYER+Arduino
+ 需下載libraries至arduino資料夾
*
*
+
+ 成功影片
+ https://instagram.com/p/7xw4_PNpjk/?fb_action_ids=10153191357286375&fb_action_types=instapp%3Atake&fb_ref=ogexp&fb_source=other_multiline&action_object_map=%5B910933742288153%5D&action_type_map=%5B%22instapp%3Atake%22%5D&action_ref_map=%5B%22ogexp%22%5D
|
||
| 2015-09-18 17:51 | r63 | |
顯示 diff(122 行未修改)
|
||
| 2015-09-18 17:50 – 17:51 | r57 – r62 | |
顯示 diff(116 行未修改)
mp3PLAYER+Arduino
+
+ *
*
|
||
| 2015-09-18 17:50 | r56 | |
顯示 diff(120 行未修改)
|
||
| 2015-09-18 17:33 – 17:50 | r3 – r55 | |
顯示 diff- Untitled
+ 投幣機+mp3PLAYER
+
+
+ 程式碼
+ 感謝偉大的阿波羅!神說有光,就有光!
#include <DFPlayer_Mini_Mp3.h>
(107 行未修改)
}
}
+
+ mp3PLAYER+Arduino
+
+ *
|
||
| 2015-09-18 17:33 | r2 | |
顯示 diff(112 行未修改)
|
||
| 2015-09-18 17:33 | r1 | |
顯示 diff Untitled
- This pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!
+ #include <DFPlayer_Mini_Mp3.h>
+ #include <SoftwareSerial.h>
+
+ /* pin define */
+ #define COIN_INPUT 2 /* the pin to detect coin input */
+ #define CUM_RX 8 /* the pin to recv from MiniMp3 */
+ #define CUM_TX 9 /* the pin to send to MiniMp3 */
+ #define LED_PIN 12 /* the pin to control relay */
+
+ /* get coins to launch player */
+ #define COIN_MAX 5 /* how many coins will work */
+
+ /* setting of */
+ #define ORIG_VOL 30 /* init volume */
+ #define REDU_VOL 15 /* reduced volume */
+ #define REDU_TICK 200 /* reduce volume tick */
+ #define REDU_TIME 10000 /* length to reduce volume of music */
+ #define ZERO_TIME 180000 /* length to clear counter */
+ #define LED_INTERVAL 20000 /* length of music */
+
+ /* configure of LED */
+ #define LED_ON HIGH /* for relay, set LED on */
+ #define LED_OFF LOW /* for relay, set LED off */
+
+ /* for check coin signal correct */
+ #define PASS_MIN_MS 25 /* the minimal millis that passing the tunnel */
+ #define PASS_MAX_MS 110 /* the maximal millis that passing the tunnel */
+
+ static unsigned long startTime = 0;
+ static unsigned long currTime = 0;
+ static unsigned long passStartTime = 0;
+ static unsigned long volumeChangeTime = 0;
+ static unsigned long passInterval = 0;
+ static volatile int counter = 0;
+ static volatile boolean coinPassing = false;
+ int currVolume = ORIG_VOL;
+ int ledStatus = LED_OFF;
+
+ SoftwareSerial cumSerial(CUM_RX, CUM_TX);
+
+ void setup()
+ {
+ cumSerial.begin(9600);
+ Serial.begin(9600);
+
+ mp3_set_serial(cumSerial);
+ mp3_single_loop(false);
+ mp3_set_reply(false);
+
+ pinMode(COIN_INPUT, INPUT);
+ pinMode(LED_PIN, OUTPUT);
+ digitalWrite(LED_PIN, ledStatus);
+ currTime = millis();
+ attachInterrupt(0, coinStateChange, CHANGE);
+ }
+
+ void loop()
+ {
+ currTime = millis();
+ if (counter && ledStatus == LED_OFF)
+ {
+ ledStatus = LED_ON;
+ digitalWrite(LED_PIN, ledStatus);
+ }
+ if (counter == COIN_MAX)
+ {
+ currVolume = ORIG_VOL;
+ counter = 0;
+ mp3_stop();
+ delay(100);
+ mp3_set_volume(currVolume);
+ delay(100);
+ mp3_play(1);
+ startTime = currTime;
+ volumeChangeTime = startTime + REDU_TIME;
+ }
+ if (currVolume > REDU_VOL && currTime > volumeChangeTime)
+ {
+ currVolume--;
+ volumeChangeTime += REDU_TICK;
+ mp3_set_volume(currVolume);
+ }
+ if (currTime - startTime > LED_INTERVAL && ledStatus == LED_ON)
+ {
+ ledStatus = LED_OFF;
+ digitalWrite(LED_PIN, ledStatus);
+ }
+ if (counter && currTime - passStartTime > ZERO_TIME)
+ {
+ counter = 0;
+ }
+ }
+
+ void coinStateChange()
+ {
+ currTime = millis();
+ coinPassing = !coinPassing;
+ if (coinPassing)
+ {
+ passStartTime = currTime;
+ }
+ else
+ {
+ passInterval = currTime - passStartTime;
+ if (passInterval > PASS_MIN_MS && passInterval < PASS_MAX_MS)
+ {
+ counter++;
+ }
+ }
+ }
|
||
| 2015-09-18 17:33 | r0 | |
顯示 diff+ Untitled
+ This pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!
|
||