kawi
Published

AI Girl Door Light Box

AI Girl Door Light Box

IntermediateFull instructions provided1 hour140
AI Girl Door Light Box

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
Seeed Studio Grove - Universal 4 Pin Buckled 5cm Cable (5 PCs Pack)
Seeed Studio Grove - Universal 4 Pin Buckled 5cm Cable (5 PCs Pack)
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1

Software apps and online services

Arduino IDE
Arduino IDE
Procreate

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

AI Light Box

C/C++
#include "Seeed_Arduino_GroveAI.h"
#include <Wire.h>
#include"TFT_eSPI.h"
#include"Seeed_FS.h"
#include"RawImage.h"
#include <Adafruit_NeoPixel.h>
TFT_eSPI tft;
Adafruit_NeoPixel pixels_1 = Adafruit_NeoPixel(250, 1, NEO_GRB + NEO_KHZ800);
 
GroveAI ai(Wire);
uint8_t state = 0;
void setup()
{
    tft.begin();
   if (!SD.begin(SDCARD_SS_PIN, SDCARD_SPI)) {
        while (1);
    }
  tft.setRotation(3);
  pixels_1.setBrightness(255);
pixels_1.begin();

pixels_1.setPixelColor(0, pixels_1.Color(20, 20, 20));
pixels_1.setPixelColor(1, pixels_1.Color(20, 20, 20));
pixels_1.setPixelColor(2, pixels_1.Color(20, 20, 20));
pixels_1.setPixelColor(3, pixels_1.Color(20, 20, 20));
pixels_1.setPixelColor(4, pixels_1.Color(20, 20, 20));
pixels_1.setPixelColor(5, pixels_1.Color(20, 20, 20));
pixels_1.setPixelColor(6, pixels_1.Color(20, 20, 20));
pixels_1.setPixelColor(7, pixels_1.Color(20, 20, 20));

pixels_1.show();

  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.");
  }
}
 
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();
          pixels_1.setBrightness(255);
pixels_1.begin();

pixels_1.setPixelColor(0, pixels_1.Color(200, 200, 200));
pixels_1.setPixelColor(1, pixels_1.Color(200, 200, 200));
pixels_1.setPixelColor(2, pixels_1.Color(200, 200, 200));
pixels_1.setPixelColor(3, pixels_1.Color(200, 200, 200));
pixels_1.setPixelColor(4, pixels_1.Color(200, 200, 200));
pixels_1.setPixelColor(5, pixels_1.Color(200, 200, 200));
pixels_1.setPixelColor(6, pixels_1.Color(200, 200, 200));
pixels_1.setPixelColor(7, pixels_1.Color(200, 200, 200));

pixels_1.show();
drawImage<uint8_t>("1.bmp", 0,0);
  tone(WIO_BUZZER,262);
  delay(250);
  noTone(WIO_BUZZER);
  tone(WIO_BUZZER,330);
  delay(250);
  noTone(WIO_BUZZER);
  tone(WIO_BUZZER,392);
  delay(250);
  noTone(WIO_BUZZER);
  delay(1000);

        }
     }
     else
     {
       Serial.println("No identification");
pixels_1.setPixelColor(0, pixels_1.Color(1, 10, 20));
pixels_1.setPixelColor(1, pixels_1.Color(1, 10, 20));
pixels_1.setPixelColor(2, pixels_1.Color(1, 10, 20));
pixels_1.setPixelColor(3, pixels_1.Color(1, 10, 20));
pixels_1.setPixelColor(4, pixels_1.Color(1, 10, 20));
pixels_1.setPixelColor(5, pixels_1.Color(1, 10, 20));
pixels_1.setPixelColor(6, pixels_1.Color(1, 10, 20));
pixels_1.setPixelColor(7, pixels_1.Color(1, 10, 20));

pixels_1.show();
  drawImage<uint8_t>("2.bmp", 0,0);
  delay(1000);

     }
    }
    else
    {
      delay(1000);
      Serial.println("Invoke Failed.");
    }
  }
  else
  {
    state == 0;
  }
}

Credits

kawi

kawi

0 projects • 0 followers

Comments