Program Behaves Differently on Pro-Mini, vs. Standard Uno 3 Board

I am running the "AnalogButtons" example program.

Runs fine, as expected, on a Uno 3 board.

When I run the same program on a Pro-Mini board (5V 16mHz), the serial monitor keeps repeating the serial.print statements (when button is pressed.)

Anyone know what's causing this?

Is it something to do with my Pro-Mini bootloader code maybe? A serial handshake issue?

Thanks for reading,
Mike

Where did you get the AnalogButtons example program? I don't find any sketch by that name in my built in examples. Did it come with a library? If so, which library?

If it's just an example you found online then please post it here using code tags(</> button on the toolbar).

``/*
AnalogButtons,

created 02 Jan 2009 V 0.1

Connect more than one button to a single analog pin,
register a call-back function.which gets called when a button
is pressed or held down for the defined number of seconds. Includes
software key debouncing which may need to be adjusted, the the second
argument to AnalogButtons class. Define the ANALOG_PIN in the constructor
of AnalogButtons.

The circuit:

  • 5 buttons, 1 side of all buttons connected together to +5V.
    The other side of each button is connected via a different value
    resister (tested with) 1k, 2k5, 5k8, 10k, 18k to one side of a
    100k resister which is in turn connected to GND. At the point
    where all the different resisters are joined you make a connection
    to your analog input. Basicly a different voltage divider is setup
    depending upon which button is pressed. You have to configure the
    Buttons Hi/Low values, see the comments in example code below and the
    AnalogButtons::configure(ANALOG_PIN) function.

More or less than 5 buttons could be added, just pick different values
of the resister sot hat all buttons have different values which arn't too
close in size.

I'm not sure what happens when Arduino is powered from batteries and Power V
drops below V5.

by Neil DUdman and everyone who's ever used Arduino

*/
#include "AnalogButtons.h"

#define ANALOG_PIN 0

// A call back function that you pass into the constructor of AnalogButtons, see example
// below. Alternitivly you could extend the Button class and re-define the methods pressed()
// or held() which are called
void handleButtons(int id, boolean held)
{
if (held) {
Serial.print("button id="); Serial.print(id); Serial.println(" was pressed and held");
} else{
Serial.print("button id="); Serial.print(id); Serial.println(" was pressed only");
}
}

AnalogButtons analogButtons(ANALOG_PIN, 30, &handleButtons);
Button b1 = Button(1, 1012,1021);
Button b2 = Button(2, 973, 983);
Button b3 = Button(3, 926, 936);
//Button b4 = Button(4, 929, 933);
// Default hold duration is 1 second, lets make it 5 seconds for button5
//Button b5 = Button(5, 860, 875, 5);

void setup()
{
Serial.begin(57600);
Serial.println("Testing your Analog buttons");

analogButtons.addButton(b1);
analogButtons.addButton(b2);
analogButtons.addButton(b3);
//analogButtons.addButton(b4);
//analogButtons.addButton(b5);
}

void loop()
{
// To check values when button are pressed
analogButtons.checkButtons();

// To configure the MAX/Min values for each
// Button, uncomment this line, make sure you've called Serial.begin(9600);
// Then in turn hold town each botton, noting the max/min values
//AnalogButtons::configure(ANALOG_PIN); //delay(1000);
}

Well at least you tried to use code tags. You need to put the program between the tags, not after them.

Where did you download the AnalogButtons library from?

Downloaded library from the Arduino Playground area . . .

http://playground.arduino.cc/Code/AnalogButtons

I'm not sure what would cause the difference but at least now you've given all the necessary information for someone to look into it. There is a newer version of that library: GitHub - rlogiacco/AnalogButtons: Arduino library to wire multiple buttons to one single analog pin. Give that one a try, maybe it will fix your problem.

Thanks! I'll try it . . .

I'm not familiar with the pro mini, are the pins identical, so the same ones used are analog capable?

To troubleshoot I'd pare it down to one button and see if it's hardware or software causing the malf.

OK . . . the newer library and example code runs same on both Pro-Mini and
Uno 3 . . . I don't think I'll bother trying to figure out the glitch with the old one, although I'm still curious why :slight_smile:

It's all very good code, has some interesting routines, very flexible!

-Mike

I've seen three different versions of the Pro Mini in terms of the extra pin locations that are not on the outer edges and one of them had the program header pins in reversed order. Recently, a friend brought me two boards to program and they had the wrong crystal. The Serial.begin() function had to use a value twice the serial monitor setting. I would avoid the Pro Minis from China and stick with Nanos. All the pins, except one header, are on the two outer edges with the USB socket on one end. This eliminates the need for an FTDI adapter. They all use the 328P chip.