Help with getting a binary from a pesky AC-type signal....

So I am trying to get just a simple ON or OFF from a reading from a synthesizer. I want to know whether a key is being pressed or not, and I am sending in an analog DC signal into the arduino from the synth. The problem is that I am reading the pin and when the key isn't pressed I get ~303. It fluctuates a lot (sometimes all the way to 307). When I press a key, I get a very fast alternating signal that swings down to the ~100 range and then up to the ~500 range.

I've tried subtracting 303 from the signal and then taking the absolute value of that number to try to get a simple 0 state to be off and then anything above 0 would be on. Unfortunately since it goes back and forth, sometimes even when a key is pressed I will get a 0... I know there must be a way to do this with some simple programming skills but I can't seem to figure this out!

Thank you!

What code do you have for reading the analog signal?

What does your circuit look like? What is the circuitry of the synthesizer output pin?

The circuitry of the synth going into the arduino is fairly straightforward because on this synth (Korg Volca) there are solder points for all kinds of things you might wanna take out of the synth.

For this project I am taking the VCA out of the synth and putting it into the arduino pin A0.

I am trying to get the a key press to light up the LED strip and the pitch of the synth is changing the color.

I am connecting the ground of the synth to the ground of the Arduino.

heres the code::

#include <HSBColor.h>

#define REDPIN 9
#define GREENPIN 10
#define BLUEPIN 11

void H2R_HSBtoRGB(int hue, int saturation, int brightness, int* rbg_array);
int squarewave = 7;     //sqr input from volca
unsigned long duration;  //duration of wavelength
int huemap ;             //mapped hue that sqr input
int colors[3];            //color array
int brightmapped = 0;   //for the smoothed VCA in number to go
int inputPin = A0;               //raw input from volca VCA in 
int brightonoff;
int rawinput;

void setup()
  pinMode(squarewave, INPUT);
  pinMode(REDPIN, OUTPUT);
   for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0; 

void loop()

rawinput = analogRead(inputPin);
  brightmapped = 303 - rawinput; 
 if (abs(brightmapped) > 3) {
    brightonoff = 99;} else {
      brightonoff = 0;
  duration = pulseIn(squarewave, HIGH);
  Serial.print("\t brightmapped =");
  Serial.print("\t bright on off");
  huemap = map(duration, 200, 17000, 0, 255);
   H2R_HSBtoRGB(huemap, 99, brightonoff, colors);
  analogWrite(REDPIN, colors[0]);
  analogWrite(BLUEPIN, colors[1]);
  analogWrite(GREENPIN, colors[2]);