Signal pattern controller


I'm new to the forum, new to the Arduino but I want to take a long shot and try if I can solve one problem through using Arduino.

I understand if many of you don't have patience to help someone who yet doesn't understand anything of Arduino world but I'm hoping someone will be able to help me through.

Situation is that I have a certain machine that is controlled by 24v DC signal by using foot pedal. Instead of signal being defined simply by pushing the pedal I would need to be able to control the signal more presicely controlling the pulse lenght that goes through as well as the pattern of the pulse as the signal is continous.

Possible reguirements would be for instance: - as the pedal is pressed once we then have one pulse with a lenght that may vary. In this case the signal going through should be possible to be determined to a even lenght no matter how inconstant the pedal operation is. The lenght should be adjustable up from few milliseconds. - other scenario could be that as the pedal is hold down continously the signal would be cut into a pattern of repeated pulse where pulse lenght and the gap between pulses would be adjustable. - third scenario could be that as we get in a signal of a random lenght we could determine how many pulses is output and with what lenght and sequence starting how soon after the initial pulse.

What I would need is advice on what components to purchase for this and how to actually put it all together.

Thumps up if someone can help me.

I am probably no help..(still pretty new to this also) However.

You could do something like this. in your loop look for an input like a button. count the time that is is pressed and then do something with that.

So for your instance all you are doing is getting a number, so you could always round the number in the case of the "random" scenario you were talking about.

Not sure if it helped... but at-least we are learning!

Thanks for your reply. This surely helps to get me started on my journey to understand Arduino programming. I do try to progress also by studying Arduino.

But if anyone is so fluent with Arduino that he or she could provide instructions just like that it would be much appreciated.

one thought if you could be more specific as to what you are trying to control or use this for what does the machine do? are you controlling speed ,counting parts,playing guitar or a sewing machine foot pedal?? more info will help

M_S: Situation is that I have a certain machine that is controlled by 24v DC signal by using foot pedal.

Sounds industrial.

What I’m trying to do is to control a solenoid valve of a hot melt glue gun.

In this system I have a unit with heated tank that keeps the glue melted. In in the unit there is also a pump that pumps the glue in to a heated hose keeping it pressurized.

In the end of the hose I have a glue gun that has a solenoid valve controlling the glue output.

The glue gun works with air pressure with solenoid driven by DC 24V. So when the solenoid gets 24V DC voltage it activates and lets the air pressure to do it’s job on opening the valve. After the valve is opened the pressurized glue gets out from the gun.

So what I need to achieve is very strict and controlled operation of that 24V driven solenoid valve.
Operator with foot pedal or sensor in more automated operation is the trigger of operation but as being far too inaccurate the signal needs to be able to be determined more precisely.

So if I understand it correctly what you want is simple on/off 24V DC power to the solenoid? That is easy to achieve with a simple MOSFET driver, switched by the Arduino. MOSFETs react very fast to signals coming in from the Arduino, making for great switches.

So then the unclear part: what is the actual switching pattern you want to achieve? How long time should the pulses last, interval between pulses, etc. Arduinos can easily do millisecond timing, which no doubt is fast enough for a solenoid, so it's just up to you on what patterns you want to do, and based on what kind of inputs.

Milli seconds should defenetely be precise enough to determine the pulse width.

There could be at least few different operations to start with: - when operated manually with foot pedal the initial pulse from pedal is up to operators foot and may vary from few milli seconds to a second. This pulse should be "cleaned" by Arduino to be exact amount of mill seconds as programmed. Ideal situation would be that there would be some kind of user interface to change that pulse value easily by the operator. But in a simple solution UI can be left out and the value predetermined at the code after testing what value works best. Result of this operation would be even and exact dot of glue shot by the glue gun no matter how inaccurately the pedal is operated.

  • other pattern would be to take in continous signal from the pedal as the operator keeps it pressed and turn it to a series of pulses where the width of single pulse and distance of pulses is determined in the code. In this scenario too the ability to control values (pulse width and distance of pulses) by somekind of user interface would be ideal but not mandatory. The pattern should be repeating as long as operator keeps the pedal pressed. Result from this operation would be continuous series of repeated glue dots on surface of a object as it moves under the glue gun.

  • then there might be situation where the initial signal comes from a optical sensor that is triggered by an object that moves along a convoyer. According to that signal there would be need to output signal or series of signals starting after certain time after the initial signal is received. Result being that the object receives a glue dot or series of dots to a exact place on it's surface as it moves under the glue gun transported by a convoyer.

But anyway there can by many different combinations of input signals and output signals and these all come down to programming I think. But those are the ones I can come up with right away.

I quess what I'm looking for is information of what components to purchase and what kind of code to program in to the Arduino unit to achieve this and even more similar operations.

That's all pretty straightforward to implement.

React to the pedal being pressed, regardless of how long it is. When a press is detected, dispense a shot of glue. Then a minimum pause interval in which the pedal is ignored, and start checking again. If (still) pressed, another shot.

Something like this:

#define GLUETIME 100 // the time in milliseconds glue has to come out.
#define GLUEPAUSE 1000 // the time in milliseconds between two glue shots.

unsigned long glueStartMillis = 0;
bool glueActive = false;
bool gluePaused = false;

void loop() {
  // If not active and not in pause mode, check for the pedal to be pressed.
  // When pressed, start dispensing glue.
  if (pedalPressed() && glueActive == false && gluePaused == false) {
    glueActive = true;
    glueStartMillis = millis();
  // When glue is active for more than GLUETIME milliseconds, stop dispensing and start the pause.
  if (glueActive && (millis() - glueStartMillis > GLUETIME) {
    glueActive = false;
    glueStartMillis += GLUETIME;
    gluePaused = true;
  // When GLUEPAUSE milliseconds elapsed, get out of pause state, to allow for a new shot of glue.
  if (gluePaused && (millis() - glueStartMillis > GLUEPAUSE) {
    gluePause = false;

Similarly you can add the optical sensor as trigger to start dispensing glue - either immediately, or after an interval.

Ok nice. I have absolutely zero knowledge on writing code but I think I understood a little bit.

What Arduino unit would be best to phurchase for this and what other components do I need to make my system to be compatible with 24V DC signal chain?

Arduino: Uno (for development), Mini (for soldering on a PCB - which you probably will want to do for permanent installation) or Pro Micro (harder to work with but has a much smaller footprint). Power supply: 24-5V step-down converter. Hardware driver for the glue gun: a MOSFET probably (if you can do low-side switching, so between the glue gun and GND), or relay.


I have now phurchased a Arduino Uno unit and an Arduino compatible mosfet (IRF520).

But as I'm not packing any knowledge on programming could I bother to edit the code to more ready to use state. The values may be what ever at this point. As I get it up and running I'll then be more able to understand it and can adjust the values.

But at this stage I'm a little confused how to finalize the code with all the pin setups and so on.

I want to thank you for your help so far. I feel like I'll be slowly getting my mind around all this