Arduino Brain Machine

I have an old brain machine - a Synetic "Esprit" 'Computerized Relaxation and Mental Fitness System' that still works. It has 12 Presets and a very simple interface 4-button/6-LED project box interface. It uses a sunshades with four small ganged LED's per eye and a pair of stereo headphones (any set works fine). I want to recreate the brain machine shown here, but using my existing 'eyephones' and headphones.

I bought two stereo headphone jacks that fit the eyephone and the head phone plugs.

Eyephones:
This one was confusing enough that I decided to check out the stereo plug on the eyephones to see what works to light up the LED's. It turns out ground has to be in two places at once to light up both arrays when I test the plug directly, but that doesn't make much sense to me. This looks a little like charlieplexing, so should I use a third pin instead of ground? I know both eyes on the eyephones blink sometimes in tandem and sometimes alternately when used with the "Esprit", so that functionality should be surmountable with the arduino. If someone give me a hint or two about how I need to interface this with my pins so the output from pin 12 goes to the right eye only and pin 13 to the left eye only, both at the same time or alternately according to my preferences, I would be grateful.

Headphones:
These work, but not exactly as expected. For this experiment, I'm the ToneTest from the Arduino Tone library exactly as is. I've put one of the stereo jacks on the breadboard. The center pin is ground. The left jack pin goes to arduino pin 12 and the right jack pin goes to arduino pin 9. If I play 'a', I can hear 440 a coming mostly from the right ear. Play 's' to stop. Then play 'A', and I hear it mostly in the left ear. Play 'S' to stop. Then play 'a' and play 'D', and you can hear two tones louder and in both ears. In both instances, I'm hearing bleed-through, where the sound from one speaker can also be heard to some extent on the other speaker. I was hoping I'd be able to get just pin 9 out of the right ear and just pin 12 out of the left ear, without combining. When I remove the wire from the ground pin on the arduino, the sound is equally loud in both ears. I would have thought the sound would have stopped, since the circuit technically has no ground.

How can I make it so the sounds coming out of each pin are truly isolated from the sound coming from the other pin?

These are the things that

Eyephones: Instead of a "common ground" for the LEDs like you'd think, this has a "common source" - so, just use a couple of small NPN transistors (2n2222 would probably work fine), emitter to ground, collector to the pin for the LED set, and put a base resistor on the base (330 ohm would probably be a good start) and control it with an Arduino digital output.

Headphones: This actually sounds like there is a short somewhere - likely while the plug fits the jack, the plug is in some way custom so that both channels are being fed incorrectly (that is, the contacts interior to the jack are making contact incorrectly with the contacts on the plug). Not sure what you can do about this, except to ohm out the plug and jack, to verify the hypothesis, then if that is correct, look for another jack or another pair of headphones (or a matching plug for the jack, then replace the headphone plug).

Also - note that an Arduino shouldn't be used to try to directly drive speakers - that's a good way to blow Arduino pins. Instead, you need to run the Arduino's output into a small amplifier (like an LM386), then run its output to the headphone jack (you'll need one LM386 for each speaker).

:slight_smile:

cr0sh:
Eyephones: Instead of a "common ground" for the LEDs like you'd think, this has a "common source" - so, just use a couple of small NPN transistors (2n2222 would probably work fine), emitter to ground, collector to the pin for the LED set, and put a base resistor on the base (330 ohm would probably be a good start) and control it with an Arduino digital output.

Headphones: This actually sounds like there is a short somewhere - likely while the plug fits the jack, the plug is in some way custom so that both channels are being fed incorrectly (that is, the contacts interior to the jack are making contact incorrectly with the contacts on the plug). Not sure what you can do about this, except to ohm out the plug and jack, to verify the hypothesis, then if that is correct, look for another jack or another pair of headphones (or a matching plug for the jack, then replace the headphone plug).

Also - note that an Arduino shouldn't be used to try to directly drive speakers - that's a good way to blow Arduino pins. Instead, you need to run the Arduino's output into a small amplifier (like an LM386), then run its output to the headphone jack (you'll need one LM386 for each speaker).

