Peter MaJustin ShenkShin Ae HongSarah Han
Published © LGPL

Clean Water AI

Using AI to detect dangerous bacteria and harmful particles in the water.

AdvancedFull instructions providedOver 1 day31,285

Things used in this project

Story

Read more

Custom parts and enclosures

Up2 Board

Up2 Board

Schematics

Helium IoT

Using Helium IoT to connect to Google IoT Core

Code

Arduino water pump

Arduino
Arduino of Water pumping
#define ROTARY_ANGLE_SENSOR A0
#define LED 3  //the Grove - LED is connected to PWM pin D3 of Arduino
#define ADC_REF 5 //reference voltage of ADC is 5v.If the Vcc switch on the seeeduino
                    //board switches to 3V3, the ADC_REF should be 3.3
#define GROVE_VCC 5 //VCC of the grove interface is normally 5v
#define FULL_ANGLE 300 //full value of the rotary angle is 300 degrees


const int ledPin =  6;      // the number of the LED pin
const int ledPin2 =  5;      // the number of the LED pin
int incomingByte = 0;   // for incoming serial data
const int buttonPin = 2;     // the number of the pushbutton pin
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  pinMode(ledPin2, OUTPUT);
    // initialize the LED pin as an output:
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
  Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
  pinMode(ROTARY_ANGLE_SENSOR, INPUT);
  pinMode(LED,OUTPUT);   
}

void loop() {
  /*
    buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
    Serial.println("on");
  } else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
    Serial.println("off");
  }*/

      float voltage;
    int sensor_value = analogRead(ROTARY_ANGLE_SENSOR);
    voltage = (float)sensor_value*ADC_REF/1023;
    float degrees = (voltage*FULL_ANGLE)/GROVE_VCC;
    //Serial.println("The angle between the mark and the starting position:");
    //Serial.println(degrees);
    if(degrees < 100)
    {
      digitalWrite(ledPin, HIGH);
      digitalWrite(ledPin2, HIGH);
      Serial.println("on");
    }
    else
    {
      digitalWrite(ledPin, LOW);
      digitalWrite(ledPin2, LOW);
      Serial.println("off");
    }
    delay(100);
}

Clean Water AI Repo

Clean Water AI Repo

Credits

Peter Ma

Peter Ma

49 projects • 393 followers
Prototype Hacker, Hackathon Goer, World Traveler, Ecological balancer, integrationist, technologist, futurist.
Justin Shenk

Justin Shenk

3 projects • 27 followers
Machine learning and computer vision research engineer with background in neuroscience.
Shin Ae Hong

Shin Ae Hong

5 projects • 35 followers
Global Startup Incubation Specialist @Innoway
Sarah Han

Sarah Han

13 projects • 79 followers
Software Engineer, Design, 3D

Comments