Friday, December 30, 2022

JQ8900-16p MP3 player

So, I'm really pleased with this new (to me) MP3 player that seems like a nice alternative to the DFPlayer. Its manual is sometimes hard to find so I've hosted a copy of the PFD below. First and foremost, it has onboard storage for audio files. Your computer recognizes it as a USB drive, so it's a simple plug-n-play then drag-n-drop. 

To trigger the audio the JQ8900 has a few options:

 (1) There is a two-way serial connection using the Rx and Tx pins. This is the most robust way with many options analogous to the DFPlayer serial connection. Unfortunately, the serial commands are different from the DFPlayer, and I'm not aware of an existing Arduino library. Fortunately, the JQ8900 seems to be based on the JQ8400. The JQ8400 does have an Arduino library, but I have not personally used it. Both the JQ8900 and the JQ8400 have manuals that have been translated into English and have good information. 

With the JQ8900, I'm partial to using the serial commands directly. "AA 06 00 B0" will play the next file. I've included below some example code that will every 5 seconds play the next file in sequence.

(2) There is a single wire input mode available using the VPP pin. I haven't personally used this, but there are many examples online (unfortunately for me, mostly in Chinese)

(3) The JQ8900 has 7 trigger pins. These are great. When the IO1 pin is connected to ground the JQ8900 will play the file named 00001.mp3 (and so on). This works well for manual buttons as well as microcontrollers. With this board, I used an ATTINY85 sending a signal to an NPN transistor to connect IO1 to ground. 

Audio output is either speaker output (appears to be a 3W amplifier) or line level output via DAC and ground. For both outputs, the JQ8900 collapses the right and left channels into a single mono channel. This is a disadvantage as compared to the DFPlayer, which has mono output for the speaker, but stereo ouput for line level. If you need stereo output, the JQ8900 may not be the board for you. 


JQ8900 Manual - English version

JQ8400 Manual - English version

JQ8400 Arduino Library

excellent collection of links [Chinese] The JQ8900-16P voice module hardware usage _ Lin Zhong Qiyuan's blog - CSDN blog _jq8900

//include libraries
#include "Arduino.h"
#include "SoftwareSerial.h"

SoftwareSerial mySoftwareSerial(15, 14); // RX, TX

void setup(){
  pinMode(4, INPUT);

void loop()
  byte playnext[] = {0xAA, 0x06, 0x00, 0xB0 };
  int trig = digitalRead(4);
  if (trig == HIGH) {  
  mySoftwareSerial.write(playnext, sizeof(playnext));

Monday, December 5, 2022


 Previously I worked on a motor controller board that would deliver random pulses to a prop. It worked well, but I was not quite happy with the randomization algorithm, and I wanted more titratable control over the pulses. Additionally I wanted something that could be triggered by either a PIR sensor or a button.  

I’ve now produced a beta version of this new controller and I’m looking for feedback. Here’s a demo video—

This is the schematic—

And here is the code—

//  Jekyll-Labs Twitchy Attiny85
//  Built for Twitchboard v1.5
int fetpin = 0;
int trigpin = 1;
int potMpin = A1;
int potRpin = A2;
int potLpin = A3;
int lambda = 5; // number of event
int timeunit = 60; // in this time interval (sec)
unsigned long last = 0;
unsigned long timeinterval = 0;
float exprob=0;

void setup() {
  pinMode(fetpin, OUTPUT);
  digitalWrite(fetpin, LOW);
  pinMode(trigpin, INPUT);
  pinMode(potLpin, INPUT);
  pinMode(potMpin, INPUT);
  pinMode(potRpin, INPUT);

void loop() {
  // duration of signal will last from 0.5 - 10 sec
  int durationpot = analogRead(potRpin);
  long duration = map(durationpot,100,1023,500,10000); 
  if (duration <500) duration = 150;

  // read middle pot for PWM of fet signal
  int PWMpot = analogRead(potMpin);
  int PWM = map(PWMpot,0,1000,0,255);
  if (PWM>255) PWM = 255;

  // mean frequency of random signals is 5 events per time unit
  int freqpot = analogRead(potLpin);
  int timeunit = map(freqpot,512,1023,60,300); // 2nd half dial range 1-5 min
  if (freqpot>1000) timeunit = 3600; // far right dial 1hr
  if (freqpot<512) timeunit = map(freqpot,0,512,0,60); // 1st half dial range 10-60 sec
  if (freqpot<100) timeunit = 0; // bottom of dial continous on  

  if (timeunit<=0){ // continuous on if left dial all counter clockwise
  else {
    // Check for trigger (X3 for debounce) and adjust
    // timeunit if trigger is positive.
    if (timeunit>0) {
      int trigger = digitalRead(trigpin);  
      if (trigger == HIGH) {
        int trigger = digitalRead(trigpin);
        if (trigger == HIGH) {
          delay (100);
          int trigger = digitalRead(trigpin);
          if (trigger == HIGH) {
            timeunit = (duration * 10)/1000;
    // Calcuate time interval between events. timeunit depends on:
    // Potentiometer value if trig = 0 
    // Duration multiplier (shorter) if trig = 1
    unsigned long timeinterval = exprob * timeunit * 1000;    
    // Check if time interval has passed
    if ((millis() - last) > timeinterval) {
      last = millis(); // updates timer to last event
      // the following equation runs once per event and 
      // generates a random float (exprob) that falls in an 
      // exponential distribution. It will be used to
      // determine the interval time for the next event.
      // Events that occur at exponentially distributed  
      // intervals form poisson processes.
      exprob =  (-1)*(log((100-random(100))/100.00)/lambda);
    else digitalWrite(fetpin,LOW);