Analog pins behaving as if they were a bitwise 'and'

I am working on a quiz buss in system with arduino products and an mp3 player module from sparkfun. I have 4 triggers with pullups on the mp3 triggers. They're on A0-A4. The mp3s don't play. I've simplified my code to get the essence of the problem:

I put my multimeter on it, and the voltage does not drop on those pins for some reason. It seems almost like there's a bitwise "&" on those analog pins. This code will play the first 2 tracks, pause and replay them: void setup() { digitalWrite(A0, HIGH); pinMode(A0, OUTPUT); digitalWrite(A1, HIGH); pinMode(A1, OUTPUT);

} void loop() { digitalWrite(A0, LOW); digitalWrite(A1, LOW); delay(5000); digitalWrite(A0, HIGH); digitalWrite(A1, HIGH); delay(5000); } This code won't play anything: void setup() { digitalWrite(A0, HIGH); pinMode(A0, OUTPUT); digitalWrite(A1, HIGH); pinMode(A1, OUTPUT);

} void loop() { digitalWrite(A0, LOW); delay(5000); digitalWrite(A0, HIGH); delay(5000); } It's as if having a 'high' anywhere in those "A" pins keeps everything high. I'm hoping you'll be able help me out. I'm at my wits' end. Shawn

what is the code you are using exactly, did you paste it twice by mistake ? and read the How To Use The Forum threads - use the CODE tags -->

I have 4 triggers with pullups on the mp3 triggers. They’re on A0-A4.

They are INPUTs then, aren’t they? Why are you setting them to OUTPUT?

Hi, what are you trying to do? Have the arduino control the mp3 player. OR Have the mp3 player control the arduino.

If the first, you need to use the DIGITAL pins of the arduino, they are on the other edge of the board. Also set pinmode BEFORE you write to it.

I'd gather you want to get the arduino to randomly play one of the selections for a set time, and/or as another game play say 5 seconds of each tune for contestants to identify.

Tom.. hope to help,.... :)

PS for all this to work you need to make sure that the gnd of the arduino and gnd of the mp3 player are connected together.

If the first, you need to use the DIGITAL pins of the arduino, they are on the other edge of the board. Also set pinmode BEFORE you write to it.

There is nothing wrong with using the analog pins as digital pins, as OP is doing. If used correctly, which does not appear to be the case.

That code looks to me as if it should correctly toggle the relevant analog pins HIGH and LOW at 5 second intervals.

If you want to confirm it is doing that I suggest you disconnect whatever it is connected to and connect an LED and series current limiting resistor to ground so you can see what the pin is doing. If you don’t have the hardware for that, use a voltmeter instead. (If you don’t have a voltmeter, get one!)

What do you have connected to the analog pins? What are the electrical characteristics (how much current will they supply/sink?), what is the expected behaviour when those lines go high and low, and how is it all connected? If you haven’t got a good ground connection then you will get some wierd behaviour.

If you want to confirm it is doing that I suggest you disconnect whatever it is connected to and connect an LED and series current limiting resistor to ground so you can see what the pin is doing. If you don't have the hardware for that, use a voltmeter instead. (If you don't have a voltmeter, get one!)

One easy trick you can use to utilize an led as a troubleshooting tool is to just utilize the arduino pin 13 led by just adding a jumper wire from pin 13 to whatever output pin you wish to monitor. The default mode for pin 13 is input mode so there will be no electrical conflict with using the pin 13 (built in on standard arduino design) led this way.

Lefty

retronet Thanks. This code plays 2 tracks, pauses, and repeats.

void setup()
{
  digitalWrite(A0, HIGH);
  pinMode(A0, OUTPUT);
  digitalWrite(A1, HIGH);
  pinMode(A1, OUTPUT);
  
 }
void loop()
{
 digitalWrite(A0, LOW);
 digitalWrite(A1, LOW);
  delay(5000);
  digitalWrite(A0, HIGH);
  digitalWrite(A1, HIGH);
 delay(5000); 
}

The following code won't play anything. I put my multimeter on A0, and it does not go low.

void setup()
{
  digitalWrite(A0, HIGH);
  pinMode(A0, OUTPUT);
  digitalWrite(A1, HIGH);
  pinMode(A1, OUTPUT);
  
 }
void loop()
{
 digitalWrite(A0, LOW);
  delay(5000);
  digitalWrite(A0, HIGH);
 delay(5000); 
}

PaulS Whoops, I misspoke. There are internal pullups on the mp3 board. I'm trying to output from the A pins to trigger inputs on the mp3 board. This is the mp3 board I'm using: https://www.sparkfun.com/products/11029

TomGeorge I'm trying to control the mp3 with the arduino. Ground between the two boards is connected. The code I posted above is a distillation of the problem (and is tested and producing the results I mention), but I'm out of pins when I use my full code/project, so I'm using the analog. I see PaulS has addressed this.

PeterH It's connected to an MP3 board (https://www.sparkfun.com/products/11029). I put a multimeter on it, and it is not going low, though I just now realize I put it on the connection without disconnecting the jumper. Probably should have disconnected the jumper to the mp3? I've got pins A0-A4 connected to Trigger1-5 on the mp3. The mp3 has internal pullups. I've got gnd on the mp3 connected to gnd on the arduino. Arduino is getting power from the programmer, and a "serial reader" (don't know the actual term) is connected to the arduio Tx and gnd. Mp3 is getting it's own power from a wall wart. I had a lot more connections for what I'm actually trying to do, but with the setup described still produces the error. Form the mp3 data sheet (http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Widgets/MP3%20Trigger%20V2.5%20User%20Guide%202012-02-01.pdf),

The trigger inputs are active low and pulled high internally. Therefore, they can be activated either by digital outputs from another microcontroller (such as an Arduino) or by a simple contact closure (switch) to ground. The inputs support voltage levels of either 5V or 3.3V.

So I'd expect, when I pull a pin low, that it would trigger the corresponding trigger on the mp3, which plays an mp3 named for the trigger in the first 3 characters of the file name ("001something.mp3"). I've manually jogged the mp3 triggers and they're working. Also, the thing works if I only set one of the analog pins. If I set two pins, nothing plays unless I bring them both low at the same time, in which case both tracks play (the mp3 board queues them up).

Thanks, retrolefty, good tip. I'll keep that in mind.

The following code won't play anything. I put my multimeter on A0, and it does not go low.

Sounds to me like you have a broken output pin. Can you change the pin and see if the new one works?

I’ll give that a try, Grumpy_Mike. I’ve also got an identical board that I can try. Thanks.

TomGeorge: If the first, you need to use the DIGITAL pins of the arduino, they are on the other edge of the board. Also set pinmode BEFORE you write to it.

No, analog pins work perfectly fine as digital pins too.

The reason the OP is setting them high before setting pinMode OUTPUT is to prevent triggering the mp3 board prematurely by a momentary low pulse. This the normal way of driving open-drain style outputs.

Anyway, back to the problem in hand.

These trigger inputs are connected to a 3.3V chip so must never be driven HIGH by the Arduino. The documentation describing them is at odds with the schematic diagram. Its not clear on the schematic how the pull-up is provided (the first chip is a 16x1 analog multiplexer), but the pins will only be pulled up one-at-a-time by the mp3 board so it won't be easy to monitor them!

The correct way to operate them I believe is this:

void triggerWrite (int pin, boolean active)
{
  digitalWrite (pin, LOW) ;
  pinMode (pin, active ? OUTPUT : INPUT) ;
}

Could the schematic is wrong about it being a 3.3V chip? I’m way over my head here, but does this (http://pdf1.alldatasheet.com/datasheet-pdf/view/15615/PHILIPS/74HC4067.html) datasheet show it’s okay to use anywhere from 2 - 10V under “recommended operating conditions” (of course, I could have the wrong datasheet)?

Unless I misunderstand your point about how the pullup is provided, there’s an smt resistor between each trigger and the first chip. I won’t need to monitor the state of the playback, which makes things a bit easier. I just need to send the signal to play the mp3. The software will make sure the delay between triggers is longer than the playtime of all of the mp3s.

Thanks, I’ll try that code. One question, though: is this a normal way of communicating between the Arduino and other stuff (this is only my second microcontroller project)? It seems a little counterintuitive to switch it between output and input pinmodes when it’s an output device.

What is the 74HC4067 doing?
This is the first time you have mentioned this multiplexer chip.
Is it between your arduino and MP3 player?

It's part of the mp3 board (http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Widgets/mp3-trigger-v23.pdf) :)

You can only ever pass voltages to a chip that are at the level of the supply or less. So while the chip can take a much higher voltage supply in the case of that trigger circuit it is only being supplied by 3V3.

Ah, makes perfect sense. Thanks.

glassgiant: Could the schematic is wrong about it being a 3.3V chip? I'm way over my head here, but does this (http://pdf1.alldatasheet.com/datasheet-pdf/view/15615/PHILIPS/74HC4067.html) datasheet show it's okay to use anywhere from 2 - 10V under "recommended operating conditions" (of course, I could have the wrong datasheet)?

I didn't mean its a 3.3V chip, I mean its supply voltage is 3.3V in that module, so its inputs must be limited to the range 0 .. 3.3V

Unless I misunderstand your point about how the pullup is provided, there's an smt resistor between each trigger and the first chip.

Those resistors seem to be some half-baked idea at circuit protection, they are not pull-ups, and at 100 ohms they are not providing enough protection - driving them at 5V will push large currents into the protection diodes of the 4067 causing potential damage or malfunction.

I won't need to monitor the state of the playback, which makes things a bit easier. I just need to send the signal to play the mp3. The software will make sure the delay between triggers is longer than the playtime of all of the mp3s.

Thanks, I'll try that code. One question, though: is this a normal way of communicating between the Arduino and other stuff (this is only my second microcontroller project)? It seems a little counterintuitive to switch it between output and input pinmodes when it's an output device.

An open-drain or open-collector signal is only ever actively driven low, and if not driven low a resistor pulls it high - this means the driver doesn't need to be the same voltage as the receiving circuit if the driver is truly open-drain. Here we mimic open-drain with pinMode, but we cannot allow the output voltage to rise above 5V as a true open-drain driver would. We can drive lower voltage logic quite happily this way for instance a 1.8V logic chip could be interfaced this way so long as you never actively pull to 5V, or as here a 3.3V logic chip.

The I2C bus is an example of a comms bus using open-drain signalling.

MarkT

void triggerWrite (int pin, boolean active)
{
  digitalWrite (pin, LOW) ;
  pinMode (pin, active ? OUTPUT : INPUT) ;
}

Hot diggity, that works! I've been beating my head against this problem for days. Thank-you!

Thanks, everyone, not only for solving the problem, but taking the time to explain why stuff works. I learned a lot over and above the issue I was having.

If you're interested, this is for a quiz buzzer system for a kids' science centre fundraiser. The guy running the technical aspects is burning the candle at both ends, so I agreed to take on this little project, and in exchange for this and other work, the science center is offering meeting space for our Makerspace to put on classes. So you've helped at least two worthy causes.