Go Down

Topic: No Information in serial monitor (Read 998 times) previous topic - next topic

00woodm

Hi,

Forgive me for this no doubt stupid question but;

After inputting the code from the projects book, I cannot see anything in the serial monitor. Obviously I have checked the baut rate is at the required 9600, and for anyone's info my Arduino is in COM3.

Naturally the lights are not working. So I guess the question is;

Is the problem with the code, causing the serial monitor to not work? or vice versa.

The code compiles fine with no errors;

Here is my code, which I believe is straight out of the book..

const int sensorPin = A0;
const float baselineTemp = 20.0;

void setup(){
 
  Serial.begin(9600);//open a serial port
 
  for(int pinNumber = 2; pinNumber,5; pinNumber ++){
    pinMode(pinNumber, OUTPUT);
    digitalWrite(pinNumber, LOW);
  }
}
void loop(){
  int sensorVal = analogRead(sensorPin);
 
  Serial.print("sensor value:");
  Serial.print(sensorVal);
 
  //convert the ADC reading to voltage
  float voltage = (sensorVal/1024.0)*5.0;
  Serial.print(", Volts: ");
  Serial.print(voltage);
 
  Serial.print(", degrees C: ");
  //convert the voltageto temperature in degrees
  float temperature = (voltage - .5)*100;
  Serial.println(temperature);
 
  if(temperature<baselineTemp){
    digitalWrite(2,LOW);
    digitalWrite(3,LOW);
    digitalWrite(4,LOW);

   }
 
  else if(temperature>=baselineTemp+2 && temperature<baselineTemp+4){
    digitalWrite(2,HIGH);
    digitalWrite(3,LOW);
    digitalWrite(4,LOW);
   
  } else if(temperature>=baselineTemp+4&& temperature<baselineTemp+6){
    digitalWrite(2,HIGH);
    digitalWrite(3,HIGH);
    digitalWrite(4,LOW);
   
  } else if(temperature>=baselineTemp+6){
    digitalWrite(2,HIGH);
    digitalWrite(3,HIGH);
    digitalWrite(4,HIGH);
    }
    delay(1);
}

Thanks in advance guys!!

dannable

#1
Jan 10, 2016, 08:31 pm Last Edit: Jan 10, 2016, 08:32 pm by dannable
Please use code tags when pasting code into your post. See the post at the top of the page on 'How to use this forum'.

Which book? Which project?

This line doesn't look right for starters...

Code: [Select]
for(int pinNumber = 2; pinNumber,5; pinNumber ++){
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

00woodm

Ah, I see. Sorry I see what you mean Re: code tags.

Thank you for your help. You were rite, the  comma before the 5 in the line of code you highlighted should have been a <

I did not get a compile error though, I guess this is because strictly speaking this could be a correct syntax??

In answer to your other questions and perhaps for future users the book I refer to is the Arduino Projects Book included in the starter pack. The project is number 3.

Thank you again for your help.

Go Up