26浏览
查看: 26|回复: 9

[项目] 【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛

[复制链接]
Arduino是一个开放源码的电子原型平台,它可以让你用简单的硬件和软件来创建各种互动的项目。Arduino的核心是一个微控制器板,它可以通过一系列的引脚来连接各种传感器、执行器、显示器等外部设备。Arduino的编程是基于C/C++语言的,你可以使用Arduino IDE(集成开发环境)来编写、编译和上传代码到Arduino板上。Arduino还有一个丰富的库和社区,你可以利用它们来扩展Arduino的功能和学习Arduino的知识。

Arduino的特点是:
1、开放源码:Arduino的硬件和软件都是开放源码的,你可以自由地修改、复制和分享它们。
2、易用:Arduino的硬件和软件都是为初学者和非专业人士设计的,你可以轻松地上手和使用它们。
3、便宜:Arduino的硬件和软件都是非常经济的,你可以用很低的成本来实现你的想法。
4、多样:Arduino有多种型号和版本,你可以根据你的需要和喜好来选择合适的Arduino板。
5、创新:Arduino可以让你用电子的方式来表达你的创意和想象,你可以用Arduino来制作各种有趣和有用的项目,如机器人、智能家居、艺术装置等。

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛图1

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛图2

驴友花雕  中级技神
 楼主|

发表于 12 小时前

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛

我从来没有养过 Tamagotchi,一种小电子宠物,当它们在 80 年代后期问世时。老实说,图形相当粗糙,纽扣电池过去和现在都是一个环境问题。

但今天你可以做得更好。不是为了你的口袋,而是为了你的桌面。一头可爱的奶牛并没有错。

因此,让我们在谷仓中建造一头奶牛,您可以喂养和抚摸它(我们将跳过谷仓的清洁工作)。

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛图1

回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 12 小时前

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛

用品与材料

• ESP32 CYD (便宜的黄色显示器) (2432S028R)
• 合适的电源 / 移动电源
• 3D 打印部件。或一些用于谷仓的木材

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛图1

• 木材 / 胶合板和颜色
• Arduino IDE 软件
(需要具备 Arduino 的基本经验)

回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 12 小时前

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛

第 1 步:奶牛图形

对于我们的奶牛,我们需要一个带有饲喂站和水槽的舞台/谷仓,每个平台都显示不同的高度。
奶牛应该
• 站着, 微笑, 咀嚼, 看起来悲伤
• 吃、喝
• 躺下反刍, 微笑, 睡觉
这些图像作为代码存储在名为 “cow-all.h” 的额外文件中,并在需要时加载。
这些图像是自制的,您可以自由使用它们。

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛图1

回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 11 小时前

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛

第 2 步:Cow 软件

CYD 是 ESP32 和 Touchschreeen 的完美结合。它为您省去了烦人的焊接和电缆。
诚然,我的编程有点业余。您当然可以从 CYD 的设计方面获得更多收益或为奶牛提供更多功能。但至少程序步骤很容易遵循。

该库可用于模拟各种工作表面。我们不展示背景,而是专注于奶牛、饮水处和饲养处。三个点击区域以隐藏的方式集成在一起,即它们不可见,但可以在三个地方点击:用于补充的水和饲料位置以及用于抚摸的奶牛本身。
奶牛的状态(很快)保存在 ESP32 上,以便随时关闭设备,并保持食物/情绪状态。

饥饿和口渴的值随机变化。ESP32 对毫秒数进行计数。这些值可以根据您的个人喜好进行设置。
文件 “cow-all.h” 在代码中包含了所有不同的奶牛图像,并且必须与 “demo.ino” 或 “tamagotchi_cow.ino” 存储在同一个文件夹中!

cow-all.h
演示.ino

  1. #include <Arduino.h>
  2. #include <SPI.h>
  3. #include <TFT_eSPI.h>
  4. #include <XPT2046_Touchscreen.h>
  5. TFT_eSPI tft = TFT_eSPI();
  6. // touchscreen pins
  7. #define XPT2046_IRQ 36  // T_IRQ
  8. #define XPT2046_MOSI 32 // T_DIN
  9. #define XPT2046_MISO 39 // T_OUT
  10. #define XPT2046_CLK 25  // T_CLK
  11. #define XPT2046_CS 33   // T_CS
  12. SPIClass touchscreenSPI = SPIClass(VSPI);
  13. XPT2046_Touchscreen touchscreen(XPT2046_CS, XPT2046_IRQ);
  14. #define SCREEN_WIDTH 320
  15. #define SCREEN_HEIGHT 240
  16. #define FONT_SIZE 2
  17. #include "cow-all.h"
  18. // extra colors
  19. #define NAVY tft.color565(0,0,160)   
  20. #define DODGERBLUE tft.color565(30,144,255)
  21. #define TURQUOISE tft.color565(64,224,208)
  22. #define CYAN tft.color565(0,255,255)  
  23. #define GOLD tft.color565(255,215,0)
  24. #define ORANGE tft.color565(255,165,0)
  25. #define RED tft.color565(255,10,0)
  26. #define MAROON tft.color565(123,0,0)
  27. #define BROWN tft.color565(150,75,0)
  28. // Global Variables
  29. int x, y, z;     // touchscreen coordinates + pressure
  30. // Set X and Y coordinates for center of display
  31. int centerX, centerY;
  32. //moodmeter & cow
  33. uint32_t moodcolor;
  34. int food, water, mood, mooddegree, waterlevel, foodlevel;
  35. int cowX,cowY;
  36. uint32_t cowImage;
  37. int saturation, thirst;
  38. int flag;
  39. void drawStable() {
  40.   //tft.drawRect(260, 10, 50, 14, TFT_RED);         //status
  41.   tft.fillRoundRect(10, 80, 30, 70, 3, GOLD );          //food   TFT_DARKGREEN
  42.   tft.fillRoundRect(10, 140, 50, 10, 5, TFT_DARKGREEN); //food
  43.   tft.fillRoundRect(290, 80, 16, 60, 5, DODGERBLUE);  //water
  44.   tft.drawRoundRect(290, 80, 16, 60, 5, TFT_WHITE);  //water
  45.   tft.drawRoundRect(280, 138, 26, 2, 2, TFT_WHITE);  //water
  46. }
  47. void setup()
  48. {
  49.   Serial.begin(115200);
  50.   // init RGB LED
  51.   pinMode(4, OUTPUT); pinMode(16, OUTPUT); pinMode(17, OUTPUT);
  52.   // turn off LED
  53.   digitalWrite(4, HIGH); digitalWrite(16, HIGH); digitalWrite(17, HIGH);
  54.   // Start the SPI for the touchscreen and init the touchscreen
  55.   touchscreenSPI.begin(XPT2046_CLK, XPT2046_MISO, XPT2046_MOSI, XPT2046_CS);
  56.   touchscreen.begin(touchscreenSPI);
  57.   touchscreen.setRotation(3);
  58.   // start display
  59.   tft.init();
  60.   tft.setRotation(3); // may be altered
  61.   tft.fillScreen(TFT_BLACK);
  62.   tft.setTextColor(TFT_WHITE, TFT_BLACK);
  63.   // Set X and Y coordinates for center of display
  64.   centerX = SCREEN_WIDTH / 2;
  65.   centerY = SCREEN_HEIGHT / 2;
  66.   tft.drawCentreString("Welcome to my stable", centerX, 30, FONT_SIZE);
  67.   int x = (tft.width() - 116) / 2;
  68.   int y = (tft.height() - 110) / 2;
  69. food=60;
  70. saturation = 90;
  71. water= 80;
  72.   //clear cow area
  73.   tft.fillRect(40, 70, 249, 170, TFT_BLACK);
  74.   // draw cow
  75.   //tft.drawBitmap(40, 80, cow_well, 160, 140, TFT_WHITE);
  76.   //tft.drawBitmap(45, 80, cow_eat, 160, 142, TFT_WHITE);
  77.   tft.drawBitmap(70, 80, cow_neutral, 160, 147, TFT_WHITE);
  78.   delay(2000);
  79.   tft.fillRect(50, 0, 200, 50, TFT_BLACK); //clear area
  80. }
  81. void loop()  {
  82.   // Checks if Touchscreen is touched
  83.   if (touchscreen.tirqTouched() && touchscreen.touched()) {
  84.     // Get Touchscreen points
  85.     TS_Point p = touchscreen.getPoint();
  86.     // Calibrate Touchscreen points with map function to the correct width and height
  87.     x = map(p.x, 200, 3700, 1, SCREEN_WIDTH);
  88.     y = map(p.y, 240, 3800, 1, SCREEN_HEIGHT);
  89.     z = p.z;
  90.     printTouchToSerial(x, y, z);
  91.       
  92.     //food touch
  93.     if ((x>5)&&(x<60)&&(y>70)&&(y<160)) food=food+20;
  94.     if (food>=100) food=100;
  95.     //water touch
  96.     if ((x>270)&&(x<315)&&(y>60)&&(y<155)) water=water+20;
  97.     if (water>=100) water=100;
  98.    
  99.     cowX=50; cowY = 80; //start coordinates of cow bmp
  100.     //cow touch
  101.     if ((x>cowX)&&(x<cowX+150)&&(y>cowY)&&(y<cowY+130)) mood=mood+20;
  102.     if (mood>=100) mood=100;
  103.     Serial.print(food); Serial.print("  "); Serial.print(water);  Serial.print("  "); Serial.println(mood);
  104.     delay(80);
  105.   }
  106.   moodmeter(mood);
  107.   waterfill(water);
  108.   foodfill(food);
  109. /*
  110.   //  food /water levels ********************
  111.   if (cowImage = cow_eat) {
  112.     food--;
  113.     saturation = saturation + 6;
  114.    
  115.   }
  116.   if (cowImage = cow_drink) {
  117.     water--;
  118.     thirst = thirst -7;
  119.   }
  120.   //hunger/thirst comes up  *******************
  121.   if (millisnow - millispast = random(480000, 900000)) {  //8-15 minutes
  122.     saturation = saturation-3;
  123.     thirst = thirst + 2;
  124.     if (saturation<=0) saturation=0;
  125.     if (thirst<=0) thirst=0;
  126.   }
  127.   */
  128.   food=food - 0.5; water=water -0.5; mood=mood-0.5;
  129.   if (food<=0) food=0;
  130.   if (water<=0) water=0;
  131.   if (mood<=0) mood=0;
  132.   if ((mood> 70) && (flag!=1)) {
  133.     tft.fillRect(54, 70, 220, 170, TFT_BLACK); //clear cow area
  134.     tft.drawBitmap(70, 80, cow_smile2, 160, 147, TFT_WHITE);// draw cow
  135.     flag = 1;
  136.   }
  137.   if ((mood<= 70) && (mood > 30) && (flag!=2)) {
  138.     tft.fillRect(54, 70, 220, 170, TFT_BLACK); //clear cow area
  139.     tft.drawBitmap(70, 80, cow_neutral, 160, 147, TFT_WHITE);// draw cow
  140.     flag = 2;
  141.   }
  142.   if ((mood<=30) && (flag !=3)) {
  143.     tft.fillRect(54, 70, 220, 170, TFT_BLACK); //clear cow area
  144.     tft.drawBitmap(70, 80, cow_sad, 160, 145, TFT_WHITE);// draw cow
  145.     flag = 3;
  146.   }
  147.   delay(300);
  148. }
  149. void waterfill(int water) {
  150.   tft.fillRoundRect(290, 80, 16, 60, 5, TFT_BLACK); //clear area
  151.   waterlevel = map(water, 0, 100, 140, 80);
  152.   tft.fillRect(290, waterlevel, 16, (140-waterlevel), DODGERBLUE);  //water
  153.   tft.drawRoundRect(289, 79, 18, 62, 5, TFT_WHITE);  //water frame
  154.   tft.drawRoundRect(275, 138, 26, 3, 1, TFT_WHITE);  //water
  155. }
  156. void foodfill(int food) {
  157.   tft.fillRoundRect(10, 80, 40, 70, 5, TFT_BLACK); //clear area
  158.   foodlevel = map(food, 0, 100, 150 , 80);
  159.   tft.drawRoundRect(9, 79, 42, 72, 3, BROWN);     //food frame
  160.   tft.fillRoundRect(10, foodlevel, 40, (150-foodlevel), 3, TFT_DARKGREEN);   //food   
  161.   tft.fillTriangle(9, 150, 10, 157, 62, 150, BROWN);    //feeding dish
  162. }
  163. void moodmeter(int mood) {
  164.   tft.fillRect(0, 0, 43, 43, TFT_BLACK); //clear area
  165.   mooddegree = map(mood, 0, 100, 1, 360);
  166.   if (mood < 15) moodcolor = RED;
  167.   if ((mood >= 15) && (mood < 30)) moodcolor = ORANGE;
  168.   if ((mood >= 30) && (mood < 60)) moodcolor = GOLD;
  169.   if (mood >= 60) moodcolor = TFT_DARKGREEN;
  170.   tft.drawSmoothArc(22, 22, 20, 8, 0, mooddegree, moodcolor, TFT_BLACK);
  171. }
  172. void printTouchToSerial(int x, int y, int z) {
  173.   Serial.print("X = ");
  174.   Serial.print(x);
  175.   Serial.print(" | Y = ");
  176.   Serial.print(y);
  177.   Serial.print(" | Pressure = ");
  178.   Serial.print(z);
  179.   Serial.println();
  180. }
复制代码





回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 11 小时前

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛

tamagotchi_cow.ino

  1. #include <Arduino.h>
  2. #include <SPI.h>
  3. #include <TFT_eSPI.h>
  4. #include <XPT2046_Touchscreen.h>
  5. TFT_eSPI tft = TFT_eSPI();
  6. // touchscreen pins
  7. #define XPT2046_IRQ 36  // T_IRQ
  8. #define XPT2046_MOSI 32 // T_DIN
  9. #define XPT2046_MISO 39 // T_OUT
  10. #define XPT2046_CLK 25  // T_CLK
  11. #define XPT2046_CS 33   // T_CS
  12. SPIClass touchscreenSPI = SPIClass(VSPI);
  13. XPT2046_Touchscreen touchscreen(XPT2046_CS, XPT2046_IRQ);
  14. #define SCREEN_WIDTH 320
  15. #define SCREEN_HEIGHT 240
  16. #define FONT_SIZE 2
  17. #include "cow-all.h"
  18. // extra colors
  19. #define NAVY tft.color565(0,0,160)   
  20. #define DODGERBLUE tft.color565(30,144,255)
  21. #define TURQUOISE tft.color565(64,224,208)
  22. #define CYAN tft.color565(0,255,255)  
  23. #define GOLD tft.color565(255,215,0)
  24. #define ORANGE tft.color565(255,165,0)
  25. #define RED tft.color565(255,10,0)
  26. #define MAROON tft.color565(123,0,0)
  27. #define BROWN tft.color565(150,75,0)
  28. // Global Variables
  29. int x, y, z;     // touchscreen coordinates + pressure
  30. // Set X and Y coordinates for center of display
  31. int centerX, centerY;
  32. //moodmeter & cow
  33. uint32_t moodcolor;
  34. int food, water, mood, mooddegree, waterlevel, foodlevel;
  35. int cowX,cowY;
  36. uint32_t cowImage;
  37. int saturation, thirst;
  38. void drawStable() {
  39.   //tft.drawRect(260, 10, 50, 14, TFT_RED);         //status
  40.   tft.fillRoundRect(10, 80, 30, 70, 3, GOLD );          //food   TFT_DARKGREEN
  41.   tft.fillRoundRect(10, 140, 50, 10, 5, TFT_DARKGREEN); //food
  42.   tft.fillRoundRect(290, 80, 16, 60, 5, DODGERBLUE);  //water
  43.   tft.drawRoundRect(290, 80, 16, 60, 5, TFT_WHITE);  //water
  44.   tft.drawRoundRect(280, 138, 26, 2, 2, TFT_WHITE);  //water
  45. }
  46. void setup()
  47. {
  48.   Serial.begin(115200);
  49.   // init RGB LED
  50.   pinMode(4, OUTPUT); pinMode(16, OUTPUT); pinMode(17, OUTPUT);
  51.   // turn off LED
  52.   digitalWrite(4, HIGH); digitalWrite(16, HIGH); digitalWrite(17, HIGH);
  53.   // Start the SPI for the touchscreen and init the touchscreen
  54.   touchscreenSPI.begin(XPT2046_CLK, XPT2046_MISO, XPT2046_MOSI, XPT2046_CS);
  55.   touchscreen.begin(touchscreenSPI);
  56.   touchscreen.setRotation(3);
  57.   // start display
  58.   tft.init();
  59.   tft.setRotation(3); // may be altered
  60.   tft.fillScreen(TFT_BLACK);
  61.   tft.setTextColor(TFT_WHITE, TFT_BLACK);
  62.   // Set X and Y coordinates for center of display
  63.   centerX = SCREEN_WIDTH / 2;
  64.   centerY = SCREEN_HEIGHT / 2;
  65.   tft.drawCentreString("Welcome to my stable", centerX, 30, FONT_SIZE);
  66.   int x = (tft.width() - 116) / 2;
  67.   int y = (tft.height() - 110) / 2;
  68. food=60;
  69. saturation = 90;
  70. water= 80;
  71.   //clear cow area
  72.   tft.fillRect(40, 70, 249, 170, TFT_BLACK);
  73.   // draw cow
  74.   //tft.drawBitmap(40, 80, cow_well, 160, 140, TFT_WHITE);
  75.   //tft.drawBitmap(45, 80, cow_eat, 160, 142, TFT_WHITE);
  76.   tft.drawBitmap(70, 80, cow_smile, 160, 145, TFT_WHITE);
  77.   delay(2000);
  78.   tft.fillRect(50, 0, 200, 50, TFT_BLACK); //clear area
  79. }
  80. void loop()  {
  81.   // Checks if Touchscreen is touched
  82.   if (touchscreen.tirqTouched() && touchscreen.touched()) {
  83.     // Get Touchscreen points
  84.     TS_Point p = touchscreen.getPoint();
  85.     // Calibrate Touchscreen points with map function to the correct width and height
  86.     x = map(p.x, 200, 3700, 1, SCREEN_WIDTH);
  87.     y = map(p.y, 240, 3800, 1, SCREEN_HEIGHT);
  88.     z = p.z;
  89.     printTouchToSerial(x, y, z);
  90.       
  91.     //food touch
  92.     if ((x>5)&&(x<60)&&(y>70)&&(y<160)) food=food+20;
  93.     if (food>=100) food=100;
  94.     //water touch
  95.     if ((x>270)&&(x<315)&&(y>60)&&(y<155)) water=water+20;
  96.     if (water>=100) water=100;
  97.    
  98.     cowX=50; cowY = 80; //start coordinates of cow bmp
  99.     //cow touch
  100.     if ((x>cowX)&&(x<cowX+150)&&(y>cowY)&&(y<cowY+130)) mood=mood+20;
  101.     if (mood>=100) mood=100;
  102.     Serial.print(food); Serial.print("  "); Serial.print(water);  Serial.print("  "); Serial.println(mood);
  103.     delay(80);
  104.   }
  105.   moodmeter(mood);
  106.   waterfill(water);
  107.   foodfill(food);
  108. /*
  109.   //  food /water levels ********************
  110.   if (cowImage = cow_eat) {
  111.     food--;
  112.     saturation = saturation + 6;
  113.    
  114.   }
  115.   if (cowImage = cow_drink) {
  116.     water--;
  117.     thirst = thirst -7;
  118.   }
  119.   //hunger/thirst comes up  *******************
  120.   if (millisnow - millispast = random(480000, 900000)) {  //8-15 minutes
  121.     saturation = saturation-3;
  122.     thirst = thirst + 2;
  123.     if (saturation<=0) saturation=0;
  124.     if (thirst<=0) thirst=0;
  125.   }
  126.   */
  127.   food--; water--; mood--;
  128.   if (food<=0) food=0;
  129.   if (water<=0) water=0;
  130.   if (mood<=0) mood=0;
  131.   delay(200);
  132. }
  133. void waterfill(int water) {
  134.   tft.fillRoundRect(290, 80, 16, 60, 5, TFT_BLACK); //clear area
  135.   waterlevel = map(water, 0, 100, 140, 80);
  136.   tft.fillRect(290, waterlevel, 16, (140-waterlevel), DODGERBLUE);  //water
  137.   tft.drawRoundRect(289, 79, 18, 62, 5, TFT_WHITE);  //water frame
  138.   tft.drawRoundRect(275, 138, 26, 3, 1, TFT_WHITE);  //water
  139. }
  140. void foodfill(int food) {
  141.   tft.fillRoundRect(10, 80, 40, 70, 5, TFT_BLACK); //clear area
  142.   foodlevel = map(food, 0, 100, 150 , 80);
  143.   tft.drawRoundRect(9, 79, 42, 72, 3, BROWN);     //food frame
  144.   tft.fillRoundRect(10, foodlevel, 40, (150-foodlevel), 3, TFT_DARKGREEN);   //food   
  145.   tft.fillTriangle(9, 150, 10, 157, 62, 150, BROWN);    //feeding dish
  146. }
  147. void moodmeter(int mood) {
  148.   tft.fillRect(0, 0, 43, 43, TFT_BLACK); //clear area
  149.   mooddegree = map(mood, 0, 100, 1, 360);
  150.   if (mood < 15) moodcolor = RED;
  151.   if ((mood >= 15) && (mood < 30)) moodcolor = ORANGE;
  152.   if ((mood >= 30) && (mood < 60)) moodcolor = GOLD;
  153.   if (mood >= 60) moodcolor = TFT_DARKGREEN;
  154.   tft.drawSmoothArc(22, 22, 20, 8, 0, mooddegree, moodcolor, TFT_BLACK);
  155. }
  156. void printTouchToSerial(int x, int y, int z) {
  157.   Serial.print("X = ");
  158.   Serial.print(x);
  159.   Serial.print(" | Y = ");
  160.   Serial.print(y);
  161.   Serial.print(" | Pressure = ");
  162.   Serial.print(z);
  163.   Serial.println();
  164. }
复制代码


回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 9 小时前

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛

第 3 步:扬声器和 LDR 传感器

“Mooh”的扬声器是可选的。不幸的是,我还没有能够让声音功能在不复杂的情况下工作。每次 SD 卡在线时,触摸屏都无法正常工作。有什么想法吗?
mp3 文件可以保存在 SD 卡上。连接引脚位于 CYD 的背面。我从一台旧的固定电话中获得了扬声器。
内置的 LDR 传感器 (GPIO 34) 告诉奶牛何时睡觉。天黑时,她躺下。在此期间,不消耗水和食物。


附件

Cow-moo-sounds.mp3

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛图1

回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 9 小时前

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛

第 4 步:谷仓

对于氛围,我很快就设计了一个带有 tinkercad.com 的马厩,并通过 3D 打印机将其变为现实。当然,您也可以在这里用木头建造一个美妙的微型马厩。不要忘记背面的良好通风。

3D打印件
Hay_Barn_ground.stl
Hay_Barn_roof.stl
Hay_Barn_walls.stl

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛图3

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛图1

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛图2

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛图4

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛图5

回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 9 小时前

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛

第 5 步:哞哞

功能:
当奶牛的内部水分和饲料水平下降(= 饥饿、口渴)时,奶牛会进食和饮水。如果水或饲料容器是空的,则奶牛会感到饥饿、不高兴和哞哞。

如果你点击水或饲料,补给就会得到补充,奶牛就可以吃东西了。如果你轻拍奶牛(=抚摸),它也会很开心,很舒服地哞哞叫。

当 LDR 注意到黑暗时,奶牛就会睡觉。她不吃东西,也没有太多的饥饿或口渴。

与您的新宠物一起玩得开心!

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛图1

回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 9 小时前

【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛

本帖最后由 驴友花雕 于 2025-5-23 17:37 编辑

附录
项目链接:https://www.instructables.com/Cute-Tamagotchi-Cow/
项目作者:德国 马库斯·奥皮茨(Markus Opitz)
视频记录:https://www.bilibili.com/video/B ... a9be994cbb4a86cc987
3D打印文件:https://content.instructables.co ... FFOYDLOMADY883L.stl
https://content.instructables.co ... FFY6D47MADY883P.stl
https://content.instructables.co ... F7A3G1NMADY883Q.stl
项目开源代码:https://content.instructables.co ... FI156M8MADY89Z5.ino
图像到字节数组在线转换器(CPP、ARDUINO):https://mischianti.org/images-to ... verter-cpp-arduino/
电子宠物声音文件:https://content.instructables.co ... /FHPLRK4MADY883F.mp 3


【Arduino 动手做】可爱的 Tamagotchi 电子宠物牛图1







项目代码 mp3 3D打印文件.zip

452.87 KB, 阅读权限: 50, 下载次数: 0

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4 备案 沪公网安备31011502402448

© 2013-2025 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail