Back to Parent

// Stage 1 code

int ledPin =  D0; // Light pin digital output
int pressureSensorPin = A0; // connected to analog pin 0
int pressureReading; // define a variable to store our sensor reading
int ledBrightness = 0; // assigning ledBrightness to 0

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  Particle.variable("pressure", &pressureReading, INT); 
}

void loop(){
  pressureReading = analogRead(pressureSensorPin);
  Serial.println( pressureReading );
  ledBrightness = map(pressureReading, 0, 4095, 50, 255);
  analogWrite(ledPin, ledBrightness); // control the ledPin output
  delay(1000); // take reading every second 

}
Click to Expand

Content Rating

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

0