Make LED dim with photo resistor

I recently bought my first Uno with a Make starter kit and have gone through several of Jeremy Blum’s tutorial projects via YouTube. I’m stuck on his second project in Tutorial 4 however. The photo resistor doesn’t seem to map correctly, but the LED does light up

In other words, the LED goes simply on and off instead of getting dimmer and brighter. I’m using the same breadboard set up as with the project before this one. I’ve double checked my circuit, uploaded the code and it still doesn’t dim the way that it should. Any suggestions would be greatly appreciated. I’ve attached a couple of photos to illustrate…Thanks very much, Mikal



Your code? And please use the code ‘</>’ tags to mark it up.

Hello dannable,

The following is the code that I used:

int sensePin = 0;
int ledPin = 9;

void setup() {
  analogReference(DEFAULT); //isn't necessary

  pinMode(ledPin, OUTPUT);


void loop() {
  int val = analogRead(sensePin);

  val = constrain(val, 750, 900);
  int ledLevel = map(val, 750, 900, 255, 0);

  analogWrite(ledPin, ledLevel);