digitalRead always goes high

Hi! Right now I am working on building a laser piano using an Arduino. I have lasers shining into photoresistors that are hooked up to a logic circuit I designed. The logic circuit ends up sending either a high or low logic state to the digital inputs of the Arduino. The problem is that my Arduino seems to register each pin as high when I use digitalRead. Even if I ground a digital pin, the serial output for the digitalRead is still high for said pin. Has anyone encountered this before? Here is my code:

// Code for a laser harp/piano

int CPIN = 0;
int CsPIN = 1;
int DPIN = 2;
int DsPIN = 3;
int EPIN = 4;
int FPIN = 5;
int FsPIN = 6;
int GPIN = 7;
int GsPIN = 8;
int APIN = 9;
int AsPIN = 10;
int BPIN = 11;
int HCPIN = 12;
int Speaker = 13;
int C = 0;
int Cs = 0;
int D = 0;
int Ds = 0;
int E = 0;
int F = 0;
int Fs = 0;
int G = 0;
int Gs = 0;
int A = 0;
int As = 0;
int B = 0;
int HC = 0;

void setup() {
pinMode(CPIN, INPUT);
pinMode(CsPIN, INPUT);
pinMode(DPIN, INPUT);
pinMode(DsPIN, INPUT);
pinMode(EPIN, INPUT);
pinMode(FPIN, INPUT);
pinMode(FsPIN, INPUT);
pinMode(GPIN, INPUT);
pinMode(GsPIN, INPUT);
pinMode(APIN, INPUT);
pinMode(AsPIN, INPUT);
pinMode(BPIN, INPUT);
pinMode(HCPIN, INPUT);
pinMode(Speaker, OUTPUT);
}

void loop() {

C = digitalRead(CPIN);
Cs = digitalRead(CsPIN);
D = digitalRead(DPIN);
Ds = digitalRead(DsPIN);
E = digitalRead(EPIN);
F = digitalRead(FPIN);
Fs = digitalRead(FsPIN);
G = digitalRead(GPIN);
Gs = digitalRead(GsPIN);
A = digitalRead(APIN);
As = digitalRead(AsPIN);
B = digitalRead(BPIN);
HC = digitalRead(HCPIN);

if(C == 1) {
buzz(Speaker, 523.25);
}
if(Cs = 1) {
buzz(Speaker, 554.37);
}
if(D = 1) {
buzz(Speaker, 587.33);
}
if(Ds = 1) {
buzz(Speaker, 655.25);
}
if(E = 1) {
buzz(Speaker, 659.26);
}
if(F = 1) {
buzz(Speaker, 698.46);
}
if(Fs = 1) {
buzz(Speaker, 739.99);
}
if(G = 1) {
buzz(Speaker, 783.99);
}
if(Gs = 1) {
buzz(Speaker, 830.61);
}
if(A = 1) {
buzz(Speaker, 880.00);
}
if(As = 1) {
buzz(Speaker, 932.33);
}
if(B = 1) {
buzz(Speaker, 987.77);
}
if(HC = 1) {
buzz(Speaker, 1046.50);
}
}

void buzz(int targetPin, long frequency) {
long delayValue = 1000000/frequency/2; // calculate the delay value between transitions
//// 1 second's worth of microseconds, divided by the frequency, then split in half since
//// there are two phases to each cycle
digitalWrite(targetPin,HIGH); // write the buzzer pin high to push out the diaphram
delayMicroseconds(delayValue); // wait for the calculated delay value
digitalWrite(targetPin,LOW); // write the buzzer pin low to pull back the diaphram
delayMicroseconds(delayValue); // wait againf or the calculated delay value
}

Are you sure buzz() is working? It's a little unusual to pass floating point constants for an argument that is expecting a long integer.

Try calling buzz() in setup - send two or three beeps to make sure it's working. Or look into tone().

You'll get better help with the overall problem if you post a schematic of your circuit.

Good luck with your project,

-br

You'll get better help with the overall problem if you post a schematic of your circuit

And if you read the how to use this forum sticky and correct that post so code is correctly posted.