Back to Parent

int motor = D3;
int photoCellPin = A0;
int photoCellReading = 0;
int ledPin = D2;
int ledBrightness = 0;


 //int prePhotoCellReading = 0;

void setup() 
{
    pinMode(photoCellPin, INPUT);
    pinMode(motor, OUTPUT);
    pinMode(ledPin, OUTPUT);
    Particle.variable("light", &photoCellReading, INT);
}

void loop() 
{
    photoCellReading = analogRead(photoCellPin);
    if(photoCellReading < 2000)
    {
        digitalWrite(ledPin, HIGH);
        digitalWrite(motor, HIGH);
        delay(3000);
    }
    else
    {
        digitalWrite(ledPin, LOW);
        digitalWrite(motor, LOW);
    }

// Map this value into the PWM range (0-255)
// and store as the led brightness
  
   
    delay(100);
    
}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0