💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
原帖,感谢 https://www.arduino.cn/thread-83370-1-1.html **基于Arduino Nano的多功能桌面感应垃圾桶** 随着大学生活不断往前迈进,宿舍桌面上的杂物越来越多,于是乎某天终于翻开了某宝,从网上淘来了一个5元钱的普通塑料桌面垃圾桶。于是乎,又经过一番折腾,一款超级拉风的多功能桌面垃圾桶就横空出世了,不多说,先发成品图为敬。 ![](https://www.arduino.cn/data/attachment/forum/201902/09/001045tzgf9zmkgkuchy0m.jpg) (垃圾桶由超声波感应自动开启,延时后关闭) ![](https://www.arduino.cn/data/attachment/forum/201812/27/004756iww75vffjfvk8jw0.jpg) 别看这个垃圾桶看起来非常的小巧和简陋,但可谓是麻雀虽小,五脏俱全,当你伸手放在桶盖前时,桶盖会自动感应打开,而这种识别方式则是双通道超声波传感器的功劳,这一传感器听起来非常的高大上是不是,事实上价格也是非常的便宜,一般不会超过10元。 垃圾桶桶盖上有两个小按键,右侧按键是用来选择功能模式,而左侧按键则用来进行确认,简洁而实用,垃圾桶内内置蜂鸣器和RTC时钟模块,可以进行精准定时和报时。LM35提供的温度数据使得垃圾桶摇身一变成为了温度播报员。桶盖上USB接口也大大拓展了使用者的想象空间,它可以用来充电,用来照明,用来驱动小风扇等等。当夜幕降临,桶内内置的LED小夜灯可以将垃圾桶摇身一变成为可爱的小精灵,在寂静的黑夜中发出温暖而和蔼的光芒。 ![](https://www.arduino.cn/data/attachment/forum/201812/27/005112myjcfmhrsgremsje.jpg) 看了这些,你想拥有这样一款智能又可爱的桌面垃圾桶吗?别急,接下来我就要向你们分享这个智能垃圾桶的所有奥秘。 首先是硬件方面,制作智能垃圾桶,我们需要哪些原材料呢? 1.普通桌面垃圾桶一个,某宝上价格5到8元不等 ![](https://www.arduino.cn/data/attachment/forum/201812/27/005159ogtdab9vxl2ggrtd.jpg) 2.小型舵机一个引脚的棕、红、橙线以此对应(GND,VCC,信号线) ![](https://www.arduino.cn/data/attachment/forum/201812/27/005215ehfgyq654gpnjzfz.jpg) LM35温度传感器: ![](https://www.arduino.cn/data/attachment/forum/201904/06/013706a0defvpdzv9oo5ee.png) 3\. 0.96存OLED显示屏,价格一般在10到15元之间 ![](https://www.arduino.cn/data/attachment/forum/201812/27/005233jhvvo45iz58vokl3.jpg) 4.三种0805型号贴片LED灯(白,蓝,绿),颜色可以根据个人喜好而定哈 ![](https://www.arduino.cn/data/attachment/forum/201812/27/005242zdeepbnveb2lq2qz.jpg) 5.轻触按键两个 ![](https://www.arduino.cn/data/attachment/forum/201812/27/005258ap4oc0k366e3oom6.jpg) 6.usb接口模块 ![](https://www.arduino.cn/data/attachment/forum/201812/27/005315h9yjcw9bh9j6w9ky.jpg) 7.DC电源接口模块及电源线 ![](https://www.arduino.cn/data/attachment/forum/201812/27/005348wuosvw96s2ywr196.jpg) ![](https://www.arduino.cn/data/attachment/forum/201812/27/005349qh8ra8hbahrhi14i.jpg) 8.RTC时钟模块 ![](https://www.arduino.cn/data/attachment/forum/201812/27/005349ncx34ieauu5u5fho.jpg) 9超声波模块一个 ![](https://www.arduino.cn/data/attachment/forum/201812/27/005425euk1ukppi3fs1f10.jpg) 10.Arduino NANO单片机最小系统板一块 ![](https://www.arduino.cn/data/attachment/forum/201812/27/005441vo2zn661d414o9t6.jpg) 11.自制PCB线路板一块(由于线路较少,布线时就没有覆铜了,不想制板的朋友也可以尝试用洞洞板连线) ![](https://www.arduino.cn/data/attachment/forum/201812/27/005503ljkrqlkctikccwqf.jpg) ![](https://www.arduino.cn/data/attachment/forum/201812/27/005507eh8dyc9y8nycex89.jpg) 这样一来我们的硬件准备阶段就告一段落啦,接下来就要进入动手制作环节 步骤一:剪去桶盖上的犄角,使得桶盖能够进行更大扭矩的转动,防止因为垃圾桶盖转动不足导致开口过小,投不进去垃圾 ![](https://www.arduino.cn/data/attachment/forum/201812/27/005538r6nj8jrlmhn0uza6.jpg) 步骤二:在桶盖上挖出大小合适的通孔,使得超声波模块的“小眼睛”、OLED、USB接口、DC电源接口和按键能够嵌入桶盖,挖孔工具可以是钻机,电烙铁或是激光切割 ![](https://www.arduino.cn/data/attachment/forum/201812/27/005538t9gz9gm9t91o9b8f.jpg) ![](https://www.arduino.cn/data/attachment/forum/201812/27/005538eeqv3sn237ksdsee.jpg) 步骤三:按照所给PCB线路图进行连线, ![](https://www.arduino.cn/data/attachment/forum/201812/27/005858jhikzi9kib82saki.jpg) 步骤四:曲轴连杆式传动结构的制作,选用硬质杆与舵机臂组成连杆传动机制,控制桶盖的开合,这样的硬质杆可以由身边许多的东西替代,比如排针,牙签,甚至热熔胶棒 ![](https://www.arduino.cn/data/attachment/forum/201812/27/005930yf6p96kfr7fc9dzt.jpg) ![](https://www.arduino.cn/data/attachment/forum/201812/27/005930ncpvscll2d8l88ad.jpg) 步骤五:利用Arduino IDE和usb串口给Arduino下载程序。Arduino IDE的配置要选择为Arduino NANO MEGA328P,并选择好相应的串口,这样才能成功的将程序烧录进单片机 ![](https://www.arduino.cn/data/attachment/forum/201812/27/010006yqw6fmmin6p36i7w.jpg) 当程序成功载入ArduinoNANO上时,你就将拥有这样一款超级拉风的多功能桌面垃圾桶了 还在等什么,赶紧动手试一试这个简单而炫酷的DIY吧 ![](https://www.arduino.cn/data/attachment/forum/201812/27/010006oq7fqurn7yuirqu7.jpg) ![](https://www.arduino.cn/data/attachment/forum/201812/27/010006ppckscz3iy5wjs3t.jpg) 当然,身为设计者的我就当仁不让的将OLED封面设计成我最喜欢的足球队的队徽和“Designed by DHGS”啦,读者朋友们也可以发挥自己的想象,设计出专属于自己的独一无二的OLED界面哦。 ![](https://www.arduino.cn/data/attachment/forum/201812/27/010031q935q4quku5583iu.jpg) 以下是Arduino代码: ~~~ 【 #include <Servo.h> #include <SPI.h> #include <Wire.h> #include <DS1302.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define OLED_RESET 10 #define PIN_SERVO 11 Servo myservo; Adafruit_SSD1306 display(OLED_RESET); #define LOGO16_GLCD_HEIGHT 8 //定义显示高度 #define LOGO16_GLCD_WIDTH 8 //定义显示宽度 const int trig=2; const int echo=3; float distance,distance1,distance2,distance3,distance4,distance5; DS1302 rtc(13, 7, 8); // RST, DAT, CLK /*void getdatetime() { Serial.println(rtc.getDateStr(FORMAT_LONG, FORMAT_LITTLEENDIAN, '/')); Serial.print(rtc.getDOWStr()); Serial.print(" "); Serial.println(rtc.getTimeStr()); }*/ static const unsigned char PROGMEM str_1[] = { }; //photoLOGO KECHUANG static const unsigned char PROGMEM str_2[] = { };//xiaohui static const unsigned char PROGMEM str_3[] = { };//LOCK static const unsigned char PROGMEM str_4[] = { };//GREEN LIGHT static const unsigned char PROGMEM str_5[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFE, 0x00,0x1C,0x00,0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x06, 0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x02, 0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x02, 0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x02, 0x00,0x18,0x1C,0x0F,0x03,0xEC,0xF1,0x80,0x00,0x00,0x41,0xF9,0xF9,0xFB,0xF7,0x1E, 0x00,0x18,0x1C,0x3F,0x8F,0xFD,0xE1,0x80,0x00,0x00,0x47,0xFB,0xF9,0xFB,0xF7,0x9E, 0x00,0x18,0x38,0x7F,0xDF,0xFF,0xC1,0x80,0x00,0x00,0x4F,0x9B,0xBB,0x87,0x0F,0xBE, 0x00,0x18,0x38,0xF3,0xFC,0x1F,0x81,0x80,0x00,0x00,0x4E,0x03,0xFB,0xF7,0xEF,0xBA, 0x00,0x18,0x38,0xE1,0xF8,0x3F,0x01,0x80,0x00,0x00,0x5F,0xF7,0xF3,0xF7,0xEF,0xFA, 0x00,0x18,0x71,0xE3,0xF0,0x3E,0x01,0x80,0x00,0x00,0x5D,0xF7,0xE7,0xEF,0xDD,0xFA, 0x00,0x18,0x71,0xC3,0xF0,0x3F,0x01,0x80,0x00,0x00,0x5C,0x77,0xE7,0x0E,0x1D,0xF2, 0x00,0x18,0x71,0xE7,0x79,0xF7,0x01,0x80,0x00,0x00,0x5F,0xFE,0xF7,0xEF,0xFD,0xF2, 0x00,0x18,0xFF,0xFF,0x7F,0x77,0x81,0x80,0x00,0x00,0x5F,0xEE,0x7F,0xFF,0xF8,0xE2, 0x00,0x18,0xFC,0xFE,0x3F,0x77,0x81,0x80,0x00,0x00,0x4F,0xCE,0x7F,0xFF,0xB8,0xE2, 0x00,0x18,0x00,0x30,0x0C,0x00,0x01,0x80,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x02, 0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x02, 0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x06, 0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFE, 0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF, 0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x03, 0x03,0x18,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x01, 0x03,0x18,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x01, 0x03,0x98,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x01, 0x03,0x98,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x01, 0x7F,0xD8,0x0F,0xCE,0x1C,0xEF,0xC0,0x80,0x00,0x00,0x47,0x39,0xDC,0x67,0xFF,0xFD, 0x7F,0xF8,0x1F,0xCE,0x38,0xEF,0xC0,0x80,0x00,0x00,0x47,0x79,0xF8,0xEF,0xFF,0xFD, 0x7F,0xF8,0x1D,0xDC,0x39,0xFF,0xC0,0x80,0x00,0x00,0x47,0x7B,0xF8,0xEE,0x38,0xE1, 0x7F,0xF8,0x1D,0xDC,0x39,0xDC,0x00,0x80,0x00,0x00,0x47,0xFB,0xB9,0xEE,0x79,0xC1, 0x7F,0xF8,0x3F,0x9C,0x71,0xDF,0x80,0x80,0x00,0x00,0x46,0xFF,0x7F,0xDC,0x71,0xF9, 0x7F,0xF8,0x3F,0xB8,0x73,0xFF,0x00,0x80,0x00,0x00,0x4F,0xFF,0x7F,0xDC,0x71,0xF9, 0x7F,0xF8,0x3B,0xB8,0x73,0xB8,0x00,0x80,0x00,0x00,0x4F,0xBE,0x73,0xDC,0xE3,0x81, 0x7F,0xF8,0x77,0xB8,0x77,0xB8,0x00,0x80,0x00,0x00,0x4F,0xBE,0xE3,0xB8,0xE3,0xF1, 0x7F,0xD8,0x7F,0xFF,0x7F,0x7F,0x00,0x80,0x00,0x00,0x4F,0x3C,0xE3,0xB8,0xE7,0xF1, 0x03,0x98,0x7E,0x7F,0x7E,0x7F,0x00,0x80,0x00,0x00,0x4F,0x38,0xE3,0xB9,0xC7,0xF1, 0x03,0x98,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x01, 0x03,0x18,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x01, 0x02,0x18,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x01, 0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF, 0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFE, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, };//BLUE LIGHT static const unsigned char PROGMEM str_6[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFE, 0x00,0x1C,0x00,0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x06, 0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x02, 0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x02, 0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x02, 0x00,0x18,0x1C,0x0F,0x03,0xEC,0xF1,0x80,0x00,0x00,0x41,0xF9,0xF9,0xFB,0xF7,0x1E, 0x00,0x18,0x1C,0x3F,0x8F,0xFD,0xE1,0x80,0x00,0x00,0x47,0xFB,0xF9,0xFB,0xF7,0x9E, 0x00,0x18,0x38,0x7F,0xDF,0xFF,0xC1,0x80,0x00,0x00,0x4F,0x9B,0xBB,0x87,0x0F,0xBE, 0x00,0x18,0x38,0xF3,0xFC,0x1F,0x81,0x80,0x00,0x00,0x4E,0x03,0xFB,0xF7,0xEF,0xBA, 0x00,0x18,0x38,0xE1,0xF8,0x3F,0x01,0x80,0x00,0x00,0x5F,0xF7,0xF3,0xF7,0xEF,0xFA, 0x00,0x18,0x71,0xE3,0xF0,0x3E,0x01,0x80,0x00,0x00,0x5D,0xF7,0xE7,0xEF,0xDD,0xFA, 0x00,0x18,0x71,0xC3,0xF0,0x3F,0x01,0x80,0x00,0x00,0x5C,0x77,0xE7,0x0E,0x1D,0xF2, 0x00,0x18,0x71,0xE7,0x79,0xF7,0x01,0x80,0x00,0x00,0x5F,0xFE,0xF7,0xEF,0xFD,0xF2, 0x00,0x18,0xFF,0xFF,0x7F,0x77,0x81,0x80,0x00,0x00,0x5F,0xEE,0x7F,0xFF,0xF8,0xE2, 0x00,0x18,0xFC,0xFE,0x3F,0x77,0x81,0x80,0x00,0x00,0x4F,0xCE,0x7F,0xFF,0xB8,0xE2, 0x00,0x18,0x00,0x30,0x0C,0x00,0x01,0x80,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x02, 0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x02, 0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x06, 0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFE, 0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF, 0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x03, 0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x01, 0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x18,0x40,0x00,0x00,0x00,0x00,0x01, 0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x1C,0x40,0x00,0x00,0x00,0x00,0x01, 0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x1C,0x40,0x00,0x00,0x00,0x00,0x01, 0x00,0x18,0x0F,0xCE,0x1C,0xEF,0xC0,0x80,0x03,0xFE,0x47,0x39,0xDC,0x67,0xFF,0xFD, 0x00,0x18,0x1F,0xCE,0x38,0xEF,0xC0,0x80,0x03,0xFF,0x47,0x79,0xF8,0xEF,0xFF,0xFD, 0x00,0x18,0x1D,0xDC,0x39,0xFF,0xC0,0x80,0x03,0xFF,0xC7,0x7B,0xF8,0xEE,0x38,0xE1, 0x00,0x18,0x1D,0xDC,0x39,0xDC,0x00,0x80,0x03,0xFF,0xC7,0xFB,0xB9,0xEE,0x79,0xC1, 0x00,0x18,0x3F,0x9C,0x71,0xDF,0x80,0x80,0x03,0xFF,0xC6,0xFF,0x7F,0xDC,0x71,0xF9, 0x00,0x18,0x3F,0xB8,0x73,0xFF,0x00,0x80,0x03,0xFF,0xCF,0xFF,0x7F,0xDC,0x71,0xF9, 0x00,0x18,0x3B,0xB8,0x73,0xB8,0x00,0x80,0x03,0xFF,0xCF,0xBE,0x73,0xDC,0xE3,0x81, 0x00,0x18,0x77,0xB8,0x77,0xB8,0x00,0x80,0x03,0xFF,0x4F,0xBE,0xE3,0xB8,0xE3,0xF1, 0x00,0x18,0x7F,0xFF,0x7F,0x7F,0x00,0x80,0x03,0xFE,0x4F,0x3C,0xE3,0xB8,0xE7,0xF1, 0x00,0x18,0x7E,0x7F,0x7E,0x7F,0x00,0x80,0x00,0x1E,0x4F,0x38,0xE3,0xB9,0xC7,0xF1, 0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x1C,0x40,0x00,0x00,0x00,0x00,0x01, 0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x18,0x40,0x00,0x00,0x00,0x00,0x01, 0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x10,0x60,0x00,0x00,0x00,0x00,0x01, 0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF, 0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFE, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0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F,0xFF,0xFF, };//CLOCK #if (SSD1306_LCDHEIGHT != 64) #error("Height incorrect, please fix Adafruit_SSD1306.h!"); #endif void setup() { Serial.begin(9600); myservo.attach(PIN_SERVO); pinMode(A2,INPUT_PULLUP); pinMode(A3,INPUT_PULLUP); pinMode(A6,INPUT); pinMode(4,OUTPUT); pinMode(5,OUTPUT); pinMode(6,OUTPUT); pinMode(12,OUTPUT); pinMode(trig,OUTPUT); pinMode(echo,INPUT); // pinMode(10,OUTPUT); display.begin(SSD1306_SWITCHCAPVCC, 0x3C); display.clearDisplay(); myservo.write(50); } int m=0,m1=0,a,a1; int ms=57; float temp; void loop() { if(m1==0) { // digitalWrite(4,LOW); digitalWrite(5,LOW); digitalWrite(6,LOW); digitalWrite(12,LOW); } if(digitalRead(A2)==0) { m++;delay(ms); } if(digitalRead(A3)==0) { m1++;delay(ms); } myservo.write(50); if(m==0) { display.clearDisplay(); digitalWrite(6,HIGH); digitalWrite(5,HIGH); digitalWrite(12,HIGH); } while(m==0) {//display.clearDisplay(); //display.drawBitmap(0, 0, str_2, 128, 64, 1); static unsigned long sensortStamp = 0; if(millis() - sensortStamp > 1500){ sensortStamp = millis(); // read the LM35 sensor value and convert to the degrees every 100ms. int reading = analogRead(A6); temp = reading *0.0048828125*100-8; } // digitalWrite(4,LOW); if(temp>=29) { //digitalWrite(4,HIGH); //delay(1000); } myservo.write(50); if(distance<=7) { myservo.write(180); delay(5000); myservo.write(50); delay(2000); distance=100; } digitalWrite(trig,LOW); delayMicroseconds(2); digitalWrite(trig,HIGH); delayMicroseconds(10); digitalWrite(trig,LOW); distance=pulseIn(echo,HIGH)/58.00;//B display.setTextColor(WHITE,BLACK);//oled display.setTextSize(2); display.setCursor(16,22); display.println(rtc.getTimeStr()); display.setTextColor(BLACK,WHITE);//oled display.setCursor(16,42); display.println(rtc.getDOWStr()); display.setTextColor(WHITE,BLACK);//oled display.setTextSize(1); display.setCursor(80,0); display.println("T="); display.setCursor(96,0); display.println(temp); display.setCursor(0,0); display.println(rtc.getDateStr(FORMAT_LONG, FORMAT_LITTLEENDIAN, '/')); display.display(); if(digitalRead(A2)==0) { m++;delay(ms); } if(digitalRead(A3)==0) { m1++;delay(ms); } } if(distance<=7) { myservo.write(180); delay(5000); myservo.write(50); delay(2000); distance=100; } digitalWrite(trig,LOW); delayMicroseconds(2); digitalWrite(trig,HIGH); delayMicroseconds(10); digitalWrite(trig,LOW); distance=pulseIn(echo,HIGH)/58.00;//B if(m==1) { display.clearDisplay(); digitalWrite(6,LOW); digitalWrite(5,LOW); digitalWrite(12,LOW); display.drawBitmap(0, 0, str_1, 128, 64, 1); display.display(); } if(m==2) { display.clearDisplay(); display.drawBitmap(0, 0, str_3, 128, 64, 1); display.display(); if(m1==1) { m=0; m1=0; } } if(m==3) { display.clearDisplay(); display.drawBitmap(0, 0, str_4, 128, 64, 1); display.display(); if(m1==1) { digitalWrite(5,HIGH); } if(m1==2) { digitalWrite(5,LOW); m1=0; } } if(m==4) { display.clearDisplay(); display.drawBitmap(0, 0, str_5, 128, 64, 1); display.display(); if(m1==1) { digitalWrite(6,HIGH); } if(m1==2) { digitalWrite(6,LOW); m1=0; } } if(m==5) { display.clearDisplay(); display.drawBitmap(0, 0, str_6, 128, 64, 1); display.display(); if(m1==1) { digitalWrite(12,HIGH); } if(m1==2) { digitalWrite(12,LOW); m1=0; } } if(m==6)//clock {if(m1!=1) { display.clearDisplay(); display.drawBitmap(0, 0, str_7, 128, 64, 1); display.display(); } int c=0,s=0,d1=0,d2=0,d3=0,d4=0,d5=0,d6=0,d7=0,d8=0; while(m1==1) { display.clearDisplay(); delay(50); if(digitalRead(A3)==0) { c++;delay(ms); } if(digitalRead(A2)==0) { s++;delay(ms); } //digitalWrite(4,HIGH);//beep display.setTextColor(BLACK,WHITE);//oled display.setTextSize(2); display.setCursor(3,0); display.println(" setclock "); display.setTextColor(WHITE,BLACK);//oled display.setTextSize(2); display.setCursor(0,20); display.println(d1); display.setCursor(16,20); display.println(d2); display.setCursor(32,20); display.println(":"); display.setCursor(48,20); display.println(d3); display.setCursor(64,20); display.println(d4); display.setCursor(80,20); display.println(":"); display.setCursor(96,20); display.println(d5); display.setCursor(112,20); display.println(d6); display.display(); if(c==1) { m1=2; } } if(m1==2) {digitalWrite(4,LOW); m1=0; m=6; } } if(m==7) { m=2; delay(65); } } 】 ~~~