int TOUCH_PIN_IN = A1; // Pin connected to SIG at Touch-Sensor
int LED_PIN = D3; // LED pin
int TOUCH_PIN_INReading = 0;
int potPin = A5;
// Create a variable to hold the pot reading
int potReading = 0;
// Create a variable to store the LED brightness.
int ledBrightness = 125;
//Declare Button pin
int buttonPin=D3;
unsigned long lastmillis = 0; // time for interation the loop
void setup()
{
pinMode(TOUCH_PIN_IN, INPUT);
pinMode(LED_PIN, OUTPUT);
Particle.variable("intensity", ledBrightness);
Particle.variable("pressure", TOUCH_PIN_INReading);
}
void loop()
{
if ((millis() - lastmillis) > 10) { // play with the millis
lastmillis = millis();
readData();
}
}
void readData() {
int proximity = digitalRead(TOUCH_PIN_IN); // Read the state of the sensor
if (proximity == HIGH)
{
analogWrite(LED_PIN, 255); // Turn the LED on
}
else
{
analogWrite(LED_PIN, 5); // Turn the LED off
}
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .