Erros upon combining code from two sketches

:frowning: The sketch named " freq read rev B" works fine on it’s own reading frequency value of a pulse train applied to pin 2 of the Arduino. The sketch " sigmatic rev C" reads ans analog input on A0 and determines it’s value is greater than constant sensorThreshold for 2.2 seconds and then toggles pins 4 and 5 five times. I just wanted to additionally qualify the analog level with a frrequency value between 950hz and 1050hz before toggling pins 4 and 5. I am new to this and have used portions of existing code to try and accomplish this. The code as is has several errors which has me stumped. Any help would be appreciated. Thanks in advance for any assistance! See attachments

Frequency_Read_Algorithm_Rev_B.ino (1.35 KB)

Sigmatic_Alarm_Code_Rev_C.ino (3.37 KB)

A good place to start would be to post the combined code as you tried it and the errors you saw.

Sorry - The sketch entitled " Sigmatic rev C" is the combined code. I have attached the analog level reading code ( which works fine except does not rear the frequency) here for reference. Sorry again for the confusion. The Sigmatic rev C code is what i am trying to get working. thank you.

Sigmatic_Alarm_Code_Rev_A.ino (2.05 KB)

Well the first problem is pretty obvious. Right here in setup:

void setup() {

  Serial.begin(9600);  // opens a serial port - digital was 19200?

  //below is imported setup lines from freq read program NEW

  attachInterrupt(0, myinthandler, RISING);

   //below is existing setup lines

  pinMode (LedPin, OUTPUT);  //set 13 as an output

  for(int pinNumber = 2; pinNumber <6; pinNumber++){
  digitalWrite(pinNumber, LOW);

You attach interrupt 0 to read the freq. That interrupt is on pin 2. But then right after that you set pin 2 as an output. It can’t read the frequency and trigger the interrupt if it is set as an output.

Delta_G - wow that was a stupid mistake left over from the original code I had before attempting to include the freq read interrupt. I will fix that first and carry on. thanks. I will work on it today and hopefully post a version with less problems - thanks again!