MichaelMeissner
Senior Member+
Very nice; that's a great summary of the pinouts. Is that link suitable for long-term reference?
I don't plan on changing the location (but I will from time to time add more microprocessors, etc.).
Very nice; that's a great summary of the pinouts. Is that link suitable for long-term reference?
Awesome! This would be perfect information for the upcoming(?) wiki...I put together the following spreadsheet to keep track of all of the Teensy's and shields. Unfortunately, it is starting to get too big to fit without having to scroll horizontally: https://docs.google.com/spreadsheet...sMG306_FpWdJcniSRR6aGNNYQ/edit#gid=1103027528
#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include <Audio.h>
#include <SerialFlash.h>
// from: https://forum.pjrc.com/threads/33328-Prop-Shield-Beta-Test?p=99236&viewfull=1#post99236
// modified by Michael Meissner
// GUItool: begin automatically generated code
AudioSynthWaveformSine sine1; //xy=180,469
AudioOutputAnalog dac1; //xy=380,468
AudioConnection patchCord1(sine1, dac1);
// GUItool: end automatically generated code
int freq = 1000;
void setup() {
Serial.begin(115200);
while (!Serial)
;
Serial.println("Setting up");
pinMode(5, OUTPUT);
digitalWrite(5, 1); // Enable Amplified.
AudioMemory(12);
sine1.amplitude(1.0);
sine1.frequency(freq);
Serial.println("Send + to increase freq, - to decrease freq, a to turn off amp, A to turn on amp, or num for freq.");
}
void loop()
{
if (Serial.available()) {
int ch = Serial.read();
switch (ch)
{
case '+':
freq += 100;
sine1.frequency(freq);
Serial.print ("New frequency ");
Serial.println (freq);
break;
case '-':
freq -= 100;
sine1.frequency(freq);
Serial.print ("New frequency ");
Serial.println (freq);
break;
case 'a':
digitalWrite (5, 0);
Serial.println ("Amp off");
break;
case 'A':
digitalWrite (5, 1);
Serial.println ("Amp on");
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
{
bool looping = true;
freq = ch - '0';
do
{
if (Serial.available ())
{
ch = Serial.read ();
if (ch >= '0' && ch <= '9')
freq = (freq * 10) + (ch - '0');
else
looping = false;
}
}
while (looping);
}
Serial.print ("New frequency ");
Serial.println (freq);
sine1.frequency(freq);
break;
case ' ':
case '\n':
case '\t':
case '\r':
break;
default:
Serial.print ("Unknown character '");
Serial.print ((char) ch);
Serial.print ("'");
}
}
}
$ for x in SDTEST{1,2,3,4}; do sox $x.WAV --bits 16 --rate 44100 --channels 1 $x.RAW; done
$ teensytransfer -l
$ for x in SDTEST{1,2,3,4}; do teensytransfer -w $x.RAW; done
$ teensytransfer -l
232072 SDTEST1.RAW
382464 SDTEST2.RAW
203676 SDTEST3.RAW
296704 SDTEST4.RAW
// Originally from Teensy release:
// hardware/teensy/avr/libraries/Audio/examples/WavFilePlayer/WavFilePlayer.ino
//
// Simple WAV file player example
//
// Three types of output may be used, by configuring the code below.
//
// 1: Digital I2S - Normally used with the audio shield:
// http://www.pjrc.com/store/teensy3_audio.html
//
// 2: Digital S/PDIF - Connect pin 22 to a S/PDIF transmitter
// https://www.oshpark.com/shared_projects/KcDBKHta
//
// 3: Analog DAC - Connect the DAC pin to an amplified speaker
// http://www.pjrc.com/teensy/gui/?info=AudioOutputAnalog
//
// To configure the output type, first uncomment one of the three
// output objects. If not using the audio shield, comment out
// the sgtl5000_1 lines in setup(), so it does not wait forever
// trying to configure the SGTL5000 codec chip.
//
// The SD card may connect to different pins, depending on the
// hardware you are using. Uncomment or configure the SD card
// pins to match your hardware.
//
// Data files to put on your SD card can be downloaded here:
// http://www.pjrc.com/teensy/td_libs_AudioDataFiles.html
//
// This example code is in the public domain.
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
AudioPlaySerialflashRaw playRaw1;
AudioOutputAnalog audioOutput;
#define PROP_AMP_ENABLE 5
#define FLASH_CHIP_SELECT 6
void setup() {
Serial.begin(9600);
// wait up to 3 seconds for the Serial device to become available
long unsigned debug_start = millis ();
while (!Serial && ((millis () - debug_start) <= 3000))
;
Serial.println ("Start prop shield wav player");
// Enable the amplifier on the prop shield
pinMode(PROP_AMP_ENABLE, OUTPUT);
digitalWrite(PROP_AMP_ENABLE, HIGH);
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(8);
// Start SerialFlash
if (!SerialFlash.begin(FLASH_CHIP_SELECT)) {
while (1)
{
Serial.println ("Cannot access SPI Flash chip");
delay (1000);
}
}
}
void playFile(const char *filename)
{
Serial.print("Playing file: ");
Serial.println(filename);
// Start playing the file. This sketch continues to
// run while the file plays.
playRaw1.play(filename);
// A brief delay for the library read WAV info
delay(5);
// Simply wait for the file to finish playing.
while (playRaw1.isPlaying()) {
// uncomment these lines if you audio shield
// has the optional volume pot soldered
//float vol = analogRead(15);
//vol = vol / 1024;
// sgtl5000_1.volume(vol);
}
}
void loop() {
playFile("SDTEST1.RAW"); // filenames are always uppercase 8.3 format
delay(500);
playFile("SDTEST2.RAW");
delay(500);
playFile("SDTEST3.RAW");
delay(500);
playFile("SDTEST4.RAW");
delay(1500);
}
do you need to define an AudioConnection?
Probably, I'll look at it tonight. As I said, I probably was missing something obvious. I didn't use the audio tool, but instead tried to hack up the WavFilePlayer example.
Start prop shield wav player
Playing file: SDTEST1.RAW
Yes, that's an issue in the old MAC Version. It is solved for Windows and Linux.Question: what is the correct syntax / location to use, as it looks as though I am currently giving the written file a filename that is the whole file path?
Probably, I'll look at it tonight. As I said, I probably was missing something obvious. I didn't use the audio tool, but instead tried to hack up the WavFilePlayer example.
i added AudioConnection patchCord1(playRaw1, audioOutput); ...
I also noticed that on my WIN10 PC the Motion Sensor Calibration Tool does not read the port unless another program has read it first.
It's OK if I remove the line: while (!Serial) ; // wait for serial port open
Crashed on exit
RE Mac, if nobody has this in their sight to compile the Teensytransfer for Mac, I will have a look at it over the weekend.Yes, that's an issue in the old MAC Version. It is solved for Windows and Linux.
Unfortuantely, i can't compile it for MAC.
Here are some explanations:
https://forum.pjrc.com/threads/33859-TeensyTransfer?p=101178#post101178
Paul, I know the LC (witout) prop shield does not have the 3 sensors, but does it still have the pull-up resistors so SDA/SCL can be used for an i2c bus?
Please let me know how it actually works for you in practice?
I'm wondering whether anybody has started making a prop shield version of a light saber? It would seem to be the right size to fit in the general saber handles, and all you would need is a speaker, battery, and appropriate LEDs.
Thank you Paul, I'll report back the results on El Capitan in about 2 hours.