Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
dmpada
/
eriala-2024
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b6aaa60b
authored
6 months ago
by
Risto Heinsar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added wk3 demo codes
parent
9a4348a5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
150 additions
and
0 deletions
lab3/lab3_demo_lcd/lab3_demo_lcd.ino
lab3/lab3_demo_light_dependent_resistor/lab3_demo_light_dependent_resistor.ino
lab3/lab3_demo_scheduler/lab3_demo_scheduler.ino
lab3/lab3_demo_thermistor/lab3_demo_thermistor.ino
lab3/lab3_demo_time_passed/lab3_demo_time_passed.ino
lab3/lab3_demo_lcd/lab3_demo_lcd.ino
0 → 100644
View file @
b6aaa60b
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C
lcd
(
0x27
,
16
,
2
);
const
uint16_t
tickDelay
=
1000
;
uint32_t
tickCount
=
0
;
void
setup
()
{
// Initsialiseerime LCD
lcd
.
init
();
// Lülitame LCD taustavalguse sisse
lcd
.
backlight
();
// Kirjutame teksti LCDle, vaikimisi esimese rea algusse kui asukohta ei täpsusta
lcd
.
print
(
"Korduste arv:"
);
// Kirjtuame teise rea positsioonidele 15 ja 16 naerunäo
lcd
.
setCursor
(
14
,
1
);
lcd
.
print
(
":)"
);
}
void
loop
()
{
// Kirjutame teise rea algusse korduste arv
lcd
.
setCursor
(
0
,
1
);
lcd
.
print
(
tickCount
);
lcd
.
print
(
" korda"
);
tickCount
++
;
delay
(
tickDelay
);
}
This diff is collapsed.
Click to expand it.
lab3/lab3_demo_light_dependent_resistor/lab3_demo_light_dependent_resistor.ino
0 → 100644
View file @
b6aaa60b
/* Fototakisti viigu number */
#define LDR_PIN A0
/* Arduino ADC on 10-bitine - st 2^10 = 1024 */
#define ADC_RESOLUTION 1024
/* Kasuta enda Arduino võrdluspinget */
#define REF_VOLTAGE 9.00
const
int
tickDelay
=
500
;
void
setup
()
{
Serial
.
begin
(
9600
);
pinMode
(
LDR_PIN
,
INPUT
);
}
void
loop
()
{
int
ldrReading
=
analogRead
(
LDR_PIN
);
float
ldrVoltage
=
(
ldrReading
/
(
float
)
ADC_RESOLUTION
)
*
REF_VOLTAGE
;
Serial
.
print
(
"Valgustakisti väärtus: "
);
Serial
.
print
(
ldrReading
);
Serial
.
print
(
"; Mõõdetud pinge: "
);
Serial
.
println
(
ldrVoltage
);
delay
(
tickDelay
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lab3/lab3_demo_scheduler/lab3_demo_scheduler.ino
0 → 100644
View file @
b6aaa60b
#define TICK_LIMIT 6
uint16_t
tickDelay
=
166
;
uint8_t
tickCount
=
0
;
void
setup
()
{
Serial
.
begin
(
9600
);
}
void
loop
()
{
/* Ülesannet lahendatakse 2 korda sekundis */
if
(
tickCount
%
3
==
0
)
{
Serial
.
print
(
millis
()
/
(
float
)
1000
);
Serial
.
println
(
" Olen Boe-Bot"
);
}
/* Ülesannet lahendatakse 3 korda sekundis */
if
(
tickCount
%
2
==
0
)
{
Serial
.
print
(
millis
()
/
(
float
)
1000
);
Serial
.
println
(
" Beep-Boop"
);
}
tickCount
++
;
/* Väldime loenduril tekkivat täisarvu ületäitumist! */
if
(
tickCount
==
TICK_LIMIT
)
{
tickCount
=
0
;
}
delay
(
tickDelay
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lab3/lab3_demo_thermistor/lab3_demo_thermistor.ino
0 → 100644
View file @
b6aaa60b
#define THERMISTOR_PIN A0
/* Arduino ADC on 10-bitine - st 2^10 = 1024 */
#define ADC_RESOLUTION 1024
/* Kasuta enda Arduino võrdluspinget */
#define REF_VOLTAGE 9.00
const
uint16_t
tickDelay
=
500
;
void
setup
()
{
Serial
.
begin
(
9600
);
pinMode
(
THERMISTOR_PIN
,
INPUT
);
}
void
loop
()
{
uint16_t
tempSensor
=
analogRead
(
THERMISTOR_PIN
);
float
tempInC
=
((
tempSensor
/
(
float
)
ADC_RESOLUTION
)
*
REF_VOLTAGE
-
0.5
)
*
100
;
Serial
.
print
(
"Temperatuur: "
);
Serial
.
print
(
tempInC
);
Serial
.
println
(
"°C"
);
delay
(
tickDelay
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lab3/lab3_demo_time_passed/lab3_demo_time_passed.ino
0 → 100644
View file @
b6aaa60b
#define MSEC_IN_SEC 1000
const
int
tickDelay
=
250
;
void
setup
()
{
Serial
.
begin
(
9600
);
}
void
loop
()
{
uint32_t
timeInMs
=
millis
();
uint8_t
timeSecPassed
=
timeInMs
/
MSEC_IN_SEC
;
uint16_t
timeMsPassed
=
timeInMs
%
MSEC_IN_SEC
;
Serial
.
print
(
"Aega möödunud: "
);
Serial
.
print
(
timeSecPassed
);
Serial
.
print
(
"s "
);
Serial
.
print
(
timeMsPassed
);
Serial
.
println
(
"ms"
);
delay
(
tickDelay
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment