Pulse input and Pulse output

Hi
Afternoon all.
I am a nubie to Arduino and i would like some assistance with my first project.

I am trying to create pulse input from a bill acceptor to a Arduino Pro Mini The Simple. On the output side to be connected to a very old video game.

On the input side, i would like to send, One (1) pulse from bill acceptor to this Arduino board.

On the output side i would like the Arduino to send Ten(10) pulse to the board.
Can someone assist me as to how i would write a code for this Arduino board.

Thanks
Harold Cover

We can't do much about whether your "bill acceptor" emits a pulse or doesn't. So I guess what you really mean is when it does send a pulse you want to be able to detect it? So the next question is what sort of pulse will it send? What voltage? How long does it last? That will determine how to connect it to the Arduino etc.

Then your next part is presumably for each incoming pulse that you read you want to send out on a different pin 10 pulses. Again what voltage does "the board" expect? How long is each pulse? How long between pulses?

What is supposed to happen if a new input pulse arrives when you're still in the middle of sending your last 10 output pulses?

Steve

Have a look st some of the examples under “ digital “ in the Arduino IDE examples .

Hi Steve
Thanks for replying. I will try to get all necessary info to answer your questions.

Hammy,
Thanks also, i will take a look at the page that you referred me to.
Harold

Steve
to answer some of your questions,
I don't know if the bill acceptor send voltage while its pulsing.
in regards to the question of pulsing,

1 pulse=10
2 pulse=20
10 pulse=100
20 pulse=200

These four (4) are the pulse that i am interested in working with.
Regards
Harold

Can you provide a link to a datasheet or other details of the bill acceptor you want to work with?

Without knowing exactly what it is sending we can't really help you to know how to read it.

BTW a pulse normally consists of a signal going up to a specific voltage and then some defined time later going back down to zero. You need to know the details.

Steve

Let's start with the File->Examples->02.Digital->StateChangeDetection example. Make a slight change to count 10 for each input 'button press'. Then send an output pulse if the count is > 0.

// this constant won't change:
const int  ButtonPin = 2;    // the pin that the pushbutton is attached to
const int  OutputPin = 13;       // the pin that the LED is attached to


// Variables will change:
int OutputPulseCounter = 0;   // counter for the number of button presses
boolean LastButtonState = HIGH;     // previous state of the button


void setup()
{
  // initialize the button pin as a input:
  pinMode(ButtonPin, INPUT_PULLUP);  // Use PULLUP in case the signal is Open Collector.
  // initialize the output:
  pinMode(OutputPin, OUTPUT);
}




void loop()
{
  static unsigned long lastButtonChangeTime = 0;
  unsigned long currentTime = millis();
  // read the pushbutton input pin:
  boolean buttonState = digitalRead(ButtonPin);


  // compare the buttonState to its previous state (ignore bounces)
  if (buttonState != LastButtonState && currentTime - lastButtonChangeTime > 10)
  {
    lastButtonChangeTime = currentTime;


    // if the state has changed, increment the counter
    if (buttonState == LOW)
    {
      // if the current state is LOW then the input went from off to on:
      OutputPulseCounter += 10;
    }
  }
  // save the current state as the last state, for next time through the loop
  LastButtonState = buttonState;


  if (OutputPulseCounter > 0)
  {
    // Output one of the pulses
    digitalWrite(OutputPin, HIGH);
    digitalWrite(OutputPin, LOW);
    OutputPulseCounter--;
  }
}

Thanks for your response lipstick
Here is all info i can find on bill acceptor;

Thank you John Wasser i will be trying to play around and if i run into trouble then i will ask for your guidance

evening all
i have a ch340 programmer that i purchase on ebay, trying to write to a a pro mini board and unable to do so. getting error message as follows

avrdudr: stk500_recv (): programming is not responding
avrdudr: stk500_getsync () attempt 10 of 10 not in sync resp=0xfe
problem uploading to board.

can any assist please
Thanks
Harold

As soon as you see the compiler say "uploading", press and release the reset button. You may need to do this several times. Consider buying a new FTDI cable or adapter that does this automatically for you (known as DTR pin enabled).

Can you refer me to one please. I looked at the Arduino store but did not see one there

rick3973:
Can you refer me to one please. I looked at the Arduino store but did not see one there

I use this device to program my pro minis (which has become my preferred 328 board.)

