Last active
April 8, 2020 19:48
-
-
Save fpawel/246cfb03b5c221fafab1bbc787b84c5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define F_CPU 4000000UL | |
#include <avr/io.h> | |
#include <util/delay.h> | |
int main() | |
{ | |
DDRC = 0b0001111; | |
DDRB = 0b11111111; | |
DDRD = 0b11111111; | |
// предположим x - это состояние порта вывода твоего контроллера | |
unsigned char x = 0; | |
// иммитация цикла | |
for (int i = 0; i < 20; ++i) | |
{ | |
// на каждой итерации если порт 11111111, то обнуление и остановка до следующего сигнала | |
if (x == 0xFF) | |
{ | |
x = 0; | |
PORTB = x; | |
} | |
else | |
{ | |
// иначе двоичный сдвиг влево и прибавить 1 | |
x = (x << 1) + 1; | |
PORTB = x; | |
// пауза 1c | |
_delay_ms(1000); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment