Teensy LC mono stereo music instrument/piano

Status
Not open for further replies.

Enotsz

New member
Hi all,

Since I'm currently closed indoors I decided to do something with some circuit components that I currently have at home. I decided to make a basic piano with only pieces that I have at home.

Currently I found a:
- Teensy LC
- ADAFRUIT MONO 2.5W CLASS D AUDIO AMPLIFIER - PAM8302
- Speaker, CMS-16093-078L100, 8 Ohms General Purpose Speaker 700mW 100Hz ~ 20kHz
- Soft tactile buttons
- Breadboard and shunts.

Currently I started to map each button in a script, but now I am stuck has I don't have enough knowledge on how I should connect the amp to the teensy, so coming here for support and help on build this.

Current setup images:
https://imgur.com/a/hbVFx4t

Including here the code that I have so far as requested:
Code:
#include <Bounce.h>

// Digital Pad
Bounce btn_C3     = Bounce( 0, 10);
Bounce btn_Cs3    = Bounce( 1, 10);
Bounce btn_R3     = Bounce( 2, 10);
Bounce btn_Rs3    = Bounce( 3, 10);
Bounce btn_M3     = Bounce( 4, 10);
Bounce btn_F3     = Bounce( 5, 10);
Bounce btn_Fs3    = Bounce( 6, 10);
Bounce btn_G3     = Bounce( 7, 10);
Bounce btn_Gs3    = Bounce( 8, 10);
Bounce btn_A3     = Bounce( 9, 10);
Bounce btn_As3    = Bounce( 10, 10);
Bounce btn_B3     = Bounce( 11, 10);
Bounce btn_C4     = Bounce( 12, 10);
Bounce btn_Cs4    = Bounce( 13, 10);
Bounce btn_R4     = Bounce( 14, 10);
Bounce btn_Rs4    = Bounce( 15, 10);
Bounce btn_M4     = Bounce( 16, 10);
Bounce btn_F4     = Bounce( 17, 10);
Bounce btn_Fs4    = Bounce( 18, 10);

void setup() {
  // put your setup code here, to run once:
  // open the serial port at 9600 bps:
  Serial.begin(9600);

  pinMode( 0, INPUT_PULLUP);  //btn_C3 
  pinMode( 1, INPUT_PULLUP);  //btn_Cs3 
  pinMode( 2, INPUT_PULLUP);  //btn_R3 
  pinMode( 3, INPUT_PULLUP);  //btn_Rs3 
  pinMode( 4, INPUT_PULLUP);  //btn_M3 
  pinMode( 5, INPUT_PULLUP);  //btn_F3 
  pinMode( 6, INPUT_PULLUP);  //btn_Fs3 
  pinMode( 7, INPUT_PULLUP);  //btn_G3 
  pinMode( 8, INPUT_PULLUP);  //btn_Gs3 
  pinMode( 9, INPUT_PULLUP);  //btn_A3 
  pinMode( 10, INPUT_PULLUP);  //btn_As3 
  pinMode( 11, INPUT_PULLUP);  //btn_B3 
  pinMode( 12, INPUT_PULLUP);  //btn_C4 
  pinMode( 13, INPUT_PULLUP);  //btn_Cs4 
  pinMode( 14, INPUT_PULLUP);  //btn_R4 
  pinMode( 15, INPUT_PULLUP);  //btn_Rs4 
  pinMode( 16, INPUT_PULLUP);  //btn_M4 
  pinMode( 17, INPUT_PULLUP);  //btn_F4 
  pinMode( 18, INPUT_PULLUP);  //btn_Fs4 
}

void loop() {
  // put your main code here, to run repeatedly:
  // Update all the buttons
  btn_C3.update();
  btn_Cs3.update();
  btn_R3.update();
  btn_Rs3.update();
  btn_M3.update();
  btn_F3.update();
  btn_Fs3.update();
  btn_G3.update();
  btn_Gs3.update();
  btn_A3.update();
  btn_As3.update();
  btn_B3.update();
  btn_C4.update();
  btn_Cs4.update();
  btn_R4.update();
  btn_Rs4.update();
  btn_M4.update();
  btn_F4.update();
  btn_Fs4.update();

  // Check each button for "falling" edge (= high (not pressed - voltage from pullup resistor))
  if( btn_C3.fallingEdge() ) {
    Serial.print("C3 ");
  }
  if( btn_Cs3.fallingEdge() ) {
    Serial.print("Cs3 ");
  }
  if( btn_R3.fallingEdge() ) {
    Serial.print("R3 ");
  }
  if( btn_Rs3.fallingEdge() ) {
    Serial.print("Rs3 ");
  }
  if( btn_M3.fallingEdge() ) {
    Serial.print("M3 ");
  }
  if( btn_F3.fallingEdge() ) {
    Serial.print("F3 ");
  }
  if( btn_Fs3.fallingEdge() ) {
    Serial.print("Fs3 ");
  }
  if( btn_G3.fallingEdge() ) {
    Serial.print("G3 ");
  }
  if( btn_Gs3.fallingEdge() ) {
    Serial.print("Gs3 ");
  }
  if( btn_A3.fallingEdge() ) {
    Serial.print("A3 ");
  }
  if( btn_As3.fallingEdge() ) {
    Serial.print("As3 ");
  }
  if( btn_B3.fallingEdge() ) {
    Serial.print("B3 ");
  }
  if( btn_C4.fallingEdge() ) {
    Serial.print("C4 ");
  }
  if( btn_Cs4.fallingEdge() ) {
    Serial.print("Cs4 ");
  }
  if( btn_R4.fallingEdge() ) {
    Serial.print("R4 ");
  }
  if( btn_Rs4.fallingEdge() ) {
    Serial.print("Rs4 ");
  }
  if( btn_M4.fallingEdge() ) {
    Serial.print("M4 ");
  }
  if( btn_F4.fallingEdge() ) {
    Serial.print("F4 ");
  }
  if( btn_Fs4.fallingEdge() ) {
    Serial.print("Fs4 ");
  }
}
 
Last edited:
Almost none of the Audio library will compile for the LC. It would be wiser to choose a 3.x or 4.0 if you actually want to synthesize sounds. You'll need to connect analog output from a DAC or codec to the amplifier's input.
 
Almost none of the Audio library will compile for the LC. It would be wiser to choose a 3.x or 4.0 if you actually want to synthesize sounds. You'll need to connect analog output from a DAC or codec to the amplifier's input.

That is a bummer. So there is no way to make a Teensy Lc to synthesize sound even if it just "beeps" in different frequencies, like usage of the "pitches.h" library?
 
It might compile and work correctly, but it's going to make a very poor piano due to lack of multiple voices and/or oscillators, no envelope generator, filter, etc.
 
Status
Not open for further replies.
Back
Top