Hi everyone. I want to create a multiple pulse generator using Arduino (currently using mega2560).
I want to create pulses using two push buttons so that each time I press either of the push buttons a pulse on that input pin is generated. I want to control each button independently. Also, I want to once increase the push button time and then take the readings and then keep them steady and count them. Can anyone help me with the code?
Here is my code-
const int input = 12;
const int input1 = 10;// This is where the input is fed.
int pulse = 0; // Variable for saving pulses count.
int pulse1 = 1;
int var = 0;
int var1 = 0;
void setup(){
pinMode(input, INPUT);
Serial.begin(9600);
Serial.println(F("No pulses yet...")); // Message to send initially (no pulses detected yet).
}
void loop(){
if(digitalRead(input) > var)
{
var = 1;
pulse++;
Serial.print(pulse);
Serial.print(F(" pulse"));
// Put an "s" if the amount of pulses is greater than 1.
if(pulse > 1) {Serial.print(F("s"));}