Hello all,
Newbie here,
I was trying to make the serial monitor output to my windows computer using a USB connection. I was initially just going to output the data being read in on an analog output. I couldn't make that work. Then I put in a line just to output Hello World. Niether are coming on the serial monitor. I looked at the language reference to no avail.
Please Help. The code is here:
int counter = 0;
int sensorPin = A0;
int sensorValue = 0;
void setup()
{
pinMode(A0, INPUT);
pinMode(10, OUTPUT);
pinMode(2, OUTPUT); Serial.begin(9600); // open the serial port at 9600 bps:
// Thermostat Circuit //Serial.print(Hello World); Serial.print("Hello world.");
sensorValue = analogRead(sensorPin); Serial.print(sensorValue,DEC); // Output to the serial monitor
if (sensorValue < 50) //500 is original Value for the temperature input
{
digitalWrite(2, HIGH); // turn fan on
}
else
{
digitalWrite(2, LOW); // turn fan off
}
}
//}
Thanks all, the printer does now print the first line. I modified the code accordlingly:
int counter = 0;
int sensorPin = A0;
int sensorValue = 0;
void setup()
{
pinMode(A0, INPUT);
pinMode(10, OUTPUT);
pinMode(2, OUTPUT);
Serial.begin(9600); // open the serial port at 9600 bps:
}
void loop()
{
Serial.print("This is a test");
// PWM Code
while(counter < 50);
{
digitalWrite(10, HIGH);
Serial.print("pin 10 is high");
delay(5);
digitalWrite(10, LOW);
Serial.print("pin 10 is low");
delay(5);
}
delay(50);
int counter = 0;
Serial.print("counter is now reset");
// Thermostat Circuit
digitalWrite(13, HIGH);
Serial.print("Hello world it's temperature measurement Time.");
sensorValue = analogRead(sensorPin);
Serial.print(sensorValue,DEC); // Output to the serial monitor
if (sensorValue < 50) //500 is original Value for the temperature input
{
digitalWrite(2, HIGH); // turn fan on
Serial.print("Fan is now on");
}
else
{
digitalWrite(2, LOW); // turn fan off
Serial.print("Fan is now off");
}
delay(1000);
digitalWrite(13, LOW);
}
Problem now is only the first line prints, then it seems to stall in the while loop. Any thoughts on how to get it past this one.