回到首页 返回首页
回到顶部 回到顶部
返回上一页 返回上一页

#智造#垃圾智能分类密码 简单

头像 huangq1228 2019.09.10 2903 2

习总书记对垃圾分类工作作出重要指示强调培养垃圾分类的好习惯,为改善生活环境作努力,为绿色发展可持续发展作贡献。实行垃圾分类,关系广大人民群众生活环境,关系节约使用资源,也是社会文明水平的一个重要体现。推行垃圾分类,关键是要加强科学管理、形成长效机制、推动习惯养成。要加强引导、因地制宜、持续推进,把工作做细做实,持之以恒抓下去。要开展广泛的教育引导工作,让广大人民群众认识到实行垃圾分类的重要性和必要性,通过有效的督促引导,让更多人行动起来,培养垃圾分类的好习惯,全社会人人动手,一起来为改善生活环境作努力,一起来为绿色发展、可持续发展作贡献。

我们小创客们用人工智能破解垃圾分类的难题,他们创作出了一款智能分类垃圾桶,他们运用“创造栗”语音识别、图像识别等人工智能相关技术,让垃圾桶实现了智能分类,让“扔垃圾”这件事不但规范化而且智能化。

材料清单

  • 人工智能主控板 X1
  • 摄像头 X1
  • 点阵屏 X1
  • LED灯 X1
  • 按钮 X1
  • 喇叭 X1
  • 塑料垃圾桶 X1
  • 雪弗板 X1
  • 舵机 X4
  • 合页 X4

步骤1 把一个塑料垃圾桶按照垃圾四分法进行隔断。

步骤2 用雪弗板进行盖板设计

步骤3 安装舵机,合页,测试盖子翻和合。

步骤4 和主控连接好舵机,摄像头,开始编制程序。

分类密码之一:智能语音分类垃圾。

分类密码之二:图像识别分类垃圾。

project-image
代码
#include <Wire.h>
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"

#include <Servo.h>

#include <Wire.h>
#include <Dino.h>

Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();
int result;

