Dear All,
I am encountering a strange problem with operating a button while using the audio adapter.
I have one button with one end wired to ground and the other to pin 22
I am using teensy 3.2 but I have encountered the problem with two other teensy3.1 boards
(all soldered to the audio adapter of course)
I am using Windows 10 if this might be relevant
my code is :
when I compile this then no sound can be heard but when I comment the line
pinMode(22, INPUT_PULLUP);
I do hear the sinewave as expected. Also : compiling the above code also
causes other strange problems : on occasion I can see the serial output
and sometimes I cannot and the led sometimes shuts off and sometimes stays on.
could anyone explain this ?
Thanks in advance
I am encountering a strange problem with operating a button while using the audio adapter.
I have one button with one end wired to ground and the other to pin 22
I am using teensy 3.2 but I have encountered the problem with two other teensy3.1 boards
(all soldered to the audio adapter of course)
I am using Windows 10 if this might be relevant
my code is :
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include <Bounce.h>
// GUItool: begin automatically generated code
AudioSynthWaveform waveform1; //xy=716,357
AudioOutputI2S i2s1; //xy=1053,362
AudioConnection patchCord1(waveform1, 0, i2s1, 0);
AudioConnection patchCord2(waveform1, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=588,587
// GUItool: end automatically generated code
Bounce button0=Bounce(22,15);
void setup() {
AudioMemory(140);
Serial.begin(9600);
pinMode(22, INPUT_PULLUP);
button0.update();
waveform1.begin(1,220,0);
sgtl5000_1.enable();
sgtl5000_1.volume(.5);
}
void loop() {
button0.update();
if (button0.fallingEdge()) {
Serial.println("Button 0 Press");
}
if (button0.risingEdge()) {
Serial.printf("Button 0 Release");
}
}
when I compile this then no sound can be heard but when I comment the line
pinMode(22, INPUT_PULLUP);
I do hear the sinewave as expected. Also : compiling the above code also
causes other strange problems : on occasion I can see the serial output
and sometimes I cannot and the led sometimes shuts off and sometimes stays on.
could anyone explain this ?
Thanks in advance
Last edited: