亿迅智能制造网
工业4.0先进制造技术信息网站!
首页 | 制造技术 | 制造设备 | 工业物联网 | 工业材料 | 设备保养维修 | 工业编程 |
home  MfgRobots >> 亿迅智能制造网 >  >> Manufacturing Technology >> 制造工艺

复古街机时钟

组件和用品

Arduino Mega 2560
× 1

必要的工具和机器

3D 打印机(通用)

应用和在线服务

Arduino IDE

关于这个项目

介绍:复古街机时钟 - Arduino

构建一个交互式街机床头钟,带有触摸屏和动画街机人偶,您可以为闹钟录制您选择的声音。

该项目包括一个 3D 打印案例和四个独立的程序可供选择

1. Arcade Clock - DK Mario、Space Invaders 和 Pac-Man 动画

2. Pacman Clock - 具有时钟功能的交互式动画吃豆人游戏

3. DK Clock - 具有时钟功能的互动动画DK游戏

4. Tumble Ghost - 基于 Flappy Bird 的动画吃豆人幽灵游戏

建造过程充满乐趣,对于喜欢重温 80 年代街机游戏角色怀旧情绪的人来说,这是一份很棒的礼物。

第 1 步:收集材料

  • Arduino 开发板 - Arduino Mega 2560(项目 1、2 和 3 可作为一个捆绑订单购买)
  • 触摸屏 Arduino 扩展板 - 3.2" Mega Touch LCD 扩展板扩展板
  • 触摸屏 - 3.2" TFT LCD 显示屏 + Arduino Mega 2560 触摸屏
  • 实时时钟模块 - DS3231 RTC
  • 录音机模块-ISD1820录音机
  • 用于 3D 打印机的 PLA 灯丝
  • 用于将外壳粘合在一起的两部分环氧树脂
  • USB 电缆 2m 长 USB 充电器(用于时钟电源)
  • 热胶枪
  • 电缆扎带 X 3

仅在床头钟时才需要可选的自动背光调光组件:

  • 电阻 270k ohm
  • 齐纳二极管 3.3v
  • 0.5 瓦电阻 47 欧姆
  • 光敏电阻 (LDR)

第 2 步:打印 3D 案例

我在 Creality Ender 3 上打印了时钟表壳。所有 3D 打印文件和表壳说明都可以在 Thingiverse 上找到。

第 3 步:构建电路

整个电路包含实时时钟、Arduino Mega、声音模块、触摸屏和屏幕屏蔽。

1.实时时钟

如提供的图片所示,将实时时钟安装在 Arduino Mega 的背面。我使用了热胶枪和包装泡沫以确保它们不会接触,并且有一些缓冲可以吸收运动。就我而言,我将 2 个 RTC 腿直接焊接到 Arduino,并使用连接线将 5v 和 GND 连接到 Arduino。

2.录音模块

这些非常酷且易于使用。以与上述类似的方式,使用泡沫和热胶将模块和扬声器定位在 Arduino 的背面,注意确保它们与接触绝缘。声音模块由Arduino上的D8触发,因此需要按照提供的电路图连接电源。

3.自动背光调光器(可选)

如果您打算用作床头钟,那么您可能希望在晚上自动调暗背光,以免影响您的睡眠。 (如果没有,那么你可以跳过这一步!)不幸的是,TFT 屏幕中的背光是硬接线到 +3.3v 的,不能用 Arduino 调整。这意味着我们必须断开它并重新连接到 Arduino 上的 PWM 引脚以控制背光亮度。我想在对组件上的引脚或轨道损坏最小的情况下做到这一点,因此采用了以下方法。请仔细按照以下步骤操作

(a) 为了实现这一点,光敏电阻 (LDR) 位于装置的背面以检测光。在外壳上钻两个 3 毫米的孔,然后将 LDR 支腿推过孔。在机柜内部使用热胶将腿固定到位。将两根电线焊接在外壳内部并按照电路图连接。根据电路图在 Arduino 的 A7 上添加一个 270k Ohm 电阻器。

(b) 取下 TFT 显示器,并将其放在坚固的表面上。识别针脚 19 (LED_A) 并小心地去除针脚底部几毫米的塑料。按照上图将插针弯曲并远离连接器。检查 TFT Sheild 是否可以紧密插入,并且弯曲的插针没有阻碍插头或插座。

(c) 将一个 47 欧姆寄存器焊接到引脚的弯曲处,并将电阻器的电线连接到 Arduino Mega 的 D9。 Arduino D9 引脚可吸收高达 40mA 的电流,因此电阻器将其限制为小于此值。将 3.3v 齐纳二极管连接到同一个引脚 (LED_A) 并按照图将其接地。这样做的目的是为了防止背光过压,因为它将电压调节到3.3v。

4. TFT 屏幕和 Arduino 扩展板

小心地将 3.2' TFT 触摸屏连接器推入 TFT Arduino Shield。然后按照提供的图片小心地连接到 Arduino 的顶部。 RTC 有一块电池,因此即使断电也能保持正确的时间。闹钟时间存储在 Arduino 上的 Eeprom 中,这意味着它会在断电时保留。

第 4 步:加载代码

该项目将需要在编译和运行之前加载以下文件和库。代码是独一无二的,围绕库的功能、硬件、一些自定义图形和我借用的其他项目构建。

请注意:此项目的代码开发使用了 IDE v1.06,并且一些必需的库已过时。这意味着有些人在加载代码时遇到了新的 IDE 1.6 及更高版本的问题。因此,为了简单起见,我建议人们使用 IDE v1.06,并在教程第 4 步的底部将正确的版本库文件包含在 zip 文件中。

1. Arduino IDE

我一直在使用早期版本的 Arduino IDE,因此为了简单起见,我建议您在安装代码之前在台式机上下载 Arduino IDE 1.06 版。你可以从这里得到他的版本。

2.图书馆

这些需要下载并添加到在您的计算机上运行的 IDE(集成开发环境)中,用于编写和上传计算机代码到物理板。

  • UTFT.h 和 URtouch.h 位于下面的 zip 文件中
  • Time.h 位于下面的 zip 文件中
  • DS1307RTC.h 位于下面的 zip 文件中
  • Wire.h 和 EEPROM.h 已包含在 IDE V1.06 中

UTFT.h 和 URtouch.h 归功于 Rinky-Dink Electronics 我已经包含了这些 zip 文件,因为源网站似乎已关闭。

4. TFT 屏幕变化

TFT 屏幕和制造商的含糊不清导致了这些注释。

(a) Sainsmart - 如果您购买了在 TFT 设备背面标有 Sainsmart 品牌的 3.2' TFT 屏幕,您会发现他们必须修改库以解决显示问题。如果您已经购买了 Sainsmart TFT 显示器,下面有一个修复程序

编辑文件“initlcd.h”并修改

中的以下行

LCD_Write_COM_DATA(0x01, 0x2B3F);

LCD_Write_COM_DATA(0x01, 0x3B3F);

您需要重新启动 IDE,然后将代码重新加载到 Arduino。

(b.) TFT 控制器芯片组 - 购买了 3.2" TFT 屏幕的人可能会发现他们也可以使用两种不同的芯片组之一“SSD1289”或“ILI9341” 令人讨厌的是,在线区分差异并不容易。好消息是它很容易修复。如果加载代码后出现黑屏,则可能是因为它是ILI9341控制器。

要修复,您需要对代码进行以下更改。编辑代码,修改下面这行代码

来自

UTFT myGLCD(SSD1289, 38, 39, 40, 41); //参数应根据您的显示/席尔德模型进行调整

UTFT myGLCD(ILI9341_16, 38, 39, 40, 41); //参数应根据您的显示/席尔德模型进行调整

现在尝试将代码重新加载到 Arduino。

(c.) 倒置触摸屏控制

一些制造商报告说 Y 轴触摸屏按钮已被颠倒。已确定对此进行了修复,其中需要更改两行代码以翻转触摸屏阅读。

做一个查找:“yT =myTouch.getY();”将其更改为:“yT =240 - myTouch.getY();”

不要忘记搜索两次,第一个是在时钟模式下控制pacman,第二个是在设置菜单中。

5.图形文件

我在下面包含了一组位图文件,当您开始加载到 Arduino 时,这些文件需要与 Arduino 代码位于同一子目录中。因此下载下面的文件并使用IDE加载。

6.设置时钟

成功加载代码后,按屏幕中央,这将显示设置屏幕。使用菜单以 24 小时格式设置时间和闹钟。按 SAVE 按钮存储设置。 RTC 有一块电池,因此即使断电也能保持正确的时间。报警时间存储在 EEPROM 中,这意味着它会在断电时保留。

7.测试警报

Sound 模块用于提供警报。 ISD1820 由 Arduino D8 引脚控制。通过在麦克风中播放声音,同时按下 ISD1820 上的录音按钮,可以轻松添加声音。就我而言,我从通过另一台设备播放的音频文件中录制了原始的 Pac-Man 介绍音乐。录制声音后,可以通过按下 PLAY-E 按钮来测试录音,该按钮应通过扬声器播放声音。使用设置菜单将时钟时间和闹钟时间间隔几分钟。一定要“设置”闹钟并按下“保存”菜单按钮。返回主屏幕后,警报应在时间发生时响起。按下触摸屏面板的中央即可关闭闹钟,出现设置屏幕。

8.触摸屏校准

一些厂商发现设置屏幕上的按钮与 TFT 触摸控件不对齐。在这些情况下,触摸屏需要校准。这可以通过使用 URtouch 库中提供的触摸屏校准代码和说明轻松完成。如果您发现此问题,请按照以下说明操作。

9.四种不同的程序可供选择

1. Arcade Clock - DK Mario, Space Invaders &Pacman animation2。 Pacman Clock - 具有时钟功能的交互式动画 Pacman/Ms Pacman 游戏

3. DK Clock - 具有时钟功能的互动动画DK游戏

4. Tumble Ghost - 基于 Flappy Bird 的动画 Pacman Ghost 游戏

1.%2BRetroArcadeClockTechKiwigadgetsV1.zip 2.%2BRetro_Pacman_Clock_V10.zip 3.%2BRetro_DK_Clock_V3.zip 4.%2BTumble_Ghost_V10.zip DS1307RTC.zip 时间.zip URTouch.zip UTFT.zip

第 5 步:将它们放在一起

1.添加外部电源

最后一步是添加外部电源。使用钻头,在机柜背面添加一个孔。将 USB 电缆穿过后面板,然后按照电路图将 USB 电缆 VCC、GND、D+ 和 D- 线连接到 Arduino USB 连接器的底座。这有两个好处,一是Arduino Mega Boards的USB输入有过流保护,二是可以使用USB线上传代码修改,不用拆盒子。将电源线绝缘层热粘到 Arduino 的背面,以在组装前面板和后面板时防止电缆张力。通过在距离 Arduino 连接 6-8 厘米的电源线上的外壳内侧的电缆周围系紧扎带,为电缆添加一个线夹。拉线时,扎线带应避免拉紧 USB 数据线时紧靠外壳内侧拉紧接头。

2.在机箱中安装电子设备

将电路与四个孔导板一起放在前面板的顶部,这些导孔应将屏幕在切口中居中对齐。给电路通电,你可以看到前面板屏幕,检查屏幕图像是否在正确的位置,然后用热胶粘到位。结果是与方形屏幕紧密配合,该屏幕位于切口孔的中心。

3.总装

将前面板轻轻推到后面板上,然后轻轻拉动 USB 电源线以收紧后面板的松弛部分。绳索夹在这里很有用,可以保护电线的任何损坏。插入 USB 充电器即可开始使用。

希望你喜欢!

代码

  • 复古街机时钟
