lcd
This commit is contained in:
parent
bd4858ccb7
commit
037f7ce38a
55
пример с библиотеками ардуино.txt
Normal file
55
пример с библиотеками ардуино.txt
Normal file
@ -0,0 +1,55 @@
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
LiquidCrystal_I2C lcd(32, 16, 2);
|
||||
|
||||
byte MasArray[32] = {
|
||||
78, 69, 71, 82, 32, 77, 65, 78, 68, 65, 82, 73, 78, 33, 33, 33,
|
||||
32, 32, 32, 32, 46, 32, 32, 32, 32, 46, 32, 32, 32, 46, 37, 33
|
||||
};
|
||||
|
||||
char colum1[17];
|
||||
char colum2[17];
|
||||
|
||||
unsigned long previousTime = 0;
|
||||
const unsigned long interval = 200;
|
||||
|
||||
void delay_ms(unsigned long milliseconds) {
|
||||
unsigned long startTime = millis();
|
||||
while (millis() - startTime < milliseconds) {
|
||||
// Wait until the specified time has passed
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
lcd.init();
|
||||
lcd.backlight();
|
||||
|
||||
for (int i = 0; i < 32; i++) {
|
||||
if (i < 16) {
|
||||
colum1[i] = (char)MasArray[i];
|
||||
} else {
|
||||
colum2[i - 16] = (char)MasArray[i];
|
||||
}
|
||||
}
|
||||
colum1[16] = '\0';
|
||||
colum2[16] = '\0';
|
||||
}
|
||||
|
||||
void loop() {
|
||||
unsigned long currentTime = millis();
|
||||
|
||||
if (currentTime - previousTime >= interval) {
|
||||
previousTime = currentTime;
|
||||
|
||||
for (int i = 15; i > 0; i--) {
|
||||
lcd.setCursor(i, 0);
|
||||
lcd.print(colum1);
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print(colum2);
|
||||
delay_ms(200); // Use the custom delay_ms() function instead of delay()
|
||||
lcd.clear();
|
||||
}
|
||||
}
|
||||
}
|
93
типо с.txt
Normal file
93
типо с.txt
Normal file
@ -0,0 +1,93 @@
|
||||
#include <Wire.h>
|
||||
|
||||
#define LCD_ADDRESS 0x27
|
||||
#define LCD_ROWS 2
|
||||
#define LCD_COLUMNS 16
|
||||
|
||||
byte MasArray[32] = {
|
||||
78, 69, 71, 82, 32, 77, 65, 78, 68, 65, 82, 73, 78, 33, 33, 33,
|
||||
32, 32, 32, 32, 46, 32, 32, 32, 32, 46, 32, 32, 32, 46, 37, 33
|
||||
};
|
||||
|
||||
char colum1[17];
|
||||
char colum2[17];
|
||||
|
||||
unsigned long previousTime = 0;
|
||||
const unsigned long interval = 200;
|
||||
|
||||
void delay_ms(unsigned long milliseconds) {
|
||||
unsigned long startTime = millis();
|
||||
while (millis() - startTime < milliseconds) {
|
||||
// Wait until the specified time has passed
|
||||
}
|
||||
}
|
||||
|
||||
void lcdCommand(uint8_t command) {
|
||||
Wire.beginTransmission(LCD_ADDRESS);
|
||||
Wire.write(0x00);
|
||||
Wire.write(command);
|
||||
Wire.endTransmission();
|
||||
}
|
||||
|
||||
void lcdWrite(uint8_t value) {
|
||||
Wire.beginTransmission(LCD_ADDRESS);
|
||||
Wire.write(0x40);
|
||||
Wire.write(value);
|
||||
Wire.endTransmission();
|
||||
}
|
||||
|
||||
void lcdSetCursor(uint8_t row, uint8_t col) {
|
||||
uint8_t row_offsets[] = { 0x00, 0x40 };
|
||||
uint8_t offset = row_offsets[row] + col;
|
||||
lcdCommand(0x80 | offset);
|
||||
}
|
||||
|
||||
void lcdClear() {
|
||||
lcdCommand(0x01); // Clear display
|
||||
delay_ms(2); // Delay for clear display command
|
||||
}
|
||||
|
||||
void lcdInit() {
|
||||
Wire.begin();
|
||||
lcdCommand(0x38); // Function set: 8-bit mode, 2 lines, 5x8 font
|
||||
lcdCommand(0x0C); // Display control: Display ON, Cursor OFF, Blinking OFF
|
||||
lcdClear();
|
||||
}
|
||||
|
||||
void lcdPrint(const char* str) {
|
||||
while (*str) {
|
||||
lcdWrite(*str++);
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
lcdInit();
|
||||
|
||||
for (int i = 0; i < 32; i++) {
|
||||
if (i < 16) {
|
||||
colum1[i] = (char)MasArray[i];
|
||||
} else {
|
||||
colum2[i - 16] = (char)MasArray[i];
|
||||
}
|
||||
}
|
||||
colum1[16] = '\0';
|
||||
colum2[16] = '\0';
|
||||
}
|
||||
|
||||
void loop() {
|
||||
unsigned long currentTime = millis();
|
||||
|
||||
if (currentTime - previousTime >= interval) {
|
||||
previousTime = currentTime;
|
||||
|
||||
for (int i = 15; i > 0; i--) {
|
||||
lcdSetCursor(i, 0);
|
||||
lcdPrint(colum1);
|
||||
lcdSetCursor(0, 1);
|
||||
lcdPrint(colum2);
|
||||
delay_ms(200); // Use the custom delay_ms() function instead of delay()
|
||||
lcdClear();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user