-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
42 lines (32 loc) · 868 Bytes
/
main.c
File metadata and controls
42 lines (32 loc) · 868 Bytes
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
#include <avr/interrupt.h> // Definicje nazw pinow układu
#define F_CPU 8000000UL // Zapisanie predkosci procesora w Hz dla biblioteki delay.h
#include <util/delay.h>
// Deklaracja funkcji mrugajacej dioda
void blinkEm(uint8_t count);
// Glowna funkcja programu
int main()
{
DDRD = _BV(PD4); // Ustawienie PORT D 4 (noga 8)jako wyjscie
while (1) // Petla, ktora nigdy sie nie konczy
{
blinkEm(1); // Wywolanie funkcji mrugajacej dioda
}
}
// Funkcja mrugajaca dioda LED ustalona ilosc razy
void blinkEm(uint8_t count)
{
// petla ilosci mrugniec
// dziala az zmienna count osiagnie wartosc 0
while (count > 0)
{
// Wlaczenie diody led
PORTD = _BV(PD4);
// oczekiwanie 1 s
_delay_ms(1000);
// wylaczenie diody led
PORTD = ~_BV(PD4);
_delay_ms(1000);
// odliczanie ilosci mrugniec
count--;
}
}