:slight_smile:

cr0sh,

Thanks for your reply.

Does the following circuit diagram come close to what you're suggesting for the eyephones?

As to the amplifier, I have a quad opamp. Could I use two subsets of pins from an opamp as easily as using two LM386's?

I've been looking around for "common cathode vs. common anode" information on LED's, and found that there is a much simpler way of approaching the use of my existing eyephones. This post on the adafruit forum was pretty insightful.

To that end, I set up a test sketch thus:

/*********************************************************
Sketch: Eyephone Test
Author: Chris Sparnicht - http://low.li
Date: 2011.01.31
License: Creative Commons 2.5 Attrib. & Share Alike
Description: A test for stereo led eye phones.
Notes:
  Common Anode Blink Test for existing LED Glasses
  Blinks two sets of LED's alternately in loop, using a common anode.
  When pins 5 and 6 are set to LOW, they emit light (on).
  When each pin is set to HIGH the no longer emit light (off).
*********************************************************/
 
 // Some variables:
int intensity[]={255, 127, 63, 31, 15};
int rintensity[]={15, 31, 63, 127, 255};
 
/*********************************************************
Setup defines LED outputs.
*********************************************************/
void setup() {                
  // initialize the digital pin as an output.
  // The LED's anodes :
  pinMode(5, OUTPUT);     // LED's on right side
  pinMode(6, OUTPUT);     // LED's on left side
}

/*********************************************************
Main function - blink the LED's continuously in a loop
*********************************************************/
void loop() {
  for (int i = 0; i < 5; i++) {
  // Two blinks on one side to confirm which pin is right or left. 
  // Do this five times.
  digitalWrite(5, HIGH);   // Common Anode: Turn LED off.
  digitalWrite(6, LOW);    // Common Anode: Turn LED on.
  delay(250);              // wait for a second
  digitalWrite(5, LOW);   // Common Anode: Turn LED off.
  digitalWrite(6, LOW);    // Common Anode: Turn LED on.
  delay(250);              // wait for a second
  digitalWrite(5, HIGH);   // Common Anode: Turn LED off.
  digitalWrite(6, LOW);    // Common Anode: Turn LED on.
  delay(250);              // wait for a second
  digitalWrite(5, LOW);   // Common Anode: Turn LED off.
  digitalWrite(6, LOW);    // Common Anode: Turn LED on.
  delay(250);              // wait for a second
  // Single blink on second in order to verify both sides function.
  digitalWrite(5, LOW);    // Common Anode: Turn LED on.
  digitalWrite(6, HIGH);    // Common Anode: Turn LED off.
  delay(1000);              // wait for a second
  }
  // Now do some PWM to show it works in reverse for PWM too.
  for (int i = 0; i < 5; i++) {
      for (int i = 0; i < 5; i++) { // over the course of a second
        analogWrite(5, intensity[i]); // Right side: dim to bright
        analogWrite(6, 0); // 
        delay(200);
      }
      for (int i = 0; i < 5; i++) { // over the course of a second
        analogWrite(5, 0); // 
        analogWrite(6, rintensity[i]); // Left Side: bright to dim
        delay(200);
      }
  }
}

I set up a double blink for the LED's on the right side just to confirm that the pin I'd specified was on the correct side. The fact that the left side LED's emit light during the double blink on the right side confirms that LOW means "On" and HIGH means "Off" with a common anode situation. Likewise, the analogWrite values are reverse as well. It looks like no transistors are necessary for this part of the programming. I may just need to inverse pin values in the sketch. Cool!

This is how the test is laid out on a bred board:

I can't tell whether I'm learning electronics incidentally to programming or vice versa. Either way, this is excellent fun.

The next thing to tackle is a better method for the earphones.

I went back to Mitch Altman's original code and used that as my base.
This is the result.
There is a short youtube video of the working arduino brain machine there.