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

aitu6661年前 (2025-02-01)常识62
用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(); 

相关文章

玩女人小游戏(播放女生玩的游戏)

好玩的女生游戏有哪些 适合女生玩的款女性向手游推荐在游戏世界中,女生玩家也有着独特的喜好,尤其是那些融合了剧情、养成、恋爱等元素的女性向游戏,深受广大女生的喜爱。无论是喜欢精美换装、与角色互动的乙女游...

洛克王国力量组(洛克王国能力计算公式)

洛克王国宠物技能效果盘点 攻防篇本文关键词:洛克王国降低物理攻击技能,降低物理攻击技能,洛克王国宠物技能特效大盘点,降低物理攻击,洛克王国技能特效大盘点小导航:?洛克王国物理攻击型宠物技能?锁国防御宠...

赛尔号动画片第3季(赛尔号动画片第3季在线观看)

《赛尔号》制作团队解散,季成最终季,终究还是没找到无尽能源#头条创作挑战赛#《赛尔号》动画制作团队解散,恐再无后续月6日,《赛尔号》动画的导演王章俊正式宣布了《赛尔号》动画第季将成为最后一季,“赛尔号...

小鳄鱼爱洗完整版下载(小鳄鱼爱洗澡破解版中文版)

寓教于乐培养出小天才 教育类应用推荐【手机中国软件】孩子的教育是家长们最为看重的事,孩子还没有出生就要去做胎教,而出生之后的教育方式更是花样繁多,补习班、舞蹈课,把几岁的孩子搞得比成年人还累,您有没有...

赛尔号艾里逊(赛尔号艾里逊结局)

赛尔号的7个宇宙海盗,你还记得吗前言:宇宙海盗有阴险沉稳的迪恩,耍小聪明的艾里逊,狂妄自大的佐格,心狠手辣的吉约,怪异的煞德罗,娘娘腔的法尔多斯,沉着冷静的卡罗尔Hello,赛尔号小伙伴们,我是小虾尾...

三国杀online网页版(三国杀online网页版登录)

三国杀OL经典服萌新快进来看以下内容都是个人描述 如有漏洞 希望各位能够在评论区斧正[捂脸][捂脸][捂脸]新手6人场概念与卡牌身份主公(1)、忠臣(1)、反贼(3)、内奸(1)主忠方胜利条件:击败所...