nosk Wu
Published

The wooden girl in "Squid Game" actually came to my desk!!

Mugunghwa kkochi pieossseubnida - Squid Game

IntermediateFull instructions provided3 hours93
The wooden girl in "Squid Game" actually came to my desk!!

Things used in this project

Hardware components

SenseCAP K1100 - The Sensor Prototype Kit with LoRa® and AI
Seeed Studio SenseCAP K1100 - The Sensor Prototype Kit with LoRa® and AI
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Laser cutter (generic)
Laser cutter (generic)
Scissor, Electrician
Scissor, Electrician
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Code

321_wood__man.ino

C/C++
#include "Seeed_Arduino_GroveAI.h"
#include <Wire.h>
#include"TFT_eSPI.h"
#include <Servo.h>

TFT_eSPI tft;
Servo servo;
GroveAI ai(Wire);
uint8_t state = 0;

void setup(){
   Wire.begin();
  Serial.begin(115200);
 
  Serial.println("begin");
  if (ai.begin(ALGO_OBJECT_DETECTION, MODEL_EXT_INDEX_1)) // Object detection and pre-trained model 1
  {
    Serial.print("Version: ");
    Serial.println(ai.version());
    Serial.print("ID: ");
    Serial.println( ai.id());
    Serial.print("Algo: ");
    Serial.println( ai.algo());
    Serial.print("Model: ");
    Serial.println(ai.model());
    Serial.print("Confidence: ");
    Serial.println(ai.confidence());
    state = 1;
  }
  else
  {
    Serial.println("Algo begin failed.");
  }
  tft.begin();
  servo.attach(0);
  pinMode(WIO_BUZZER, OUTPUT);
  pinMode(WIO_5S_RIGHT, INPUT_PULLUP);
  tft.setRotation(3);
  tft.fillScreen(0x0);
  tft.setTextSize(4);
  tft.setTextColor(0x6FE0);
  servo.write(180);
  delay(1000);
  tft.drawString((String)"- _ -", 100, 100);
  tone(WIO_BUZZER,880);
  delay(62.5);
  noTone(WIO_BUZZER);
  tone(WIO_BUZZER,659);
  delay(62.5);
  noTone(WIO_BUZZER);
  tone(WIO_BUZZER,784);
  delay(62.5);
  noTone(WIO_BUZZER);
  delay(1000);
  servo.write(180);
  delay(1000);
  tft.fillScreen(0x0);
  tft.drawString((String)"> _ <", 100, 100);
  tft.drawString((String)"READY? RIGHT!", 10, 190);
  while(digitalRead(WIO_5S_RIGHT) == LOW == false){
  }
  tone(WIO_BUZZER,784);
  delay(62.5);
  noTone(WIO_BUZZER);
  tone(WIO_BUZZER,659);
  delay(62.5);
  noTone(WIO_BUZZER);
  tone(WIO_BUZZER,523);
  delay(62.5);
  noTone(WIO_BUZZER);


}



void loop(){


 if (state == 1)
  {
    uint32_t tick = millis();
    if (ai.invoke()) // begin invoke
    {
      while (1) // wait for invoking finished
      {
        CMD_STATE_T ret = ai.state(); 
        if (ret == CMD_STATE_IDLE)
        {
          break;
        }
        delay(20);
      }
 
     uint8_t len = ai.get_result_len(); // receive how many people detect
     if(len)
     {
       int time1 = millis() - tick; 
       Serial.print("Time consuming: ");
       Serial.println(time1);
       Serial.print("Number of people: ");
       Serial.println(len);
       object_detection_t data;       //get data
 
       for (int i = 0; i < len; i++)
       {
          Serial.println("result:detected");
          Serial.print("Detecting and calculating: ");
          Serial.println(i+1);
          ai.get_result(i, (uint8_t*)&data, sizeof(object_detection_t)); //get result
 
          Serial.print("confidence:");
          Serial.print(data.confidence);
          Serial.println();
          tft.fillScreen(0x0);
   tft.fillScreen(0x0);
  tft.drawString((String)"Q o Q", 100, 100);
  tft.drawString((String)"CATCH YOU!", 40, 190);
  tone(WIO_BUZZER,659);
  delay(125);
  noTone(WIO_BUZZER);
  tone(WIO_BUZZER,880);
  delay(125);
  noTone(WIO_BUZZER);
  tone(WIO_BUZZER,988);
  delay(125);
  noTone(WIO_BUZZER);
  delay(3000);
  servo.write(180);
  delay(3000);
        }
     }
     else
     {
       Serial.println("No identification");
  tft.fillScreen(0x0);
  tft.drawString((String)"- _ -", 100, 100);
  tft.drawString((String)"SAFE", 140, 190);
  delay(1000);
  servo.write(180);
  delay(100);
  tft.fillScreen(0x0);
  tft.drawString((String)"- _ -", 100, 100);
  delay(2000);
  tft.drawString((String)"3", 100, 190);
  tone(WIO_BUZZER,659);
  delay(250);
  noTone(WIO_BUZZER);
  tone(WIO_BUZZER,880);
  delay(250);
  noTone(WIO_BUZZER);
  tone(WIO_BUZZER,880);
  delay(500);
  noTone(WIO_BUZZER);
  delay(50);
  tft.drawString((String)"2", 150, 190);
  tone(WIO_BUZZER,880);
  delay(500);
  noTone(WIO_BUZZER);
  tone(WIO_BUZZER,784);
  delay(500);
  noTone(WIO_BUZZER);
  delay(50);
  tft.drawString((String)"1", 200, 190);
  tone(WIO_BUZZER,880);
  delay(250);
  noTone(WIO_BUZZER);
  tone(WIO_BUZZER,880);
  delay(250);
  noTone(WIO_BUZZER);
  tone(WIO_BUZZER,659);
  delay(250);
  noTone(WIO_BUZZER);
  tone(WIO_BUZZER,659);
  delay(250);
  noTone(WIO_BUZZER);
  tone(WIO_BUZZER,784);
  delay(1000);
  noTone(WIO_BUZZER);
  delay(3000);
  servo.write(0);
  delay(50);
  delay(3000);
     }
    }
    else
    {
      delay(1000);
      Serial.println("Invoke Failed.");
    }
  }
  else
  {
    state == 0;
  }

}

Credits

nosk Wu
4 projects • 3 followers

Comments