Stephanie Strahlerjenna
Published

Measuring Whether There is Water in a Cup

This project uses two argons to turn on an LED light when a water level sensor senses water in a cup.

BeginnerShowcase (no instructions)10 hours53
Measuring Whether There is Water in a Cup

Things used in this project

Hardware components

Argon
Particle Argon
×2
Male/Male Jumper Wires
×5
Male/Female Jumper Wires
Male/Female Jumper Wires
×3
Water Level Sensor
Our group used a Water level Sensor to determine whether there was water in a cup or not
×1
Breadboard (generic)
Breadboard (generic)
×1
LED (generic)
LED (generic)
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
ThingSpeak API
ThingSpeak API

Story

Read more

Schematics

Water Level Sensor Circuit Schematic

LED Circuit Schematic

Code

Water Sensor Code

C/C++
This is the code from Stephanie's Argon which controlled the water sensor
//Stephanie Argon
#define POWER_PIN   D5
#define SIGNAL_PIN  A3
#define THRESHOLD 75


int value = 0; // variable to store the sensor value
int wl = 0;

void setup() {

  Serial.begin(9600);
  pinMode(POWER_PIN, OUTPUT);   // configure D7 pin as an OUTPUT
  digitalWrite(POWER_PIN, LOW); // turn the sensor OFF
 
}

void loop() {
  digitalWrite(POWER_PIN, HIGH);  // turn the sensor ON
  delay(10);                      // wait 10 milliseconds
  value = analogRead(SIGNAL_PIN); // read the analog value from sensor
  digitalWrite(POWER_PIN, LOW);   // turn the sensor OFF
  if (value > THRESHOLD) {
        wl = 1;
        
        Particle.publish("Water Good", String (wl), PRIVATE);
        Particle.publish("Water Level Good", String (wl));
  } else {
        wl = 0;
        
        Particle.publish("Water Low", String (wl), PRIVATE);
        Particle.publish("Water Level Low", String (wl));
  }
}

LED Light Code

C/C++
This is the code from Jenna's Argon which controlled the green LED light and also talked to Stephanie's Argon
// Jenna Argon
int led1 = D7;

void setup () {
    Serial.begin(9600);
    Particle.subscribe("Water Level Low", LedOff); 
    Particle.subscribe("Water Level Good", LedOn);
    pinMode(led1, OUTPUT);
    
}
//void loop(){
    
//}
void LedOn (const char *event, const char *data) {
  // To blink the LED, first we'll turn it on...

    digitalWrite(led1, LOW);
    delay (500);
}
    
void LedOff (const char *event, const char *data) {
  // To blink the LED, first we'll turn it on...

    digitalWrite(led1, HIGH);
    delay (500);
  
}

Credits

Stephanie Strahler

Stephanie Strahler

1 project • 0 followers
jenna

jenna

1 project • 0 followers

Comments