# MSP430G2231 Serial out using Energia

I am trying to read an analog signal using the Analog.Read() function and output 1 or 0 depending on the value of the analog signal. While testing using a serial monitor, I always get the symbol for 'phi'instead of 0 and the 'square box with question mark'instead of 1. Please help.

    const int analogInPin = A3;
int inputValue=0;
int ch1=1,ch2=0;
void setup()
{

pinMode(A0, INPUT);
Serial.begin(9600);
}

void loop()
{
if(inputValue>240)
Serial.print('1');
else
Serial.print('0');
delay(10);
}


If I remember well you can use either:

Serial.print(1);

or

Serial.write('1');

To display 1 in the serial monitor.

• I tried that too,but the same outcome with a different character. – Ajmal Mulla Abdul Shukoor Dec 3 '14 at 19:14
• You might try also Serial.print("1"); – Roger C. Dec 3 '14 at 19:15
• That doesn't work either. – Ajmal Mulla Abdul Shukoor Dec 3 '14 at 19:18
• You may have a problem somewhere else because I'm pretty sure that this code works. You could look to the TX line on the oscilloscope, to see what does generate the microcontroller. – Roger C. Dec 3 '14 at 19:20
• This is not related to the problem you're describing but in your code you're setting A0 as an input but reading from A3. – Roger C. Dec 3 '14 at 20:05

If you're trying to output 1 or 0 simply remove your single quotes and use the following:

Serial.print(1);

Or

Serial.print(0);


Your code is printing out the ASCII value of 1 and 0...