Hackster is hosting Hackster Holidays, Ep. 4: Livestream & Giveaway Drawing. Start streaming on Wednesday!Stream Hackster Holidays, Ep. 4 on Wednesday!
kot_behemot53
Published © CC BY-NC-SA

Bluetooth Volume Control For An Old Stereo With Buttons!

How about getting rid of that broken volume knob on your stereo and replacing it with some buttons, LEDs and Bluetooth?

IntermediateFull instructions provided3,042
Bluetooth Volume Control For An Old Stereo With Buttons!

Things used in this project

Hardware components

ATtiny85
Microchip ATtiny85
×1
DIP-8 socket
Optional - for easy removal of the Attiny
×1
HC-06 Bluetooth Module
Or similar, eg. HC-05, HM-10
×1
LED (generic)
LED (generic)
might be substituted by resistors if somebody doesn't want the BLING
×2
Tactile Switch, Top Actuated
Tactile Switch, Top Actuated
preferably larger ones, easy to press - these will be our volume control buttons
×2
Resistor 100 ohm
Resistor 100 ohm
Or similar
×1
Resistor 1k ohm
Resistor 1k ohm
Or similar - in the schematics there's a 1.2k ohm resistor
×1
Resistor 2.21k ohm
Resistor 2.21k ohm
Or similar
×1
Resistor 100k ohm
Resistor 100k ohm
Or similar
×1
Capacitor 100 nF
Capacitor 100 nF
×1
2x2 Female Header Connector
For connecting the board to the stereo (square shapes helps fit it in the encoder hole)
×1
Male/Male Jumper Wires
For connecting the board to the stereo
×4
Universal PCB
about 4x6 cm (or a custom made one, based on the schematics attached)
×1
Arduino UNO
Arduino UNO
Or another Arduino board, or an AVR programmer - for programming the Attiny
×1
Breadboard (generic)
Breadboard (generic)
And some more jumper wires - for prototyping
×1

Software apps and online services

Arduino IDE
Arduino IDE
Or any other editor. The code should work with PlatformIO after minor modifications (linking Arduino library and converting to C)

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, 40/60
Solder Wire, 40/60
Solder Flux, Soldering
Solder Flux, Soldering
Desoldering Pump, Metal
Desoldering Pump, Metal
Optional, but useful

Story

Read more

Schematics

A simple variant of the volume control (without LEDs and Bluetooth)

Connect it to your stereo system's volume encoder A and B signals and 5V line + GND

A full variant of the volume control (with LEDs and Bluetooth)

Connect it to your stereo system's volume encoder A and B signals and 5V line + GND

Code

Volume control program for the Attiny

Arduino
A program that simulates the rotary encoder by sending appropriate volume up and down signal cycles and communicates with a Bluetooth module to receive "volume up" and "volume down" messages from it.
//THIS IS FOR ATTINY85 ONLY!
#include <SoftwareSerial.h>  //Software Serial Port

//vol cntrl pins
#define VOL_A 0
#define VOL_B 1

//buttons pin
#define BTNS A1

//bluetooth pins
#define RxD 3
#define TxD 4

//bluetooth connection
SoftwareSerial blueToothSerial(RxD,TxD);

//signal segment timing (ms)
#define SIGNAL_DELAY 80

//it takes ~64 cycles to take the volume from min to max

void setup() {
  //init buttons
  pinMode(BTNS, INPUT);
  
  //init volume outputs
  pinMode(VOL_A, OUTPUT);
  pinMode(VOL_B, OUTPUT);
  digitalWrite(VOL_A, HIGH);
  digitalWrite(VOL_B, HIGH);

  //init BT
  pinMode(RxD, INPUT);
  pinMode(TxD, OUTPUT);
  setupBlueToothConnection();
}

void loop() {
  //read buttons state & send appropriate signals to the stereo
  int btnState = analogRead(BTNS);
  if(btnState < 300) {
    volDown();
  } else {
    if(btnState < 700) {
      volUp();
    }
  }

  //read remote commands over BT & send appropriate signals to the stereo
  char recvChar;
  while (blueToothSerial.available() > 0 ) {
    recvChar = blueToothSerial.read();
    if (recvChar == '1') {
      volUp();
    } else {
      if (recvChar == '2') {
        volDown();
      }
    }
  }
}

void volDown()
{
  digitalWrite(VOL_B, LOW);
  delay(SIGNAL_DELAY);
  digitalWrite(VOL_B, HIGH);
  digitalWrite(VOL_A, LOW);
  delay(SIGNAL_DELAY);
  digitalWrite(VOL_A, HIGH);
  delay(SIGNAL_DELAY);
}

void volUp()
{
  digitalWrite(VOL_A, LOW);
  delay(SIGNAL_DELAY);
  digitalWrite(VOL_A, HIGH);
  digitalWrite(VOL_B, LOW);
  delay(SIGNAL_DELAY);
  digitalWrite(VOL_B, HIGH);
  delay(SIGNAL_DELAY);
}
 
void setupBlueToothConnection()
{
  blueToothSerial.begin(9600); //using the default baud rate of HC-06
  blueToothSerial.print("AT+NAMEdupa1"); //set the name - in fact it would be enough to do it just once, also a reset is needed after the change

  delay(2000); //a delay just to make sure that the setup is completed
  blueToothSerial.flush();
}

Credits

kot_behemot53

kot_behemot53

0 projects • 2 followers

Comments