复古街机时钟C/C++
Arduino IDE
/* Retro Arcade Clock - TechKiwigadgets V1 - 第一个生产版本*/ #include  #include #include #include  #include  #include  // 将时间作为 time_t 返回的基本 DS1307 库// 警报变量布尔警报状态 =false; // false 关闭且 true 为 onboolean soundalarm =false 的标志; // 表示需要发起报警的标志int alarmhour =0; // 闹钟设置的小时int alarmminute =0; // 闹钟设置分钟byte ahour; //小时字节amin的字节变量; // 字节变量为 minuteint actr =300; // 当闹钟响起时,这是一个用于重置声卡的计数器,直到触屏为止int act =0;int p =0; // 动画位置 E.G Pacman 图形标志 0 =关闭,1 =中开,2 =大开,3 =中开int m =0; // 动画位置 mario 3 postions// 图形 X,Y 坐标// myGLCD.drawBitmap (30, 14, 40, 40, rd_ghost); // 关闭 Ghostint ghostX =15;int ghostY =14;int ghostD =0; // 方向 d ==0 =右,1 =下,2 =左,3 =上 // myGLCD.drawBitmap (140, 14, 40, 40, MarioR3); // 关闭 Ghostint MarioX =141;int MarioY =14;int MarioD =0; // 方向 d ==0 =右,1 =下,2 =左,3 =上 // myGLCD.drawBitmap (240, 14, 40, 40, Monkey2); // 关闭 Ghostint MonkeyX =261;int MonkeyY =14;int MonkeyD =0; // 方向 d ==0 =右,1 =下,2 =左,3 =上 // myGLCD.drawBitmap (30, 180, 40, 40, pacman); // 关闭 Ghostint pacmanX =15;int pacmanY =185;int pacmanD =2; // 方向 d ==0 =右,1 =下,2 =左,3 =上// myGLCD.drawBitmap (140, 180, 40, 40, Alien); // 关闭 Ghostint AlienX =141;int AlienY =185;int AlienD =2; // 方向 d ==0 =右,1 =下,2 =左,3 =上// myGLCD.drawBitmap (240, 180, 40, 40, Cannon); // 关闭幽灵 int CannonX =270;int CannonY =185;int CannonD =2; // 方向 d ==0 =右,1 =下,2 =左,3 =上// 初始化 RTC 时间值:const int DS1307 =0x68; // DS1307 地址见数据表// Display Dimmer Variablesint dimscreen =255; // 此变量用于驱动屏幕亮度,其中 255 为最大亮度int LDR =100; //直接从模拟7测量的LDR变量//====创建对象UFT myGLCD(SSD1289,38,39,40,41); //参数应根据您的显示器/Schield 模型进行调整URTouch myTouch( 6, 5, 4, 3, 2);//====Defining Fontsextern uint8_t SmallFont[];extern uint8_t BigFont[];extern uint8_t SevenSegNumFont[]; extern uint8_t SevenSeg_XXXL_Num[];//定义位图sextern unsigned int Alien1[0x640]; // 外星人 1 graphicsextern unsigned int Alien2[0x640]; // 外星人 2 graphicsextern unsigned int Cannon[0x640]; // 太空入侵者 cannonextern unsigned int MarioL1[0x310]; // M Left 1extern unsigned int MarioL2[0x310]; // 鬼位图 直接extern unsigned int MarioL3[0x310]; // 幽灵位图 直接extern unsigned int MarioR1[0x310]; // 幽灵位图 直接extern unsigned int MarioR2[0x310]; // 鬼位图 直接extern unsigned int MarioR3[0x310]; // 鬼位图 直行extern unsigned int MarioStop[0x310]; // 鬼位图 直接extern unsigned int MarioU1[0x310]; // 鬼位图 直接extern unsigned int MarioU2[0x310]; // 幽灵位图 直接extern unsigned int MarioU3[0x310]; // 幽灵位图 直接extern unsigned int MarioU4[0x310]; // 鬼位图 直接extern unsigned int rd_ghost[784]; // 鬼位图 直接extern unsigned int ru_ghost[784]; // 鬼位图 直接extern unsigned int rl_ghost[784]; // 鬼位图 直接extern unsigned int rr_ghost[784]; // 鬼位图 直接extern unsigned int r_o_pacman[784]; // 鬼位图 直接extern unsigned int r_m_pacman[784]; // 鬼位图 直接extern unsigned int l_o_pacman[784]; // 鬼位图 直接extern unsigned int l_m_pacman[784]; // 鬼位图 直接extern unsigned int u_m_pacman[784]; // 鬼位图 直接extern unsigned int u_o_pacman[784]; // 鬼位图 直接extern unsigned int d_m_pacman[784]; // 鬼位图 直接extern unsigned int d_o_pacman[784]; // 幽灵位图 直接extern unsigned int c_pacman[784]; // 鬼位图 直接extern unsigned int Monkey2[0x640]; // 鬼位图 直接extern unsigned int Monkey3[0x640]; // Ghost Bitmap 直行// 触摸屏坐标boolean screenPressed =false;int xT,yT;int userT =4; // 在 screenboolean setupscreen =false 上指示定向触摸的标志; // 用于进入设置界面//报警设置变量boolean xsetup =false; // 标志以确定是否存在设置模式// 动画延迟以减慢向下移动int dly =0; // 原来 30 // 时间刷新计数器 int rfcvalue =300; // 等待这么长的时间,直到变化的检查时间int rfc =1;// 声明上一次的全局变量,只对发生变化的数字启用刷新// 有四位数字需要独立绘制,以确保时间的一致定位int c1 =20; // 十小时数 int c2 =20; // 小时数 int c3 =20; // 十分钟数 int c4 =20; // 1 分钟 digitvoid setup() {//初始化 RTC Serial.begin(9600); // 而 (!Serial); //等到Arduino串行监视器打开延迟(200); setSyncProvider(RTC.get); // 从 RTC 获取时间的函数 setSyncInterval(60); // 每 60 秒(1 分钟)同步一次时间 if(timeStatus()!=timeSet){ Serial.println("无法与 RTC 同步"); RTC.set(1408278800); // 将 RTC 设置为 2014 年 8 月 25 日上午 9:00 setTime(1408278800); } else{ Serial.println("RTC 设置了系统时间"); }// 设置报警使能引脚在ISD1820板上播放声音 pinMode(8, OUTPUT); // D8 用于切换声音 digitalWrite(8,LOW); // 设置为低以关闭声音 // 启动显示 myGLCD.InitLCD(); myGLCD.clrScr(); myTouch.InitTouch(); myTouch.setPrecision(PREC_LOW);画屏(); // 启动游戏 UpdateDisp(); // 更新时钟值 }void loop() {// 增加 Pacman Graphic Flag 0 =Closed, 1 =Medium Open, 2 =Wide Openp=p+1;如果(p==4){p=0; // 将计数器重置为关闭}// 增加 Pacman 图形标志 0 =关闭,1 =中等打开,2 =宽 Openm=m+1; if(m==3){m=0; // 将计数器重置为关闭}// 设置屏幕亮度// 检查环境光并调整 LED 亮度以适应环境大约 500 暗低于 100LDR =analogRead(A7);/* LDR 的测试值范围 myGLCD.setColor(237, 28, 36); myGLCD.setBackColor(0, 0, 0); myGLCD.printNumI(LDR,250,60);*/if (LDR>=121){dimscreen =255; } if (LDR <=120) { dimscreen =45;模拟写入(9,dimscreen); // 控制亮度 0 是暗,环境房间是大约 25 和 70 是直射阳光 // 从 RTC 读取当前日期和时间并重置 boardrfc++; if (rfc>=rfcvalue) { // 计数周期和打印时间 UpdateDisp(); // 更新时钟值然后... dly =18; // 重置延迟 rfc =0; }//===检查是否需要发出警报 if (alarmstatus ==true){ if ( (alarmhour ==hour()) &&(alarmminute ==minute())) { // 发出警报 soundalarm =true; } }//===启动闹钟声音 - 声音支付 10 秒,然后将在 20 秒重新启动 markif ((alarmstatus ==true)&&(soundalarm==true)){ // 设置一个计数器并采取行动重新启动sound if screen not touch if (act ==0) { // 通过切换 D8 设置闹钟,录制的声音由 LOW 到 HIGH 转换触发 digitalWrite(8,HIGH); // 设置高digitalWrite(8,LOW); // 设置低 UpdateDisp(); // 更新时钟值 } act =act +1; if (act ==actr) { // 通过切换 D8 设置闹钟,录制的声音由 LOW 到 HIGH 转换触发 digitalWrite(8,HIGH); // 设置高digitalWrite(8,LOW); // 设置低行为 =0; // 每 20 秒重置一次计数器 } }// 检查用户是否输入到触摸屏// UserT 设置方向 0 =右,1 =下,2 =左,3 =上,4 =无触摸输入 myTouch.read(); if (myTouch.dataAvailable() &&!screenPressed) { xT =myTouch.getX(); yT =myTouch.getY(); // ********************************** // ******* 进入设置模式 ** ******* // ************************************ 如果 (((xT>=120) &&(xT<=200) &&(yT>=105) &&(yT<=140)) &&(soundalarm !=true)) { // 如果警报没有响起,则调用设置程序 xsetup =true; // 切换标志clocksetup(); // 调用时钟设置程序 UpdateDisp(); // 更新时钟值 } else // 如果在闹钟响起时触摸屏幕中心,则关闭声音并将闹钟重置为未设置 if (((xT>=120) &&(xT<=200) &&(yT> =105) &&(yT<=140)) &&((alarmstatus ==true) &&(soundalarm ==true))) { alarmstatus =false;声音警报 =假;数字写入(8,低); // 设置低 } screenPressed =true; } // 不允许按住屏幕 / 你必须点击它 if ( !myTouch.dataAvailable() &&screenPressed){ screenPressed =false; }drawghost(ghostX, ghostY, ghostD, p); // 增加位置和绘制图像// ghost Direction //// 方向d ==0 =right, 1 =down, 2 =left, 3 =upif(ghostD ==0){ // Right // Increment Counter and test结果 ghostX =ghostX + 3;如果(ghostX ==270){ myGLCD.fillRect(ghostX-3,ghostY,ghostX,ghostY+28); // 在改变位置前清除拖尾图形 ghostD =1; // 向下改变方向 } } else if(ghostD ==1) { // 向下 // 递增计数器和测试结果 ghostY =ghostY + 3; if (ghostY ==185){ myGLCD.fillRect(ghostX+3, ghostY-3, ghostX+36, ghostY); // 在改变位置前清除拖尾图形 ghostD =2; // 向下改变方向 } } else if(ghostD ==2) { // Left // 递增计数器和测试结果 ghostX =ghostX - 3; if (ghostX ==12){ myGLCD.fillRect(ghostX+28, ghostY, ghostX+31, ghostY+28); // 在打印新的 positi ghostD =3 之前清除拖尾图形; // 向下改变方向 } } else if(ghostD ==3) { // 向上 // 递增计数器和测试结果 ghostY =ghostY - 3; if (ghostY ==14){ myGLCD.fillRect(ghostX, ghostY+29, ghostX+28, ghostY+28); // 在打印新位置前清除拖尾图形 ghostD =0; // 向下改变方向 }}drawMonkey(MonkeyX, MonkeyY, MonkeyD, p); // 增加位置并绘制图像 // Monkey Direction //// 方向 d ==0 =right, 1 =down, 2 =left, 3 =upif(MonkeyD ==0){ // Right // Increment Counter and test结果 MonkeyX =MonkeyX + 3; if (MonkeyX ==270){ myGLCD.fillRect(MonkeyX-3, MonkeyY, MonkeyX, MonkeyY+40); // 在改变方向之前清除拖尾图形 MonkeyD =1; // 向下改变方向 } } else if(MonkeyD ==1) { // 向下 // 递增计数器和测试结果 MonkeyY =MonkeyY + 3; if (MonkeyY ==185){ myGLCD.fillRect(MonkeyX+3, MonkeyY-3, MonkeyX+38, MonkeyY); // 在打印新位置 MonkeyD =2 之前清除图形拖尾; // 向下改变方向 } } else if(MonkeyD ==2) { // Left // 递增计数器和测试结果 MonkeyX =MonkeyX - 3; if (MonkeyX ==12){ myGLCD.fillRect(MonkeyX+41, MonkeyY+1, MonkeyX+40, MonkeyY+38); // 在打印新的 positi MonkeyD =3 之前清除图形// 向下改变方向 } } else if(MonkeyD ==3) { // Up // 递增计数器和测试结果 MonkeyY =MonkeyY - 3; if (MonkeyY ==14){ myGLCD.fillRect(MonkeyX, MonkeyY+38, MonkeyX+40, MonkeyY+43); // 在打印新位置 MonkeyD =0 之前清除图形拖尾; // 向下改变方向 }}drawCannon(CannonX, CannonY, CannonD, p); // 增加位置并绘制图像 // Cannon 方向 //// 方向 d ==0 =右,1 =下,2 =左,3 =upif(CannonD ==0){ // 右 // 递增计数器和测试结果 CannonX =CannonX + 3; if (CannonX ==270){ myGLCD.fillRect(CannonX-3, CannonY+3, CannonX, CannonY+36); // 在改变方向前清除拖尾图形 CannonD =1; // 向下改变方向 } } else if(CannonD ==1) { // 向下 // 递增计数器和测试结果 CannonY =CannonY + 3; if (CannonY ==185){ CannonD =2; // 向下改变方向 } } else if(CannonD ==2) { // Left // 递增计数器和测试结果 CannonX =CannonX - 3; if (CannonX ==12){ myGLCD.fillRect(CannonX+41, CannonY+3, CannonX+40, CannonY+36); // 在打印新的位置之前清除图形 CannonD =3; // 向下改变方向 } } else if(CannonD ==3) { // Up // 递增计数器和测试结果 CannonY =CannonY - 3; if (CannonY ==14){ CannonD =0; // 向下改变方向 }}drawpacman(pacmanX, pacmanY, pacmanD, p); // 增加位置并绘制图像// pacman Direction //// 方向 d ==0 =right, 1 =down, 2 =left, 3 =upif(pacmanD ==0){ // Right // Increment Counter and test结果 pacmanX =pacmanX + 3; if (pacmanX ==270){ myGLCD.fillRect(pacmanX-3, pacmanY+3, pacmanX, pacmanY+36); // 在改变方向前清除拖尾图形 pacmanD =1; // 向下改变方向 } } else if(pacmanD ==1) { // 向下 // 递增计数器和测试结果 pacmanY =pacmanY + 3; if (pacmanY ==185){ myGLCD.fillRect(pacmanX+3, pacmanY-3, pacmanX+36, pacmanY); // 在改变位置之前清除拖尾图形 pacmanD =2; // 向下改变方向 } } else if(pacmanD ==2) { // Left // 递增计数器和测试结果 pacmanX =pacmanX - 3; if (pacmanX ==12){ myGLCD.fillRect(pacmanX+28, pacmanY, pacmanX+31, pacmanY+28); // 在打印新的 positi pacmanD =3 之前清除拖尾图形; // 向下改变方向 } } else if(pacmanD ==3) { // Up // 递增计数器和测试结果 pacmanY =pacmanY - 3; if (pacmanY ==14){ myGLCD.fillRect(pacmanX, pacmanY+29, pacmanX+28, pacmanY+28); // 在打印新位置之前清除拖尾图形 pacmanD =0; // 向下改变方向 }}drawAlien(AlienX, AlienY, AlienD, p); // 增加位置并绘制图像// Alien Direction //// 方向d ==0 =right, 1 =down, 2 =left, 3 =upif(AlienD ==0){ // Right // Increment Counter and test结果 AlienX =AlienX + 3; if (AlienX ==270){ myGLCD.fillRect(AlienX-3, AlienY+3, AlienX, AlienY+36); // 在改变方向之前清除拖尾图形 AlienD =1; // 向下改变方向 } } else if(AlienD ==1) { // 向下 // 递增计数器和测试结果 AlienY =AlienY + 3; if (AlienY ==185){ AlienD =2; // 向下改变方向 } } else if(AlienD ==2) { // Left // 递增计数器和测试结果 AlienX =AlienX - 3; if (AlienX ==12){ myGLCD.fillRect(AlienX+41, AlienY+3, AlienX+40, AlienY+36); // 在打印新的 positi AlienD =3 之前清除图形// 向下改变方向 } } else if(AlienD ==3) { // Up // 递增计数器和测试结果 AlienY =AlienY - 3; if (AlienY ==14){ AlienD =0; // 向下改变方向 }}drawMario(MarioX, MarioY, MarioD, p); // 增加位置并绘制图像 // Mario 方向 //// 方向 d ==0 =右, 1 =下, 2 =左, 3 =upif(MarioD ==0){ // 右 // 递增计数器和测试结果 MarioX =MarioX + 3; if (MarioX ==270){ myGLCD.fillRect(MarioX-3, MarioY+3, MarioX, MarioY+36); // 在改变方向之前清除拖尾图形 MarioD =1; // 向下改变方向 } } else if(MarioD ==1) { // 向下 // 递增计数器和测试结果 MarioY =MarioY + 3; if (MarioY ==185){ myGLCD.fillRect(MarioX+3, MarioY-3, MarioX+36, MarioY); // 在打印新位置之前清除拖尾图形 MarioD =2; // 向下改变方向 } } else if(MarioD ==2) { // Left // 递增计数器和测试结果 MarioX =MarioX - 3; if (MarioX ==12){ MarioD =3; // 向下改变方向 } } else if(MarioD ==3) { // 向上 // 递增计数器和测试结果 MarioY =MarioY - 3; if (MarioY ==14){ myGLCD.fillRect(MarioX, MarioY+30, MarioX+28, MarioY+28); // 在打印新位置之前清除拖尾图形 MarioD =0; // 向下改变方向 }}delay(dly); }// **************************************************** ****************************************************** ***********// =====更新数字时钟// *************************** ****************************************************** ******************************** void UpdateDisp(){ // 清除时间区域 myGLCD.setColor(0, 0, 0); myGLCD.setBackColor(0, 0, 0);// myGLCD.fillRect(60, 80,262, 166); INT H; // 24 小时格式的小时值 int e; // 分钟格式的分钟值 int pm =0; // 判断PM还是AM的标志 // 有四位数字需要独立绘制以保证时间的一致定位 int d1; // 十小时数字 int d2; // 小时数 int d3; // 十分钟数字 int d4; //个分位数 h =hour(); // 24 小时 RT 时钟值 e =minute();/* TESTh =12;e =8;*/// 计算 timeif ((h>=10) &&(h <=12)) { / /AM 小时 10,11,12 d1 =1; // 计算十小时数字 d2 =h - 10; // 计算一个小时数 0,1,2 } else if ( (h>=22) &&(h <=24)) { // PM hours 10,11,12 d1 =1; // 计算十小时数字 d2 =h - 22; // 计算一个小时数 0,1,2 } else if ((h <=9)&&(h>=1)) { // 上午十点以下的小时数 d1 =0; // 计算十小时数字 d2 =h; // calculate Ones hour digit 0,1,2 } else if ( (h>=13) &&(h <=21)) { // PM hours below 10 d1 =0; // calculate Tens hour digit d2 =h - 12; // calculate Ones hour digit 0,1,2 } else { // If hour is 0 d1 =1; // calculate Tens hour digit d2 =2; // calculate Ones hour digit 0,1,2 } // Calculate minute digit values for timeif ((e>=10)) { d3 =e/10; // calculate Tens minute digit 1,2,3,4,5 d4 =e - (d3*10); // calculate Ones minute digit 0,1,2 } else { // e is less than 10 d3 =0; d4 =e; } if (h>=12){ // Set // h =h-12; // Work out value pm =1; // Set PM flag} // *************************************************************************// Print each digit if it has changed to reduce screen impact/flicker// Set digit font colour to white myGLCD.setColor(255, 255, 255); myGLCD.setBackColor(0, 0, 0); myGLCD.setFont(SevenSeg_XXXL_Num); // First Digitif(((d1 !=c1)||(xsetup ==true))&&(d1 !=0)){ // Do not print zero in first digit position myGLCD.printNumI(d1,10,70); // Printing thisnumber impacts LFH walls so redraw impacted area // ---------------- Clear lines on Outside wall myGLCD.setColor(0,0,0); myGLCD.drawRoundRect(1, 238, 318, 1); }//If prevous time 12:59 or 00:59 and change in time then blank First Digitif((c1 ==1) &&(c2 ==2) &&(c3 ==5) &&(c4 ==9) &&(d2 !=c2) ){ // Clear the previouis First Digit and redraw wall myGLCD.setColor(0,0,0); myGLCD.fillRect(50, 70, 70, 165);}if((c1 ==0) &&(c2 ==0) &&(c3 ==5) &&(c4 ==9) &&(d2 !=c2) ){ // Clear the previouis First Digit and redraw wall myGLCD.setColor(0,0,0); myGLCD.fillRect(50, 70, 70, 165);} myGLCD.setColor(255, 255, 255); myGLCD.setBackColor(0, 0, 0); myGLCD.setFont(SevenSeg_XXXL_Num); // Second Digitif((d2 !=c2)||(xsetup ==true)){ myGLCD.printNumI(d2,70,70); // Print 0}// Third Digitif((d3 !=c3)||(xsetup ==true)){ myGLCD.printNumI(d3,143,70); // Was 145 }// Fourth Digitif((d4 !=c4)||(xsetup ==true)){ myGLCD.printNumI(d4,204,70); // Was 205 }if (xsetup ==true){ xsetup =false; // Reset Flag now leaving setup mode } // Print PM or AM // myGLCD.setColor(1, 73, 240); myGLCD.setBackColor(0, 0, 0); myGLCD.setFont(BigFont); if (pm ==0) { myGLCD.print("AM", 270, 147); } else { myGLCD.print("PM", 270, 147); }// ----------- Alarm Set on LHS lower pillarif (alarmstatus ==true) { // Print AS on fron screenleft hand side myGLCD.print("AS", 7, 147); } // Round dots myGLCD.setColor(255, 255, 255); myGLCD.setBackColor(0, 0, 0); myGLCD.fillCircle(137, 105, 5); myGLCD.fillCircle(137, 135, 5);//--------------------- copy exising time digits to global variables so that these can be used to test which digits change in futurec1 =d1;c2 =d2;c3 =d3;c4 =d4;}// =====initiateGame - Custom Functionvoid drawscreen() { // Setup Clock Background //Draw Background lines myGLCD.setColor(1, 73, 240);// myGLCD.setColor(229, 14, 122);// myGLCD.setColor(255, 0, 131); // ---------------- Outside wall myGLCD.drawRoundRect(0, 239, 319, 0); myGLCD.drawRoundRect(2, 237, 317, 2); myGLCD.drawBitmap (ghostX, ghostY, 28, 28, rd_ghost); // Closed Ghost myGLCD.drawBitmap (MarioX, MarioY, 28, 28, MarioR3); // Closed Ghost myGLCD.drawBitmap (MonkeyX, MonkeyY, 40, 40, Monkey2); // Closed Ghost myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, r_o_pacman); // Closed Ghost myGLCD.drawBitmap (AlienX, AlienY, 40, 40, Alien1); // Closed Ghost myGLCD.drawBitmap (CannonX, CannonY, 40, 40, Cannon); // Closed Ghost } // ********************************** // ******* Enter Setup Mode ********* // ********************************** // Use up down arrows to change time and alrm settings void clocksetup(){ int timehour =hour();int timeminute =minute();// Read Alarm Set Time from Eeprom // read a byte from the current address of the EEPROM ahour =EEPROM.read(100); alarmhour =(int)ahour; if (alarmhour>24 ) { alarmhour =0; } amin =EEPROM.read(101); alarmminute =(int)amin; if (alarmminute>60 ) { alarmminute =0; }boolean savetimealarm =false; // If save button pushed save the time and alarm // Setup Screen myGLCD.clrScr();// ---------------- Outside wall myGLCD.setColor(255, 255, 0); myGLCD.setBackColor(0, 0, 0); myGLCD.drawRoundRect(0, 239, 319, 0); myGLCD.drawRoundRect(2, 237, 317, 2); //Reset screenpressed flagscreenPressed =false;// Read in current clock time and Alarm time // Setup buttons myGLCD.setFont(BigFont); // Time Set buttons myGLCD.print("+ +", 135, 38); myGLCD.print("- -", 135, 82); myGLCD.drawRoundRect(132, 35, 152, 55); // time hour + myGLCD.drawRoundRect(180, 35, 200, 55); // time minute + myGLCD.drawRoundRect(132, 80, 152, 100); // time hour - myGLCD.drawRoundRect(180, 80, 200, 100); // time minute - // Alarm Set buttons myGLCD.print("+ +", 135, 138); myGLCD.print("- -", 135, 182); myGLCD.drawRoundRect(132, 135, 152, 155); // alarm hour + myGLCD.drawRoundRect(180, 135, 200, 155); // alarm minute + myGLCD.drawRoundRect(132, 180, 152, 200); // alarm hour - myGLCD.drawRoundRect(180, 180, 200, 200); // alarm minute - myGLCD.print("SAVE", 13, 213); myGLCD.print("EXIT", 245, 213); myGLCD.drawRoundRect(10, 210, 80, 230); myGLCD.drawRoundRect(243, 210, 310, 230); // Get your Ghost on myGLCD.drawBitmap (50, 20, 28, 28, rd_ghost); // Closed Ghost myGLCD.drawBitmap (240, 100, 28, 28, r_o_pacman); // Closed Ghost myGLCD.drawBitmap (240, 20, 40, 40, Alien1); // Closed Ghost // Begin Loop herewhile (xsetup ==true){ if (alarmstatus ==true){ // flag where false is off and true is on myGLCD.print("SET", 220, 160); } else { myGLCD.print("OFF", 220, 160); } myGLCD.drawRoundRect(218, 157, 268, 177);// Draw Sound Button myGLCD.print("TEST", 50, 110); // Triggers alarm sound myGLCD.drawRoundRect(48, 108, 116, 128); // Display Current Time myGLCD.print("Time", 40, 60); // myGLCD.printNumI(timehour, 130, 60); if(timehour>=10){ // Annoyingly if number less than 10 doesnt print on RHS and misses zero so need to compensate myGLCD.printNumI(timehour, 130, 60); // If>=10 just print minute } else { myGLCD.print("0", 130, 60); myGLCD.printNumI(timehour, 146, 60); } myGLCD.print(":", 160, 60); if(timeminute>=10){ // Annoyingly if number less than 10 doesnt print on RHS and misses zero so need to compensate myGLCD.printNumI(timeminute, 175, 60); // If>=10 just print minute } else { myGLCD.print("0", 175, 60); myGLCD.printNumI(timeminute, 193, 60); } //Display Current Alarm Setting myGLCD.print("Alarm", 40, 160); // myGLCD.printNumI(alarmhour, 130, 160); if(alarmhour>=10){ // Annoyingly if number less than 10 doesnt print on RHS and misses zero so need to compensate myGLCD.printNumI(alarmhour, 130, 160); // If>=10 just print minute } else { myGLCD.print("0", 130, 160); myGLCD.printNumI(alarmhour, 146, 160); } myGLCD.print(":", 160, 160); if(alarmminute>=10){ // Annoyingly if number less than 10 doesnt print on RHS and misses zero so need to compensate myGLCD.printNumI(alarmminute, 175, 160); // If>=10 just print minute } else { myGLCD.print("0", 175, 160); myGLCD.printNumI(alarmminute, 193, 160); } // Read input to determine if buttons pressed myTouch.read(); if (myTouch.dataAvailable()) { xT =myTouch.getX(); yT =myTouch.getY(); // Capture input command from user if ((xT>=230) &&(xT<=319) &&(yT>=200) &&(yT<=239)) { // (243, 210, 310, 230) Exit Button xsetup =false; // Exit setupmode } else if ((xT>=0) &&(xT<=90) &&(yT>=200) &&(yT<=239)) { // (243, 210, 310, 230) Save Alarm and Time Button savetimealarm =true; // Exit and save time and alarm xsetup =false; // Exit setupmode } else if ((xT>=130) &&(xT<=154) &&(yT>=32) &&(yT<=57)) { // Time Hour + (132, 35, 152, 55) timehour =timehour + 1; // Increment Hour if (timehour ==24) { // reset hour to 0 hours if 24 timehour =0; } } else if ((xT>=130) &&(xT<=154) &&(yT>=78) &&(yT<=102)) { // (132, 80, 152, 100); // time hour - timehour =timehour - 1; // Increment Hour if (timehour ==-1) { // reset hour to 23 hours if <0 timehour =23; } } else if ((xT>=178) &&(xT<=202) &&(yT>=32) &&(yT<=57)) { // Time Minute + (180, 35, 200, 55) timeminute =timeminute + 1; // Increment Hour if (timeminute ==60) { // reset minute to 0 minutes if 60 timeminute =0; } } else if ((xT>=178) &&(xT<=202) &&(yT>=78) &&(yT<=102)) { // (180, 80, 200, 100); // time minute - timeminute =timeminute - 1; // Increment Hour if (timeminute ==-1) { // reset minute to 0 minutes if 60 timeminute =59; } } else if ((xT>=130) &&(xT<=154) &&(yT>=133) &&(yT<=157)) { // (132, 135, 152, 155); // alarm hour + alarmhour =alarmhour + 1; // Increment Hour if (alarmhour ==24) { // reset hour to 0 hours if 24 alarmhour =0; } } else if ((xT>=130) &&(xT<=154) &&(yT>=178) &&(yT<=202)) { // (132, 180, 152, 200); // alarm hour - alarmhour =alarmhour - 1; // Increment Hour if (alarmhour ==-1) { // reset hour to 23 hours if <0 alarmhour =23; } } else if ((xT>=178) &&(xT<=202) &&(yT>=133) &&(yT<=157)) { // (180, 135, 200, 155); // alarm minute + alarmminute =alarmminute + 1; // Increment Hour if (alarmminute ==60) { // reset minute to 0 minutes if 60 alarmminute =0; } } else if ((xT>=178) &&(xT<=202) &&(yT>=178) &&(yT<=202)) { // (180, 180, 200, 200); // alarm minute - alarmminute =alarmminute - 1; // Increment Hour if (alarmminute ==-1) { // reset minute to 0 minutes if 60 alarmminute =59; } } else if ((xT>=216) &&(xT<=270) &&(yT>=155) &&(yT<=179)) { // (218, 157, 268, 177); // alarm set button pushed if (alarmstatus ==true) { alarmstatus =false; // Turn off Alarm } else { alarmstatus =true; // Turn on Alarm } } else if ((xT>=46) &&(xT<=118) &&(yT>=106) &&(yT<=130)) { // ((48, 108, 116, 128); // alarm test button pushed // Set off alarm by toggling D8, recorded sound triggered by LOW to HIGH transition digitalWrite(8,HIGH); // Set high digitalWrite(8,LOW); // Set low } // Should mean changes should scroll if held down delay(250); } } if ( savetimealarm ==true) { // The following codes transmits the data to the RTC Wire.beginTransmission(DS1307); Wire.write(byte(0)); Wire.write(decToBcd(0)); Wire.write(decToBcd(timeminute)); Wire.write(decToBcd(timehour)); Wire.write(decToBcd(0)); Wire.write(decToBcd(0)); Wire.write(decToBcd(0)); Wire.write(decToBcd(0)); Wire.write(byte(0)); Wire.endTransmission(); // Ends transmission of data // Write the Alarm Time to EEPROM so it can be stored when powered off //alarmhour =(int)ahour; ahour =(byte)alarmhour; amin =(byte)alarmminute; EEPROM.write(100, ahour); EEPROM.write(101, amin); // Now time and alarm data saved reset fla g savetimealarm =false;} //* Clear Screen myGLCD.setColor(0, 0, 0); myGLCD.setBackColor(0, 0, 0); myGLCD.fillRect(0,239,319,0); xsetup =true; // Set Flag now leaving setup mode in order to draw Clock Digits setSyncProvider(RTC.get); // the function to get the time from the RTC setSyncInterval(60); // sync the time every 60 seconds (1 minutes) drawscreen(); // Initiate the screen UpdateDisp(); // update value to clock } // =================Decimal to BCD converterbyte decToBcd(byte val) { return ((val/10*16) + (val%10));} /* myGLCD.drawBitmap (ghostX, ghostY, 28, 28, ghost); // Closed Ghost myGLCD.drawBitmap (MarioX, MarioY, 40, 40, Mario); // Closed Ghost myGLCD.drawBitmap (MonkeyX, MonkeyY, 40, 40, Monkey); // Closed Ghost myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, r_o_pacman); // Closed Ghost myGLCD.drawBitmap (AlienX, AlienY, 40, 40, Alien); // Closed Ghost myGLCD.drawBitmap (CannonX, CannonY, 40, 40, Cannon); // Closed Ghost *///**********************************************************************************************************//======Draws the rd_ghost - bitmapvoid drawghost(int x, int y, int d, int p) { // Draws the ghost - bitmap // knotting direction d ==0 =right, 1 =down, 2 =left, 3 =up myGLCD.setColor(0, 0, 0); myGLCD.setBackColor(0, 0, 0); if ( d ==0){ // Right myGLCD.fillRect(x-3, y, x, y+28); // Clear trail off graphic before printing new position // draw image myGLCD.drawBitmap (ghostX, ghostY, 28, 28, rr_ghost); } else if ( d ==1){ // Down myGLCD.fillRect(x+3, y-3, x+36, y); // Clear trail off graphic before printing new position // draw image myGLCD.drawBitmap (ghostX, ghostY, 28, 28, rd_ghost); } else if ( d ==2){ // Left myGLCD.fillRect(x+28, y, x+31, y+28); // Clear trail off graphic before printing new positi // draw image myGLCD.drawBitmap (ghostX, ghostY, 28, 28, rl_ghost); // draw image } else if ( d ==3){ // Up myGLCD.fillRect(x, y+29, x+28, y+28); // Clear trail off graphic before printing new position // draw image myGLCD.drawBitmap (ghostX, ghostY, 28, 28, ru_ghost); }}//**********************************************************************************************************//======Draws the Mario - bitmapvoid drawMario(int x, int y, int d, int p) { // Draws the Mario - bitmap // Mario direction d ==0 =right, 1 =down, 2 =left, 3 =up myGLCD.setColor(0, 0, 0); myGLCD.setBackColor(0, 0, 0); if ( d ==0){ // Right myGLCD.fillRect(x-3, y+3, x, y+36); // Clear trail off graphic before printing new position // draw image if (p==0) { myGLCD.drawBitmap (MarioX, MarioY, 28, 28, MarioR1); } else if (p==1) { myGLCD.drawBitmap (MarioX, MarioY, 28, 28, MarioR3); } else if (p==2) { myGLCD.drawBitmap (MarioX, MarioY, 28, 28, MarioR2); } else if (p==3) { myGLCD.drawBitmap (MarioX, MarioY, 28, 28, MarioR3); } } else if ( d ==1){ // Down myGLCD.fillRect(x+3, y-3, x+36, y); // Clear trail off graphic before printing new position // draw image if (p==0) { myGLCD.drawBitmap (MarioX, MarioY, 28, 28, MarioU1); } else if (p==1) { myGLCD.drawBitmap (MarioX, MarioY, 28, 28, MarioU2); } else if (p==2) { myGLCD.drawBitmap (MarioX, MarioY, 28, 28, MarioU1); } else if (p==3) { myGLCD.drawBitmap (MarioX, MarioY, 28, 28, MarioU2); } } else if ( d ==2){ // Left myGLCD.fillRect(x+28, y, x+31, y+28); // Clear trail off graphic before printing new positi // draw image if (p==0) { myGLCD.drawBitmap (MarioX, MarioY, 28, 28, MarioL1); } else if (p==1) { myGLCD.drawBitmap (MarioX, MarioY, 28, 28, MarioL3); } else if (p==2) { myGLCD.drawBitmap (MarioX, MarioY, 28, 28, MarioL2); } else if (p==3) { myGLCD.drawBitmap (MarioX, MarioY, 28, 28, MarioL3); } } else if ( d ==3){ // Up myGLCD.fillRect(x, y+30, x+28, y+28); // Clear trail off graphic before printing new position // draw image if (p==0) { myGLCD.drawBitmap (MarioX, MarioY, 28, 28, MarioU1); } else if (p==1) { myGLCD.drawBitmap (MarioX, MarioY, 28, 28, MarioU2); } else if (p==2) { myGLCD.drawBitmap (MarioX, MarioY, 28, 28, MarioU1); } else if (p==3) { myGLCD.drawBitmap (MarioX, MarioY, 28, 28, MarioU2); } }// myGLCD.drawBitmap (MarioX, MarioY, 40, 40, MarioR3); }//**********************************************************************************************************//======Draws the Cannon - bitmapvoid drawCannon(int x, int y, int d, int p) { // Draws the Cannon - bitmap // Cannon direction d ==0 =right, 1 =down, 2 =left, 3 =up myGLCD.setColor(0, 0, 0); myGLCD.setBackColor(0, 0, 0); if ( d ==0){ // Right myGLCD.fillRect(x-3, y+3, x, y+36); // Clear trail off graphic before printing new position // draw image } else if ( d ==1){ // Down myGLCD.fillRect(x+3, y-3, x+36, y); // Clear trail off graphic before printing new position // draw image } else if ( d ==2){ // Left myGLCD.fillRect(x+41, y+3, x+40, y+36); // Clear trail off graphic before printing new positi // draw image } else if ( d ==3){ // Up myGLCD.fillRect(x, y+41, x+40, y+40); // Clear trail off graphic before printing new position // draw image } myGLCD.drawBitmap (CannonX, CannonY, 40, 40, Cannon); }//**********************************************************************************************************//======Draws the Monkey - bitmapvoid drawMonkey(int x, int y, int d, int p) { // Draws the Monkey - bitmap // Monkey direction d ==0 =right, 1 =down, 2 =left, 3 =up myGLCD.setColor(0, 0, 0); myGLCD.setBackColor(0, 0, 0); if ( d ==0){ // Right myGLCD.fillRect(x-3, y, x, y+40); // Clear trail off graphic before printing new position // draw image if (p==0) { myGLCD.drawBitmap (MonkeyX, MonkeyY, 40, 40, Monkey2); } else if (p==1) { myGLCD.drawBitmap (MonkeyX, MonkeyY, 40, 40, Monkey2); } else if (p==2) { myGLCD.drawBitmap (MonkeyX, MonkeyY, 40, 40, Monkey3); }else { myGLCD.drawBitmap (MonkeyX, MonkeyY, 40, 40, Monkey3); } } else if ( d ==1){ // Down myGLCD.fillRect(x, y-3, x+40, y); // Clear trail off graphic before printing new position // draw image myGLCD.drawBitmap (MonkeyX, MonkeyY, 40, 40, Monkey3); } else if ( d ==2){ // Left myGLCD.fillRect(x+41, y, x+40, y+40); // Clear trail off graphic before printing new positi // draw image if (p==0) { myGLCD.drawBitmap (MonkeyX, MonkeyY, 40, 40, Monkey2); } else if (p==1) { myGLCD.drawBitmap (MonkeyX, MonkeyY, 40, 40, Monkey2); } else if (p==2) { myGLCD.drawBitmap (MonkeyX, MonkeyY, 40, 40, Monkey3); }else { myGLCD.drawBitmap (MonkeyX, MonkeyY, 40, 40, Monkey3); } } else if ( d ==3){ // Up myGLCD.fillRect(x, y+43, x+40, y+40); // Clear trail off graphic before printing new position // draw image myGLCD.drawBitmap (MonkeyX, MonkeyY, 40, 40, Monkey3); } }//**********************************************************************************************************//======Draws the pacman - bitmapvoid drawpacman(int x, int y, int d, int p) { // Draws the pacman - bitmap // pacman direction d ==0 =right, 1 =down, 2 =left, 3 =up myGLCD.setColor(0, 0, 0); myGLCD.setBackColor(0, 0, 0); if ( d ==0){ // Right myGLCD.fillRect(x-3, y+3, x, y+36); // Clear trail off graphic before printing new position // draw image if (p==0) { myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, c_pacman); } else if (p==1) { myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, r_m_pacman); } else if (p==2) { myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, r_o_pacman); }else { myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, r_m_pacman); } } else if ( d ==1){ // Down myGLCD.fillRect(x+3, y-3, x+36, y); // Clear trail off graphic before printing new position // draw image if (p==0) { myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, c_pacman); } else if (p==1) { myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, d_m_pacman); } else if (p==2) { myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, d_o_pacman); }else { myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, d_m_pacman); } } else if ( d ==2){ // Left myGLCD.fillRect(x+28, y, x+31, y+28); // Clear trail off graphic before printing new positi // draw image if (p==0) { myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, c_pacman); } else if (p==1) { myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, l_m_pacman); } else if (p==2) { myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, l_o_pacman); }else { myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, l_m_pacman); } } else if ( d ==3){ // Up myGLCD.fillRect(x, y+29, x+28, y+28); // Clear trail off graphic before printing new position // draw image if (p==0) { myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, c_pacman); } else if (p==1) { myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, u_m_pacman); } else if (p==2) { myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, u_o_pacman); }else { myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, u_m_pacman); } }// myGLCD.drawBitmap (pacmanX, pacmanY, 28, 28, r_o_pacman); }//**********************************************************************************************************//======Draws the Alien - bitmapvoid drawAlien(int x, int y, int d, int p) { // Draws the Alien - bitmap // Alien direction d ==0 =right, 1 =down, 2 =left, 3 =up myGLCD.setColor(0, 0, 0); myGLCD.setBackColor(0, 0, 0); if ( d ==0){ // Right myGLCD.fillRect(x-3, y+3, x, y+36); // Clear trail off graphic before printing new position // draw image if((p ==1)||(p ==3)){ myGLCD.drawBitmap (AlienX, AlienY, 40, 40, Alien1); } else { myGLCD.drawBitmap (AlienX, AlienY, 40, 40, Alien2); } } else if ( d ==1){ // Down myGLCD.fillRect(x+3, y-3, x+36, y); // Clear trail off graphic before printing new position // draw image if((p ==1)||(p ==3)){ myGLCD.drawBitmap (AlienX, AlienY, 40, 40, Alien1); } else { myGLCD.drawBitmap (AlienX, AlienY, 40, 40, Alien2); } } else if ( d ==2){ // Left myGLCD.fillRect(x+41, y+3, x+40, y+36); // Clear trail off graphic before printing new positi // draw image if((p ==1)||(p ==3)){ myGLCD.drawBitmap (AlienX, AlienY, 40, 40, Alien1); } else { myGLCD.drawBitmap (AlienX, AlienY, 40, 40, Alien2); } } else if ( d ==3){ // Up myGLCD.fillRect(x, y+41, x+40, y+40); // Clear trail off graphic before printing new position // draw image if((p ==1)||(p ==3)){ myGLCD.drawBitmap (AlienX, AlienY, 40, 40, Alien1); } else { myGLCD.drawBitmap (AlienX, AlienY, 40, 40, Alien2); } } }

定制零件和外壳

物联网
https://www.thingiverse.com/thing:3017701CAD file on thingiverse.com

示意图


制造工艺

  1. LED 定序器
  2. 布谷鸟钟
  3. Arduino pov 视觉时钟
  4. Verilog 时钟发生器
  5. 简单字时钟(Arduino)
  6. TeleBall Retro 手持游戏机
  7. 主时钟
  8. Ingegno Retro Games Console
  9. 意大利字时钟
  10. 柏林时钟
  11. 模拟式 LED POV 时钟
  12. 无限镜时钟