lab 5
This commit is contained in:
parent
0695d67e68
commit
03346ce51d
17
lab_5/task_1.ino
Normal file
17
lab_5/task_1.ino
Normal file
@ -0,0 +1,17 @@
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
LiquidCrystal_I2C lcd(0x27, 16, 2);
|
||||
|
||||
void setup() {
|
||||
lcd.init();
|
||||
lcd.backlight();
|
||||
lcd.print("Andrew");
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print("Shved");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
lcd.scrollDisplayLeft();
|
||||
delay(100);
|
||||
}
|
||||
14
lab_5/task_1.pcf
Normal file
14
lab_5/task_1.pcf
Normal file
@ -0,0 +1,14 @@
|
||||
version,0,0,0:0.9.2
|
||||
scale,0,0,0:1.800000
|
||||
position,1390,607,1022:761
|
||||
boardp,1841,37,855:577
|
||||
spare_on,0,0,0:1
|
||||
osc_on,0,0,0:0
|
||||
useAlias,0,0,0:0
|
||||
debug,0,1,0:
|
||||
osc_cfg,1037,189,0:1.000000,0.000000,1,1,2.500000,0,5,1,0,0
|
||||
osc_ch1,0,0,0:2.000000,0.000000,1,#FF0000,0,23 PC0/A0
|
||||
osc_ch2,0,0,0:2.000000,0.000000,0,#00FF00,0,8 GND
|
||||
IO Virtual Term,13,10,0:3,2,1,9600,0,283,240,531,408
|
||||
7 Segments Display,218,9,0:4,5,6,11,12,13,14,0,0,0,0,0,1,1
|
||||
Push Buttons,15,173,0:15,0,0,0,0,0,0,0,1,0,1
|
||||
34
lab_5/task_2.ino
Normal file
34
lab_5/task_2.ino
Normal file
@ -0,0 +1,34 @@
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
const int TEMPERATURE_SENSOR_IN = A0;
|
||||
float temperature_value = 0;
|
||||
|
||||
LiquidCrystal_I2C lcd(0x27, 16, 2);
|
||||
|
||||
inline float get_C_temperature() {
|
||||
return analogRead(TEMPERATURE_SENSOR_IN) * (5.0 / 1023.0) * 100;
|
||||
}
|
||||
|
||||
inline float C_to_F_temperature(float C_temperature) {
|
||||
return (C_temperature * 9.0 / 5.0) + 32.0;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
lcd.init();
|
||||
lcd.backlight();
|
||||
lcd.print("T:");
|
||||
lcd.setCursor(10, 0);
|
||||
lcd.print("C");
|
||||
lcd.setCursor(10, 1);
|
||||
lcd.print("F");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
temperature_value = get_C_temperature();
|
||||
lcd.setCursor(3, 0);
|
||||
lcd.print(temperature_value);
|
||||
lcd.setCursor(3, 1);
|
||||
lcd.print(C_to_F_temperature(temperature_value));
|
||||
delay(100);
|
||||
}
|
||||
13
lab_5/task_2.pcf
Normal file
13
lab_5/task_2.pcf
Normal file
@ -0,0 +1,13 @@
|
||||
version,0,0,0:0.9.2
|
||||
scale,0,0,0:1.500000
|
||||
position,1207,867,987:501
|
||||
boardp,1488,0,706:460
|
||||
spare_on,0,0,0:1
|
||||
osc_on,0,0,0:0
|
||||
useAlias,0,0,0:0
|
||||
debug,0,1,0:
|
||||
osc_cfg,1037,189,0:1.000000,0.000000,1,1,2.500000,0,5,1,0,0
|
||||
osc_ch1,0,0,0:2.000000,0.000000,1,#FF0000,0,23 PC0/A0
|
||||
osc_ch2,0,0,0:2.000000,0.000000,0,#00FF00,0,8 GND
|
||||
IO Virtual Term,13,10,0:3,2,1,9600,0,283,240,531,408
|
||||
7 Segments Display,218,9,0:17,13,6,4,3,16,11,5,12,14,15,18,0,0
|
||||
19
lab_5/task_3.ino
Normal file
19
lab_5/task_3.ino
Normal file
@ -0,0 +1,19 @@
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
const char surname[] = {'S', 'h', 'w', 'e', 'd'};
|
||||
|
||||
LiquidCrystal_I2C lcd(0x27, 16, 2);
|
||||
|
||||
void setup() {
|
||||
lcd.init();
|
||||
lcd.backlight();
|
||||
for (int i = i; i < sizeof(surname) / sizeof(char); ++i) {
|
||||
lcd.setCursor(i, i % 2);
|
||||
lcd.print(surname[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
13
lab_5/task_3.pcf
Normal file
13
lab_5/task_3.pcf
Normal file
@ -0,0 +1,13 @@
|
||||
version,0,0,0:0.9.2
|
||||
scale,0,0,0:1.800000
|
||||
position,1386,393,808:975
|
||||
boardp,1488,0,706:460
|
||||
spare_on,0,0,0:1
|
||||
osc_on,0,0,0:0
|
||||
useAlias,0,0,0:0
|
||||
debug,0,1,0:
|
||||
osc_cfg,1037,189,0:1.000000,0.000000,1,1,2.500000,0,5,1,0,0
|
||||
osc_ch1,0,0,0:2.000000,0.000000,1,#FF0000,0,23 PC0/A0
|
||||
osc_ch2,0,0,0:2.000000,0.000000,0,#00FF00,0,8 GND
|
||||
IO Virtual Term,6,9,0:3,2,1,9600,0,283,240,531,408
|
||||
7 Segments Display,7,175,0:4,5,6,11,12,13,14,15,0,0,0,0,1,1
|
||||
31
lab_5/task_4.ino
Normal file
31
lab_5/task_4.ino
Normal file
@ -0,0 +1,31 @@
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
const uint8_t sh[] = { 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x1F };
|
||||
const uint8_t a[] = { 0x0, 0x0, 0x0, 0x1E, 0x11, 0x1E, 0x11, 0x1E };
|
||||
const uint8_t e[] = { 0x0, 0x0, 0x0, 0x1F, 0x10, 0x1F, 0x10, 0x1F };
|
||||
const uint8_t d[] = { 0x0, 0x0, 0x0, 0xE, 0xA, 0xA, 0x1F, 0x11 };
|
||||
const char surname[] = {'S', 'h', 'w', 'e', 'd'};
|
||||
|
||||
LiquidCrystal_I2C lcd(0x27, 16, 2);
|
||||
|
||||
void setup() {
|
||||
lcd.init();
|
||||
lcd.backlight();
|
||||
|
||||
lcd.createChar(0, sh);
|
||||
lcd.createChar(1, a);
|
||||
lcd.createChar(2, e);
|
||||
lcd.createChar(3, d);
|
||||
|
||||
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.write(0);
|
||||
lcd.write(1);
|
||||
lcd.write(2);
|
||||
lcd.write(3);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
15
lab_5/task_4.pcf
Normal file
15
lab_5/task_4.pcf
Normal file
@ -0,0 +1,15 @@
|
||||
version,0,0,0:0.9.2
|
||||
scale,0,0,0:1.400000
|
||||
position,895,188,1501:1038
|
||||
boardp,1841,37,855:577
|
||||
spare_on,0,0,0:1
|
||||
osc_on,0,0,0:0
|
||||
useAlias,0,0,0:0
|
||||
debug,0,1,0:
|
||||
osc_cfg,1037,189,0:1.000000,0.000000,1,1,2.500000,0,5,1,0,0
|
||||
osc_ch1,0,0,0:2.000000,0.000000,1,#FF0000,0,23 PC0/A0
|
||||
osc_ch2,0,0,0:2.000000,0.000000,0,#00FF00,0,8 GND
|
||||
IO Virtual Term,10,8,0:3,2,1,115200,1,1906,422,531,408
|
||||
7 Segments Display,222,9,0:4,5,6,11,12,13,14,15,16,17,18,19,1,0
|
||||
RTC ds1307,11,171,0:27,28,0
|
||||
DHT22 (Temp. Hum.),224,280,0:24,23,49
|
||||
29
lab_5/task_4_dec.pcf
Normal file
29
lab_5/task_4_dec.pcf
Normal file
@ -0,0 +1,29 @@
|
||||
version,0,0,0:0.9.2
|
||||
scale,0,0,0:1.100000
|
||||
position,1662,308,785:903
|
||||
boardp,1929,40,855:577
|
||||
spare_on,0,0,0:1
|
||||
osc_on,0,0,0:0
|
||||
useAlias,0,0,0:1
|
||||
debug,0,1,0:
|
||||
osc_cfg,1037,189,0:1.000000,0.000000,1,1,2.500000,0,5,1,0,0
|
||||
osc_ch1,0,0,0:2.000000,0.000000,1,#FF0000,0,23 PC0/A0
|
||||
osc_ch2,0,0,0:2.000000,0.000000,0,#00FF00,0,8 GND
|
||||
IO Virtual Term,10,8,0:3,2,1,9600,1,1937,421,531,408
|
||||
7 Segments Display,222,9,0:115,116,117,118,119,120,121,122,16,17,18,19,1,1
|
||||
RTC ds1307,11,171,0:27,28,0
|
||||
Push Buttons,11,356,0:23,0,0,0,0,0,0,0,1,1,1
|
||||
DHT22 (Temp. Hum.),224,280,0:24,114,49
|
||||
Logic Block,652,14,0:15,0,0,0,0,0,0,0,0,110,0,1
|
||||
Logic Block,810,17,0:16,0,0,0,0,0,0,0,0,111,0,1
|
||||
Logic Block,651,130,0:17,0,0,0,0,0,0,0,0,112,0,1
|
||||
Logic Block,1129,18,0:18,0,0,0,0,0,0,0,0,113,0,1
|
||||
Logic Block,1291,18,0:19,0,0,0,0,0,0,0,0,114,0,1
|
||||
Logic Block,652,247,0:110,111,112,0,0,0,0,0,0,115,2,3
|
||||
Logic Block,652,366,0:15,111,112,0,0,0,0,0,0,116,2,3
|
||||
Logic Block,651,483,0:110,16,112,0,0,0,0,0,0,117,2,3
|
||||
Logic Block,652,599,0:15,16,112,0,0,0,0,0,0,118,2,3
|
||||
Logic Block,652,714,0:110,111,17,0,0,0,0,0,0,119,2,3
|
||||
Logic Block,652,829,0:15,111,17,0,0,0,0,0,0,120,2,3
|
||||
Logic Block,652,946,0:110,16,17,0,0,0,0,0,0,121,2,3
|
||||
Logic Block,651,1060,0:15,16,17,0,0,0,0,0,0,122,2,3
|
||||
44
lab_5/task_5.ino
Normal file
44
lab_5/task_5.ino
Normal file
@ -0,0 +1,44 @@
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
#include <Fonts/FreeMono9pt7b.h>
|
||||
|
||||
#define POTENTIOMETER_IN A0
|
||||
#define SCREEN_WIDTH 128
|
||||
#define SCREEN_HEIGHT 64
|
||||
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
|
||||
|
||||
int i, wave = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
|
||||
Serial.println("SSD1306 allocation failed");
|
||||
for (;;);
|
||||
}
|
||||
delay(2000);
|
||||
|
||||
display.setFont(&FreeMono9pt7b);
|
||||
display.clearDisplay();
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0, 20);
|
||||
display.println("Shved\nAndrii\nIO-23");
|
||||
display.display();
|
||||
delay(3000);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
display.clearDisplay();
|
||||
|
||||
for (i = 0; i < SCREEN_WIDTH; ++i) {
|
||||
wave = analogRead(POTENTIOMETER_IN);
|
||||
wave = map(wave, 0, 1023, SCREEN_HEIGHT - 1, 0);
|
||||
wave = constrain(wave, 0, SCREEN_HEIGHT);
|
||||
|
||||
display.drawPixel(i, wave, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user