一、线序
1、0.91 inch OLED屏幕
2、1.54 inch LCD屏幕
- 紫:VCC
- 白:GND
- 绿:DIN
- 橙:CLK
- 黄:CS
- 蓝:DC
- 棕:RST
- 灰:BL
二、录制素材
随便找个录音软件,录制三段关键词的音频,之后使用ffmpeg转成指定格式
1 2 3
| ffmpeg -i input_audio.mp3 -acodec pcm_s16le -ar 16000 -ac 1 record1.wav ffmpeg -i input_audio.mp3 -acodec pcm_s16le -ar 16000 -ac 1 record2.wav ffmpeg -i input_audio.mp3 -acodec pcm_s16le -ar 16000 -ac 1 record3.wav
|
三、问问AI
1、arduino相关
编写arduino程序,从串口读入一个十六进制数,将其转化为二进制并以数组的形式存储每一位
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| byte hex; byte binary[8];
void setup() { Serial.begin(9600); }
void loop() { if(Serial.available() > 0) { hex = Serial.read(); for(int i=0; i<8; i++) { binary[i] = (hex>>i)&0x01; } for(int i=7; i>=0; i--) { Serial.print(binary[i]); } Serial.println(); } }
|
屏幕滚动显示
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
| #define TFT_DC 9 #define TFT_CS 10 #define TFT_RST 8
#define FONT_SIZE_SMALL 1 #define FONT_SIZE_MEDIUM 2 #define FONT_SIZE_LARGE 3
#define SCROLL_UP 0 #define SCROLL_DOWN 1
#define SCROLL_SLOW 0 #define SCROLL_MEDIUM 1 #define SCROLL_FAST 2
String scroll_str = "Arduino ST7789滚动显示屏";
int str_len = scroll_str.length();
int scroll_pos = 0;
int scroll_dir = SCROLL_UP;
int scroll_speed = SCROLL_SLOW;
int font_size = FONT_SIZE_MEDIUM;
int scroll_delay = 200;
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
void setup() { tft.initR(INITR_BLACKTAB); tft.fillScreen(ST77XX_BLACK); tft.setRotation(3); }
void loop() { tft.setTextSize(font_size);
scrollText(scroll_str, scroll_pos, scroll_dir, scroll_speed);
scroll_pos++; if (scroll_pos > str_len * font_size * 6) { scroll_pos = 0; }
delay(scroll_delay); }
void scrollText(String str, int pos, int dir, int speed) { int x_pos = pos; if (dir == SCROLL_DOWN) { x_pos = -pos; }
int delay_time = 200; if (speed == SCROLL_MEDIUM) { delay_time = 150; } else if (speed == SCROLL_FAST) { delay_time = 100; }
int str_len = str.length();
for (int i = 0; i < str_len; i++) { tft.setCursor(x_pos, 0);
char c = str.charAt(i);
tft.print(c);
x_pos += font_size * 6; if (x_pos > tft.width()) { x_pos = 0; }
delay(delay_time); } }
|