So would this be ok?
I want to count the number of pulses in a second. Is there a better way? If im going to have multiple things in the main loop is that the right way of doing it or should i use interupts? I'm very new to this . Thanks Rob
//////////////////////////////////////////////////
/////////////////START UP CODE////////////////////
//////////////////////////////////////////////////
int latchPin = 8; //Latch pin declare
int clockPin = 12; //Clock pin declare
int dataPin = 11; //Data pin declare
int rpmpulseinput = 1; //RPM input declare
int pulsesdetected = 0; //RPM counted
void setup() {
//start com with (serial)
Serial.begin(96000);
Serial.println("Arduino Connected to M1330 via USB");
//Connect to shift register IC
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(rpmpulseinput, INPUT);
// sets the digital pin as input
digitalWrite(rpmpulseinput, HIGH);
// turns on the internal pull up
//Output test of IC
}
//////////////////////////////////////////////////
///////////////////MAIN CODE//////////////////////
//////////////////////////////////////////////////
int pulseread(){
if (digitalRead(rpmpulseinput) == LOW) {
pulsesdetected=pulsesdetected+1;
}
}
void loop()
{
pulseread();
//DO OTHER THINGS
//MORE OTHER THINGS :)
}
//////////////////////////////////////////////////
////////////////////END OF CODE///////////////////
//////////////////////////////////////////////////