// 描述该功能...
void xiaolian() {

  matrix.setRotation(0);

  matrix.drawPixel(0, 0, LED_OFF);
  matrix.drawPixel(0, 1, LED_OFF);
  matrix.drawPixel(0, 2, LED_RED);
  matrix.drawPixel(0, 3, LED_RED);
  matrix.drawPixel(0, 4, LED_OFF);
  matrix.drawPixel(0, 5, LED_OFF);
  matrix.drawPixel(0, 6, LED_OFF);
  matrix.drawPixel(0, 7, LED_OFF);

  matrix.drawPixel(1, 0, LED_OFF);
  matrix.drawPixel(1, 1, LED_RED);
  matrix.drawPixel(1, 2, LED_RED);
  matrix.drawPixel(1, 3, LED_RED);
  matrix.drawPixel(1, 4, LED_RED);
  matrix.drawPixel(1, 5, LED_OFF);
  matrix.drawPixel(1, 6, LED_OFF);
  matrix.drawPixel(1, 7, LED_OFF);

  matrix.drawPixel(2, 0, LED_RED);
  matrix.drawPixel(2, 1, LED_RED);
  matrix.drawPixel(2, 2, LED_RED);
  matrix.drawPixel(2, 3, LED_RED);
  matrix.drawPixel(2, 4, LED_RED);
  matrix.drawPixel(2, 5, LED_RED);
  matrix.drawPixel(2, 6, LED_OFF);
  matrix.drawPixel(2, 7, LED_OFF);

  matrix.drawPixel(3, 0, LED_OFF);
  matrix.drawPixel(3, 1, LED_RED);
  matrix.drawPixel(3, 2, LED_RED);
  matrix.drawPixel(3, 3, LED_RED);
  matrix.drawPixel(3, 4, LED_RED);
  matrix.drawPixel(3, 5, LED_RED);
  matrix.drawPixel(3, 6, LED_RED);
  matrix.drawPixel(3, 7, LED_OFF);

  matrix.drawPixel(4, 0, LED_OFF);
  matrix.drawPixel(4, 1, LED_RED);
  matrix.drawPixel(4, 2, LED_RED);
  matrix.drawPixel(4, 3, LED_RED);
  matrix.drawPixel(4, 4, LED_RED);
  matrix.drawPixel(4, 5, LED_RED);
  matrix.drawPixel(4, 6, LED_RED);
  matrix.drawPixel(4, 7, LED_OFF);

  matrix.drawPixel(5, 0, LED_RED);
  matrix.drawPixel(5, 1, LED_RED);
  matrix.drawPixel(5, 2, LED_RED);
  matrix.drawPixel(5, 3, LED_RED);
  matrix.drawPixel(5, 4, LED_RED);
  matrix.drawPixel(5, 5, LED_RED);
  matrix.drawPixel(5, 6, LED_OFF);
  matrix.drawPixel(5, 7, LED_OFF);

  matrix.drawPixel(6, 0, LED_OFF);
  matrix.drawPixel(6, 1, LED_RED);
  matrix.drawPixel(6, 2, LED_RED);
  matrix.drawPixel(6, 3, LED_RED);
  matrix.drawPixel(6, 4, LED_RED);
  matrix.drawPixel(6, 5, LED_OFF);
  matrix.drawPixel(6, 6, LED_OFF);
  matrix.drawPixel(6, 7, LED_OFF);

  matrix.drawPixel(7, 0, LED_OFF);
  matrix.drawPixel(7, 1, LED_OFF);
  matrix.drawPixel(7, 2, LED_RED);
  matrix.drawPixel(7, 3, LED_RED);
  matrix.drawPixel(7, 4, LED_OFF);
  matrix.drawPixel(7, 5, LED_OFF);
  matrix.drawPixel(7, 6, LED_OFF);
  matrix.drawPixel(7, 7, LED_OFF);

  matrix.writeDisplay();
  delay(3 * 1000);

  matrix.setRotation(0);

  matrix.drawPixel(0, 0, LED_OFF);
  matrix.drawPixel(0, 1, LED_OFF);
  matrix.drawPixel(0, 2, LED_OFF);
  matrix.drawPixel(0, 3, LED_YELLOW);
  matrix.drawPixel(0, 4, LED_YELLOW);
  matrix.drawPixel(0, 5, LED_YELLOW);
  matrix.drawPixel(0, 6, LED_YELLOW);
  matrix.drawPixel(0, 7, LED_OFF);

  matrix.drawPixel(1, 0, LED_OFF);
  matrix.drawPixel(1, 1, LED_OFF);
  matrix.drawPixel(1, 2, LED_YELLOW);
  matrix.drawPixel(1, 3, LED_OFF);
  matrix.drawPixel(1, 4, LED_RED);
  matrix.drawPixel(1, 5, LED_OFF);
  matrix.drawPixel(1, 6, LED_OFF);
  matrix.drawPixel(1, 7, LED_YELLOW);

  matrix.drawPixel(2, 0, LED_OFF);
  matrix.drawPixel(2, 1, LED_YELLOW);
  matrix.drawPixel(2, 2, LED_OFF);
  matrix.drawPixel(2, 3, LED_RED);
  matrix.drawPixel(2, 4, LED_RED);
  matrix.drawPixel(2, 5, LED_RED);
  matrix.drawPixel(2, 6, LED_OFF);
  matrix.drawPixel(2, 7, LED_YELLOW);

  matrix.drawPixel(3, 0, LED_YELLOW);
  matrix.drawPixel(3, 1, LED_OFF);
  matrix.drawPixel(3, 2, LED_OFF);
  matrix.drawPixel(3, 3, LED_OFF);
  matrix.drawPixel(3, 4, LED_RED);
  matrix.drawPixel(3, 5, LED_OFF);
  matrix.drawPixel(3, 6, LED_OFF);
  matrix.drawPixel(3, 7, LED_YELLOW);

  matrix.drawPixel(4, 0, LED_YELLOW);
  matrix.drawPixel(4, 1, LED_OFF);
  matrix.drawPixel(4, 2, LED_OFF);
  matrix.drawPixel(4, 3, LED_OFF);
  matrix.drawPixel(4, 4, LED_OFF);
  matrix.drawPixel(4, 5, LED_OFF);
  matrix.drawPixel(4, 6, LED_OFF);
  matrix.drawPixel(4, 7, LED_YELLOW);

  matrix.drawPixel(5, 0, LED_OFF);
  matrix.drawPixel(5, 1, LED_YELLOW);
  matrix.drawPixel(5, 2, LED_OFF);
  matrix.drawPixel(5, 3, LED_OFF);
  matrix.drawPixel(5, 4, LED_RED);
  matrix.drawPixel(5, 5, LED_OFF);
  matrix.drawPixel(5, 6, LED_OFF);
  matrix.drawPixel(5, 7, LED_YELLOW);

  matrix.drawPixel(6, 0, LED_OFF);
  matrix.drawPixel(6, 1, LED_OFF);
  matrix.drawPixel(6, 2, LED_YELLOW);
  matrix.drawPixel(6, 3, LED_OFF);
  matrix.drawPixel(6, 4, LED_RED);
  matrix.drawPixel(6, 5, LED_OFF);
  matrix.drawPixel(6, 6, LED_YELLOW);
  matrix.drawPixel(6, 7, LED_YELLOW);

  matrix.drawPixel(7, 0, LED_OFF);
  matrix.drawPixel(7, 1, LED_OFF);
  matrix.drawPixel(7, 2, LED_OFF);
  matrix.drawPixel(7, 3, LED_YELLOW);
  matrix.drawPixel(7, 4, LED_YELLOW);
  matrix.drawPixel(7, 5, LED_YELLOW);
  matrix.drawPixel(7, 6, LED_YELLOW);
  matrix.drawPixel(7, 7, LED_OFF);

  matrix.writeDisplay();
}

