Maaz SyedBrian TressAli Mohamed Hussein
Published

The Tweeting Trash Can

Make throwing out trash fun! The tweeting trash can keeps track of your points for throwing away garbage! Leader-boards soon available.

IntermediateWork in progress10 hours38
The Tweeting Trash Can

Schematics

IMG_20160806_163511.jpg

IMG_20160806_163559.jpg

screenshots.png

Code

Tweeting Trash BIn

Arduino
// Including wifi and internet connectivity libraries
#include <Dhcp.h>
#include <Dns.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>

#include <SPI.h>
#include <Ethernet.h>

#include <Twitter.h>

//defines the pin connections
int GroundPin= A0;
int LEDPin= 4;
int count = 0;
int score = 0;

//defines normal and threshold voltage levels
int threshold= 500;

//sets GroundPin and LEDPin as output pins, with GroundPin being set to LOW
void setup()
{
Serial.begin(9600);
pinMode(GroundPin, OUTPUT);
digitalWrite(GroundPin, LOW);
pinMode(LEDPin, OUTPUT);
}

//if the reading is higher than the threshold value, then the LED is turned on
void loop()
{
int reading= analogRead(GroundPin);
Serial.println(reading);
if (reading > threshold)
{
  count=count ++;
digitalWrite(LEDPin, HIGH);
delay(1000);
digitalWrite(LEDPin, LOW);
tweetMessage(count);
}}

void tweetMessage(int count) {
  Twitter twitter("Your Twitter Token Here");
if (count >= 5)
{
  score = score ++;
  String stringMsg = "I'm Full! - Temperature Reading: ";
    stringMsg += analogRead(A1);
    stringMsg += " Score: " + score;

    //Convert String to Char for posting on twitter
    char msg[140];
    stringMsg.toCharArray(msg, 140);


    twitter.post(msg);
    count = 0;
}
else
{
   String stringMsg = "Temperature Reading: ";
    stringMsg += analogRead(A1);
    stringMsg += "Score: " + score;
    
   //Convert String to Char for posting on twitter
    char msg[140];
    stringMsg.toCharArray(msg, 140);
    twitter.post(msg);
}
}

Credits

Maaz Syed

Maaz Syed

2 projects • 3 followers
Brian Tress

Brian Tress

3 projects • 2 followers
Ali Mohamed Hussein

Ali Mohamed Hussein

2 projects • 2 followers
Ever since I was a child, I've always wanted to make the games I played on my Playstation and on my PC.

Comments