I got the program below off of this website and I'm wondering if somebody could explain what
"Serial.println(analogRead(lightPin))" does in the program.
Thanks
Drew Davis
int lightPin = 0; //define a pin for Photo resistor
int ledPin=11; //define a pin for LED
void loop()
{
Serial.println(analogRead(lightPin)); //Write the value of the photoresistor to the serial monitor.
analogWrite(ledPin, analogRead(lightPin)/4); //send the value to the ledPin. Depending on value of resistor
//you have to divide the value. for example,
//with a 10k resistor divide the value by 2, for 100k resistor divide by 4.
delay(10); //short delay for faster response to light.
}
lightpin is defined here as pin 0 (zero) on the arduino board, this is the arduino pin that has the photoresistor connected to it.
The resistance of the photoresistor varies with the amount of light that falls on it, pin zero reads this value same as it would with a pot (variable resistor).
Serial.print prints out this value to the serial monitor as well as controlling the brightness of the LED.
I understand that it prints the value to the serial monitor but how does that effect the program?
Also, what is a serial monitor? Sorry to ask such basic questions.
Deleting it does no harm as AWOL remarked, but don't forget it's existance - Serial.print and Serial.println are your primary weapons for debugging your sketches. You will be needing them before long I suspect.