Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Ryan D'Costa
Published

Intelligent Trash Can

This is a trash can, specially for glass and plastic bottles, which actually pays you to throw your trash in them!

AdvancedFull instructions provided3 hours1,030
Intelligent Trash Can

Things used in this project

Hardware components

Proximity Sensor
Proximity Sensor
×1
Photo resistor
Photo resistor
×1
Resistor (generic)
×1

Story

Read more

Schematics

schematic_GIujJeQu7k.png

Code

FCZ66ZQIMRYHNOB.txt

HTML
<html>
<head>
<title>This is a noble cause</title>
</head>
<body>
<p id = "demo"> </p>
<p id = "rahul"> </p>
<p id = "result"> </p>
<form>
<span id="demo">Phone Number</span>
<input type="text">
</form>
<button type="get" Onclick="proximity()">Check!</button>

<script>

function proximity() {
  var xhttp = new XMLHttpRequest();	
  xhttp.onreadystatechange = function() {
    
    if (xhttp.readyState == 4 && xhttp.status == 200) {
      alert(xhttp.responseText);
	document.getElementById("demo").innerHTML = xhttp.responseText;
	var prox = document.getElementById("demo").innerHTML;	
	if(prox == "{\"success\":\"1\",\"value\":\"0\"}")
	{	
	alert("in if");	
	readldr();  }  
	else {
	alert("in else");
	alert("Your trash should only consist of bottles!");
	}	
}
    
  };
  xhttp.open("GET", "/digitalRead?pin=4", true);
  xhttp.send();

}
function readldr() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
 
   if (xhttp.readyState == 4 && xhttp.status == 200) {
      alert(xhttp.responseText);
	document.getElementById("rahul").innerHTML = xhttp.responseText;
	var irs = document.getElementById("rahul").innerHTML;
	if(irs == "{\"success\":\"1\",\"value\":\"0\"}"){	
	alert("Your Account has been recharged!");
	}	
	else{
	alert("Your trash should only consist of bottles in the ldr part!");
	}

}	
  };
  xhttp.open("GET","/digitalRead?pin=A0", true);
  xhttp.send();

}
</script>
</body>
</html>

Credits

rkhamkar1977

Posted by Ryan D'Costa

Comments

Please log in or sign up to comment.