LED Status lighting (On/off)


I am using the Arduino Mega. I am trying to write to the serial port to get the status of the devices attached to the ports. I am using digitalRead() to read the value of a contact switch. Once the value is read, I am trying to write this value to the serial port but I am not having much success. I get some values as well as other garbage.

I have attached that portion of the code:

// Read Status of Contact Switches
for(int reaD = 44; reaD <= 53; reaD++) {
d_val= digitalRead(reaD); // read the input pin
if (d_val == ‘1’){
digitalWrite(13, d_val);
else {
Serial.write(deviceByte); // write value to Serial

Any ideas?

if (d_val == '1'){

digitalRead NEVER returns the ASCII character ‘1’ - use 1 or HIGH instead.

(This isn’t really a poll, is it?)

No it is not a poll. I have tried "HIGH" as well and I have not been to successful. Any other ideas?

Serial.write() is not the same as Serial.print() or Serial.println().