Servo servo_4;

Servo servo_5;

Servo servo_6;

Servo servo_7;

// 描述该功能...
void duoji() {
  servo_4.write(90);
  servo_5.write(90);
  servo_6.write(90);
  servo_7.write(90);
}

Dino ai;

void setup()
{
  matrix.begin(0x70);

  servo_4.attach(4);

  servo_5.attach(5);

  servo_6.attach(6);

  servo_7.attach(7);

  Wire.begin();

  pinMode(9, OUTPUT);
  result = 0;
  duoji();
  ai.init();
  ai.language("zh_CN");
  ai.name("绿宝");
  ai.add_sentence("你好", 1);
  ai.add_sentence("谢谢", 2);
  ai.add_sentence("再见", 3);
  ai.add_sentence("开灯", 4);
  ai.add_sentence("关灯", 5);
  ai.add_sentence("垃圾分类", 6);
  ai.add_sentence("唱歌", 7);
  ai.add_sentence("分类儿歌", 8);
  ai.add_sentence("荧光灯管", 9);
  ai.add_sentence("饮料瓶", 10);
  ai.add_sentence("菜根菜叶", 11);
  ai.add_sentence("砖瓦陶瓷", 12);
  ai.add_sentence("唱歌", 13);
  ai.generate_acoustic_models();
  ai.generate_pronunciation_dictionary();
  ai.generate_language_models();
  ai.generate_decoder();
  ai.sensitivity(255);
  ai.playbackVolume(255);
  ai.captureVolume(255);
  ai.listen();
  ai.speak("大家好,我是绿宝智能分类垃圾桶,很高兴为您服务。");
}


void loop()
{
  if (ai.is_speaking()) {
    ai.extract_features();
    ai.decode(
      ai.acoustic_models,
      ai.pronunciation_dictionary,
      ai.language_models);
  }
  result = ai.poll();
  switch (result) {
   case 1:
    ai.speak("您好,我是绿宝,绿色环保,从我做起,很高兴为您服务。");
    break;
   case 2:
    ai.speak("这是我应该做的。不用客气。");
    break;
   case 3:
    ai.speak("期待下次见面。再见。");
    break;
   case 4:
    digitalWrite(9, HIGH);
    break;
   case 5:
    digitalWrite(9, LOW);
    break;
   case 6:
    ai.playbackVolume(0);
    ai.shell("look");
    delay(100);
    ai.playbackVolume(255);
    break;
   case 7:
    ai.play("/SD/1.mp3");
    delay(100);
    break;
   case 8:
    ai.speak("小朋友,讲文明,垃圾分类要分清。");
    ai.speak("剩饭剩菜瓜果皮,厨余垃圾放绿桶。");
    ai.speak("金属纸盒饮料瓶,可回收物放蓝桶。");
    ai.speak("电池农药杀虫剂,有害垃圾放红桶。");
    ai.speak("毛发陶瓷打火机,其他垃圾放灰桶。");
    ai.speak("垃圾分类我做起,节约资源废变宝。");
    delay(100);
    break;
   case 1113:
    ai.speak("这是香蕉皮,是厨余垃圾。");
    break;
   case 1108:
    ai.speak("这是变质苹果,是厨余垃圾。");
    break;
   case 1002:
    ai.speak("这是企鹅,不是垃圾!");
    break;
   case 9:
    servo_4.write(0);
    ai.speak("荧光灯管是有害垃圾!");
    xiaolian();
    servo_4.write(90);
    break;
   case 10:
    servo_5.write(0);
    ai.speak("饮料瓶是可回收物!");
    xiaolian();
    servo_5.write(90);
    break;
   case 11:
    servo_6.write(0);
    ai.speak("菜根菜叶是厨余垃圾!");
    xiaolian();
    servo_6.write(90);
    break;
   case 12:
    servo_7.write(0);
    ai.speak("砖瓦陶瓷是其他垃圾!");
    xiaolian();
    servo_7.write(90);
    break;
  }
  delay(80);

}

评论

user-avatar
  • 王张御

    王张御2022.06.16

    噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩噩

    0
    • 舵机缔造

      舵机缔造2021.12.30

      大家好! 我这边是专门做舵机的,工业/机器人,玩具型号都有,有需要的朋友可以加我微信了解13202713017

      0