Sylvia
Published © CC BY-ND

SBox - My Fat-Killer machine

As a lady who always look to keep fit, do you want a machine to help you to maintain your discipline to sugars? SBox is here!

BeginnerFull instructions provided5 hours134
SBox - My Fat-Killer machine

Things used in this project

Hardware components

Wio Terminal
Seeed Studio Wio Terminal
×1
Grove - Ultrasonic Ranger
Seeed Studio Grove - Ultrasonic Ranger
×1
Seeed Studio wio terminal chasis - battery
make wio terminal to be a stand-alone running device
×1
Storage Box
for stocking snacks
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

CONNECTION

Code

Arduino codes

C/C++
#include"TFT_eSPI.h"
#include "Ultrasonic.h"
#include"Seeed_FS.h"
#include"RawImage.h"

TFT_eSPI tft;
Ultrasonic ult(0);
int QTY = 3;

void setup(){
  tft.begin();
   if (!SD.begin(SDCARD_SS_PIN, SDCARD_SPI)) {
        while (1);
    }
  tft.setFreeFont(&FreeSansBoldOblique9pt7b);
  pinMode(WIO_BUZZER, OUTPUT);
  tft.setRotation(3);
  tft.fillScreen(0x8228);
  tft.setTextSize(1);
  tft.setTextColor(0xFFFF);
  tft.drawString("Today",140,80);
  tft.drawString("You have 3 times to get your snacks",3,110);
  Serial.begin(9600); //Serial monitor
}

void loop()
{
  long Distance = ult.MeasureInCentimeters();

  if ((Distance < 20) && (QTY >0))
  {
    QTY = (QTY - 1);
    tft.fillScreen(0x8208);
    tft.setFreeFont(&FreeSansBoldOblique12pt7b);
    tft.drawString("You still left",85,80);
    tft.drawString(String(QTY),160,100);
    tft.drawString("times to take your snacks",10,120);
    Serial.print("Acitvated and QTY = "); //Serial monitor
    Serial.println(QTY); //Serial monitor
    delay(5000);
  }
  else if ((Distance < 20)&&(QTY == 0))
  {
      Serial.print("Acitvated and QTY = "); //Serial monitor
      Serial.println(QTY);  //Serial monitor
      tft.fillScreen(0x81C7);
      tft.setFreeFont(&FreeSansBoldOblique9pt7b);
      tft.drawString((String)"All used up today,see you tomorrow",5, 100);
      tone(WIO_BUZZER,587);
      delay(1000);
      drawImage<uint8_t>("fat.bmp", 0,0);
      delay(1500);
      noTone(WIO_BUZZER);
      Serial.println("bye bye"); //Serial monitor
      exit(0);
  }
  else
  {
    Serial.print("Distance to me now: ");//Serial monitor
    Serial.print(Distance);//Serial monitor
    Serial.println(" cm");//Serial monitor
    delay(250); //Serial monitor
  }
}

Credits

Sylvia
1 project • 2 followers
Contact

Comments

Please log in or sign up to comment.