ChrisTenone:
As soon as you see the compiler say "uploading", press and release the reset button. You may need to do this several times. Consider buying a new FTDI cable or adapter that does this automatically for you (known as DTR pin enabled).
[/quThis method that you asked me to try didnt work either

rick3973:

ChrisTenone:
As soon as you see the compiler say "uploading", press and release the reset button. You may need to do this several times. Consider buying a new FTDI cable or adapter that does this automatically for you (known as DTR pin enabled).

This method that you asked me to try didnt work either

The reset button trick is, well, tricky. You need to do it a few times, because you need to hit it at exactly the right moment. If the correct cable doesn't work, then you have a different problem.

Hi All,

Johnwasser had helped me to write this code for my project, but after finally getting it to upload to the MiniPro and connect it to the gaming board to add credits, it (coin jam) the the game board. I am using a micro switch on Pin 2 input to create a one punch input and on pin 13 output to create 10 pulse output. I cant seems to get it correct. so I am posting what I have this far to see if anyone could help to correct it.

Thanks
Harold

// this constant won't change
const int ButtonPin = 2; // the pin that micro switch or bill acceptor is connected to
const int OutputPin = 13; // the pin that is attached to game pcb edge connector

// Variables will change:
int OutputPulseCounter = 10; // counter for the number of pulse from mini pro to game pcb
boolean LastButtonState = HIGH; // previous state of pulse

void setup() {
// initialize the button pin as an input:
pinMode(ButtonPin, INPUT_PULLUP); // Use PULLUP in case the signal is Open Collector:
// initialize the output:
pinMode(OutputPin, OUTPUT);

}

void loop()
{

static unsigned long LastButtonChangeTime = 0;
unsigned long CurrentTime = 50;
// read the pushbuttoninput pin:
boolean buttonState = digitalRead(ButtonPin);

// compare the buttonState to its previous state (ignore bounces)
if (buttonState !=LastButtonState && CurrentTime - LastButtonChangeTime > 10);

{
LastButtonChangeTime = CurrentTime;
// if the state has changed, increment the counter if (buttonState ==Low)
{
// if the current state is LOW then the input went from off to on:
OutputPulseCounter += 10;
}
}
// save the current state as the last state, for next time through the loop
LastButtonState = buttonState;

if (OutputPulseCounter > 0)
{
// Output one of the pulses
digitalWrite(OutputPin, HIGH);
digitalWrite(OutputPin, LOW);
OutputPulseCounter--;

}
}

johnwasser:
Let's start with the File->Examples->02.Digital->StateChangeDetection example. Make a slight change to count 10 for each input 'button press'. Then send an output pulse if the count is > 0.

// this constant won't change:

const int  ButtonPin = 2;    // the pin that the pushbutton is attached to
const int  OutputPin = 13;      // the pin that the LED is attached to

// Variables will change:
int OutputPulseCounter = 0;  // counter for the number of button presses
boolean LastButtonState = HIGH;    // previous state of the button

void setup()
{
  // initialize the button pin as a input:
  pinMode(ButtonPin, INPUT_PULLUP);  // Use PULLUP in case the signal is Open Collector.
  // initialize the output:
  pinMode(OutputPin, OUTPUT);
}

void loop()
{
  static unsigned long lastButtonChangeTime = 0;
  unsigned long currentTime = millis();
  // read the pushbutton input pin:
  boolean buttonState = digitalRead(ButtonPin);

// compare the buttonState to its previous state (ignore bounces)
  if (buttonState != LastButtonState && currentTime - lastButtonChangeTime > 10)
  {
    lastButtonChangeTime = currentTime;

// if the state has changed, increment the counter
    if (buttonState == LOW)
    {
      // if the current state is LOW then the input went from off to on:
      OutputPulseCounter += 10;
    }
  }
  // save the current state as the last state, for next time through the loop
  LastButtonState = buttonState;

if (OutputPulseCounter > 0)
  {
    // Output one of the pulses
    digitalWrite(OutputPin, HIGH);
    digitalWrite(OutputPin, LOW);
    OutputPulseCounter--;
  }
}

johnwasser:
Let's start with the File->Examples->02.Digital->StateChangeDetection example. Make a slight change to count 10 for each input 'button press'. Then send an output pulse if the count is > 0.

// this constant won't change:

const int  ButtonPin = 2;    // the pin that the pushbutton is attached to
const int  OutputPin = 13;      // the pin that the LED is attached to

// Variables will change:
int OutputPulseCounter = 0;  // counter for the number of button presses
boolean LastButtonState = HIGH;    // previous state of the button

void setup()
{
  // initialize the button pin as a input:
  pinMode(ButtonPin, INPUT_PULLUP);  // Use PULLUP in case the signal is Open Collector.
  // initialize the output:
  pinMode(OutputPin, OUTPUT);
}

void loop()
{
  static unsigned long lastButtonChangeTime = 0;
  unsigned long currentTime = millis();
  // read the pushbutton input pin:
  boolean buttonState = digitalRead(ButtonPin);

// compare the buttonState to its previous state (ignore bounces)
  if (buttonState != LastButtonState && currentTime - lastButtonChangeTime > 10)
  {
    lastButtonChangeTime = currentTime;

// if the state has changed, increment the counter
    if (buttonState == LOW)
    {
      // if the current state is LOW then the input went from off to on:
      OutputPulseCounter += 10;
    }
  }
  // save the current state as the last state, for next time through the loop
  LastButtonState = buttonState;

if (OutputPulseCounter > 0)
  {
    // Output one of the pulses
    digitalWrite(OutputPin, HIGH);
    digitalWrite(OutputPin, LOW);
    OutputPulseCounter--;
  }
}

Hi All,

Johnwasser had helped me to write this code for my project, but after finally getting it to upload to the MiniPro and connect it to the gaming board to add credits, it (coin jam) the the game board. I am using a micro switch on Pin 2 input to create a one punch input and on pin 13 output to create 10 pulse output. I cant seems to get it correct. so I am posting what I have this far to see if anyone could help to correct it.

Thanks
Harold

// this constant won't change
const int ButtonPin = 2; // the pin that micro switch or bill acceptor is connected to
const int OutputPin = 13; // the pin that is attached to game pcb edge connector

// Variables will change:
int OutputPulseCounter = 10; // counter for the number of pulse from mini pro to game pcb
boolean LastButtonState = HIGH; // previous state of pulse

void setup() {
// initialize the button pin as an input:
pinMode(ButtonPin, INPUT_PULLUP); // Use PULLUP in case the signal is Open Collector:
// initialize the output:
pinMode(OutputPin, OUTPUT);

}

void loop()
{

static unsigned long LastButtonChangeTime = 0;
unsigned long CurrentTime = 50;
// read the pushbuttoninput pin:
boolean buttonState = digitalRead(ButtonPin);

// compare the buttonState to its previous state (ignore bounces)
if (buttonState !=LastButtonState && CurrentTime - LastButtonChangeTime > 10);

{
LastButtonChangeTime = CurrentTime;
// if the state has changed, increment the counter if (buttonState ==Low)
{
// if the current state is LOW then the input went from off to on:
OutputPulseCounter += 10;
}
}
// save the current state as the last state, for next time through the loop
LastButtonState = buttonState;

if (OutputPulseCounter > 0)
{
// Output one of the pulses
digitalWrite(OutputPin, HIGH);
digitalWrite(OutputPin, LOW);
OutputPulseCounter--;

}
}

   // if the state has changed, increment the counter if (buttonState ==Low)

Where do you you test whether buttonState is LOW in the code ?

Please learn to post your code in blocks.

// this constant won't change
const int ButtonPin = 2;     // the pin that micro switch or bill acceptor is connected to
const int OutputPin = 13;    // the pin that is attached to game pcb edge connector

// Variables will change:
int OutputPulseCounter = 10;        // counter for the number of pulse from mini pro to game pcb
boolean LastButtonState = HIGH;     // previous state of pulse

void setup() 
{
    // initialize the button pin as an input:
    pinMode(ButtonPin, INPUT_PULLUP);   // Use PULLUP in case the signal is Open Collector:
    // initialize the output:
    pinMode(OutputPin, OUTPUT);

}

void loop()
{
    static unsigned long LastButtonChangeTime = 0;
    unsigned long CurrentTime = 50;
    // read the pushbuttoninput pin:
    boolean buttonState = digitalRead(ButtonPin);

    // compare the buttonState to its previous state (ignore bounces)
    if (buttonState !=LastButtonState && CurrentTime - LastButtonChangeTime > 10);
    {
        LastButtonChangeTime = CurrentTime;
        // if the state has changed, increment the counter if (buttonState ==Low)
        {
            // if the current state is LOW then the input went from off to on:
            OutputPulseCounter += 10;  
        }
    }
    // save the current state as the last state, for next time through the loop
    LastButtonState = buttonState;

    if (OutputPulseCounter > 0)
    {
        // Output one of the pulses
        digitalWrite(OutputPin, HIGH);
        digitalWrite(OutputPin, LOW);
        OutputPulseCounter--;

    }
}

When you enter loop(), static LastButtonChangeTime = 0, CurrentTime = 50.

The first time buttonState != LastButtonState you will drop into the test segment because CurrentTime - LastButtonChangeTime = 50 which is greater than 10. You then set LastButtonChangeTime = CurrentTime; which means they are both now = 50. Your test condition will never again be true and OutputPulseCounter will never again increment.

// Variables will change:
int OutputPulseCounter = 10;        // counter for the number of pulse from mini pro to game pcb

WHY?!? Why give 10 pulses of credit each time the sketch restarts?

  unsigned long CurrentTime = 50;

WHY?!? Why are you setting the time to 50 and not millis()?!? That will completely muck up the debounce timer!

    // if the state has changed, increment the counter if (buttonState ==Low)
    {
      // if the current state is LOW then the input went from off to on:
      OutputPulseCounter += 10;
    }

WHY?!? Why did you remove the " if (buttonState == LOW)"?!? That will credit 10 pulses whenever the input changes, both when the pulse goes LOW and when it goes HIGH. That's 20 output pulses per input pulse.