如何制作火柴人动画(如何制作火柴人动画书)

aitu6661年前 (2025-02-01)常识50
用arduino和OLED制作火柴人奔跑动画

用arduino和OLED制作火柴人奔跑动画

2.为动画创建位图

这可能是最耗时的步骤。你必须创建一组框架,这将适合128x32格式。您可以尝试从任何拖鞋剪贴片中创建它们,您可以在网上找到。

所有的框架需要是黑白的!!!

我创造了显示奔跑生物的帧,一共八张

3.连接

OLED

arduino

GND

GND

VCC

VCC

SDA

A4

SCK

A5

OLED 显示屏有四个引脚,分别是:
1.SDA(数据线) SCK(时钟线) VDD(3.3V) GND
2.在UNO开发板上I2C接口,SDA对应D4,SCK对应D5
3.在MEGA2560开发板上I2C接口,SDA对应D20, SCL对应D21

4.创建位图的代码表示

①使用在线取模软件

要创建位图的代码表示,我们将使用在线工具

你可以找到它去下面的网址

https://javl.github.io/image2cpp/

②执行以下步骤:

  • Select Image(选择图像)部分,逐个打开帧文件
  • 通过检查图像设置部分检查上传的Image Settings(图像)是否正确
  • 如果想要具有黑色背景,并且只点亮线像素,请检查倒置图像颜色,在Background选择Black
  • Output(输出部分)在Code output format(代码输出格式)中指定&#;Arduino code ,single bitmap&#;在Identifier/Prefix(标识符/前缀)中提供动画名称,必须要英文按Generate code(生成按钮)保存生成的代码。它将被粘贴到arduino编译器

4.创建动画代码

①首先,我们需要引用所需的头文件

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

前一个用于 I2C 接口,其他两个用于与 OLED 显示器配合工作

②我们需要定义显示屏的大小

#define SCREEN_WIDTH  // OLED 显示宽度 in pixels
#define SCREEN_HEIGHT  // OLED 显示高度 in pixels

③引用函数库,里面有宣布通过 OLED 显示连接的引脚。有了这些别针,我们宣布显示器本身

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

然后,您必须复制粘贴我们从Image2cpp 中获得的代码

这是一个相当长的代码,所以我不会粘贴在这里的全部。我只显示一帧

static const unsigned char Frame1 [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 
0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x83, 0x80, 0x00, 0x00, 0x00, 
0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x03, 0x0c, 
0x40, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xe1, 0x0c, 0x60, 0x00, 0x00, 0x00, 0x00, 0xf0, 
0x00, 0x1f, 0xff, 0x80, 0x20, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x01, 0xf9, 0xe0, 0x20, 0x00, 
0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0xcc, 0x78, 0x60, 0x00, 0x00, 0x03, 0xe7, 0x80, 0x00, 0x00, 
0x64, 0x1f, 0xc0, 0x00, 0x00, 0x0e, 0xff, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x1c, 
0x0e, 0x00, 0x00, 0x00, 0x33, 0xf0, 0x00, 0x00, 0x00, 0x30, 0xf8, 0x00, 0x00, 0x00, 0x18, 0x1f, 
0xf0, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0xfc, 0x00, 0x00, 
0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x01, 0x86, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

然后,在设置功能中,我们正在初始化 OLED 显示屏

void setup() {
Serial.begin);
delay);
// by default, we&#;ll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64)
}

然后,我们有循环功能,我们重播所有帧在50ms间隔

void loop() {

// Diplay Animation

// Frame1
display.clearDisplay();
display.drawBitmap(,0,RUN1, , , 1);
display.display();
delay();

// Frame2
display.clearDisplay();
display.drawBitmap(,0,RUN2, , , 1);
display.display();
delay();

// Frame3
display.clearDisplay();
display.drawBitmap(,0,RUN3, , , 1);
display.display();
delay();

// Frame4
display.clearDisplay();
display.drawBitmap(,0,RUN4, , , 1);
display.display();
delay();

// Frame5
display.clearDisplay();
display.drawBitmap(,0,RUN5, , , 1);
display.display();
delay();

// Frame6
display.clearDisplay();
display.drawBitmap(,0,RUN6, , , 1);
display.display();
delay();

// Frame7
display.clearDisplay();
display.drawBitmap(,0,RUN7, , , 1);
display.display();
delay();

// Frame8
display.clearDisplay();
display.drawBitmap(,0,RUN8, , , 1);
display.display();
delay();

// Frame9
display.clearDisplay();
display.drawBitmap(,0,RUN9, , , 1);
display.display();
delay(); 

// Frame10
display.clearDisplay();
display.drawBitmap(,0,RUN10, , , 1);
display.display();
delay(); 

相关文章

武侠剧情介绍(武侠剧情电视剧)

从历史的角度看“武侠”,解析中国武侠传统文化武侠是江南三月,莺啼草长之时春日下的市井茶摊;是城郊竹林身着青衫手秉长剑的清风徐徐;是披甲入戎襄阳城头的侠之大义;武侠,是你我心中挥之不去的儿时旧梦.......

倚天屠龙记手游(倚天屠龙记手游官网)

搞趣网:《倚天屠龙记》手游评测:倚天不出谁与争锋金庸大师笔下的武侠世界色彩纷呈,不管是《射雕英雄传》《神雕侠侣》还是《天龙八部》《笑傲江湖》无一不是脍炙人口的佳作。而随着近些年手游的逐步发展,这些作品...

坑爸诈骗犯2(坑爸诈骗犯攻略)

又有爸爸被“女儿”骗了!这回诈骗犯也是一对父女涉嫌掩饰、隐瞒犯罪所得罪的陈某接受警方讯问 崇明公安供图新民晚报讯(记者 陈浩 通讯员 陈卫国)今年月,杨先生因轻信“女儿”的QQ信息向陌生人账户转账导致...

迷你世界太空(迷你世界太空巨人怎么召唤)

迷你世界 为绿化做贡献 太空上栽花种树哈喽,小伙伴们大家好。在现代工业发展异常迅猛的今天,人们已经越来越意识到了绿化的重要性,绿化不仅具有美化环境、净化空气、调节气温、降低噪音,促进身体健康等多方面的...

警察大战僵尸(警察大战僵尸2破解版)

警察大战“僵尸车”,一个月腾空个被霸占车位长期霸占车位,遗弃无人维护,外观邋遢破旧,早已达到强制报废标准,它们被大家形象地称之为“僵尸车”。近期,针对市民深恶痛绝的“僵尸车”,佛山禅城公安依托“你举报...

一举两得任务(一举两得怎么理解)

王者荣耀:作为一个过来人,教你又快又轻松的通关梦境修炼任务哈喽,大家好,我是凌嘉游戏。今天我要给大家讲解的是如何快速通关王者荣耀云端梦境中的梦境修炼任务。首先要说的是,梦境修炼的难度并不大,这个任务的...