Back to Parent

const int ledPin = D2;
const int lightPin = A5;
const int servoPin = D5;
Servo P;

int lightData;
int servoPos;

int last_published = -1;

void spreadsheet(){

  // check if 1 minute has elapsed
	if( last_published + 60000 < millis() ){
		Particle.publish( "spreadsheet", String(lightData) );
		last_published = millis();
	}

}

 
void setup()
{
  //Setup pin modes
  pinMode(lightPin, INPUT);
  pinMode(ledPin, OUTPUT);
  P.attach(servoPin);
  
}
 
void loop(){
    lightData = analogRead(lightPin);

    
    spreadsheet();

    servoPos = map(lightData, 4000, 4095, 85, 180);
    
    P.write(servoPos);
    
    Particle.publish("lightData", String(lightData));
    
    delay(5000);

    
    //if(lightData < 200){
    //    P.write(70);
    //}
    //else{
    //    P.write(160);
    //    digitalWrite(ledPin, HIGH);
    //}
    
}
const int ledPin = D2;
const int lightPin = A5;
const int servoPin = D5;
Servo P;

int lightData;
int servoPos;

int last_published = -1;

void spreadsheet(){

  // check if 1 minute has elapsed
	if( last_published + 60000 < millis() ){
		Particle.publish( "spreadsheet", String(lightData) );
		last_published = millis();
	}

}

 
void setup()
{
  //Setup pin modes
  pinMode(lightPin, INPUT);
  pinMode(ledPin, OUTPUT);
  P.attach(servoPin);
  
}
 
void loop(){
    lightData = analogRead(lightPin);

    
    spreadsheet();

    servoPos = map(lightData, 4000, 4095, 85, 180);
    
    P.write(servoPos);
    
    Particle.publish("lightData", String(lightData));
    
    delay(5000);

    
    //if(lightData < 200){
    //    P.write(70);
    //}
    //else{
    //    P.write(160);
    //    digitalWrite(ledPin, HIGH);
    //}
    
}
const int ledPin = D2;
const int lightPin = A5;
const int servoPin = D5;
Servo P;

int lightData;
int servoPos;

int last_published = -1;

void spreadsheet(){

  // check if 1 minute has elapsed
	if( last_published + 60000 < millis() ){
		Particle.publish( "spreadsheet", String(lightData) );
		last_published = millis();
	}

}

 
void setup()
{
  //Setup pin modes
  pinMode(lightPin, INPUT);
  pinMode(ledPin, OUTPUT);
  P.attach(servoPin);
  
}
 
void loop(){
    lightData = analogRead(lightPin);

    
    spreadsheet();

    servoPos = map(lightData, 4000, 4095, 85, 180);
    
    P.write(servoPos);
    
    Particle.publish("lightData", String(lightData));
    
    delay(5000);

    
    //if(lightData < 200){
    //    P.write(70);
    //}
    //else{
    //    P.write(160);
    //    digitalWrite(ledPin, HIGH);
    //}
    
}
Click to Expand

Content Rating

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

0