I need help with the serial monitor (read inside)

so I have been trying to make a small test project using the serial monitor to display the current going through a photoresistor. I have connected one of the terminals of the P.R. to the 'ANALOG IN (0)' and the other terminal to '5V'. here is my code:

void setup() {

int power = 0;
}

void loop() {

Serial.begin(9600);

int power = (analogRead(0));

Serial.write(power);
Serial.println();
}

when I upload the code and look at the serial monitor, all it shows is '$H?'

how can I make the serial monitor constanltly display the 'power' variable?

please be nice, as I am very new.

you want Serial.print(power) which converts the integer into human readable ASCII.

ooooooh, ok. I never really learned the difference between Serial.write and Serial.print. however when I uploaded with print, it did pretty much the same thing…

That is probably a poor way to connect a photoresistor. You probably need another fixed resistor from the analog input pin to ground. A good starting value would be whatever resistance the photoresistor has when it is moderately illuminated.

Traditionally, Serial.begin() is put in setup() because it is only needed once.

Did you set the baud rate of Serial Monitor to 9600? There is a drop-down menu for that at the bottom of the Serial Monitor window.