Things used in this project

Code

trashmatic.pyPython
Script which handles trashmatic on Edison. Servo connects to D5. Capacitive touch connects to D7. RGB/Prox sensor connects to I2C slot. Run on Edison, and it handles the rest.
from upm import pyupm_servo as servo
import time
from upm import pyupm_grove as grove
from upm import pyupm_i2clcd as lcd
from HTU21D_Ed import HTU21D as RGB
from subprocess import call
from upm import pyupm_i2clcd as lcd

#myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62)

recycle = 0
trash = 0
rgb = RGB(6)
touch = grove.GroveButton(7)
gServo = servo.ES08A(5)
opped = False

thingname = "edison-lightbulb"



def sendAWSData():
	payload = "\"{\\\"state\\\":{\\\"reported\\\":{\\\"recyclable\\\": " + str(recycle) + ", \\\"trash\\\": " + str(trash) + ", \\\"trashed\\\": " + str(trash + recycle) + "}}}\""
	
	shadow_command = "iot-data update-thing-shadow --thing-name " + thingname + " --payload " + payload + " output.txt"
	call("aws " + shadow_command, shell=True)

def recycleItem(recycle):
    recycle += 1
    gServo.setAngle(0)
#    myLcd.setColor(0,255,0)
    time.sleep(1)

def trashItem(trash):
    trash += 1
    gServo.setAngle(110)
#    myLcd.setColor(255,0,0)
    time.sleep(1)

rgb.initSensor()
gServo.setAngle(58)

while 1:
#        myLcd.setColor(0,0,255)
	if rgb.readUReg(0x9C) > 200:
		print("Something's in the bin!")
		time.sleep(2)
		if touch.value() == 1:
			print("Conductive material")
                        recycleItem(recycle)
                        opped = True
		a,r,g,b = rgb.color() # Checks data from sensor. a = ambient light
                if (a+r+g+b) > 2000:
                    print()
                    print("Paper!")
                    recycleItem(recycle)
                    opped = True

                if opped == False:
                    trashItem(trash)
		gServo.setAngle(58)

                opped = False

		sendAWSData()

Credits

121591c0564092035499cb0056c35fea
Douglas Jude Patz

I am a young aspiring hacker who is very into game development.

Contact

Replications

Did you replicate this project? Share it!

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Sign up / LoginProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlog