Skip to content

Instantly share code, notes, and snippets.

@lazicdanilo
Created March 7, 2018 20:34
Show Gist options
  • Save lazicdanilo/85bc2ff8504d30ea474dd41bc3b50a8d to your computer and use it in GitHub Desktop.
Save lazicdanilo/85bc2ff8504d30ea474dd41bc3b50a8d to your computer and use it in GitHub Desktop.
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
unsigned long int i = 0;
unsigned long int j = 0;
double x = 0.5;
void delay_us2(long int us) {
long int i;
us /= 10;
for(i=0; i < us; i++) {
_delay_us(10);
}
}
void impuls(long int us) {
PORTF=0xff;
delay_us2(us);
PORTF=0;
delay_us2(18500-us);
}
int main(void) {
DDRF = 0xff;
long int us;
for(j = 1; j < 300; j++) {
PORTF=0xff;
_delay_us(1000);
PORTF=0x00;
_delay_us(19000);
}
for(us = 1000; us < 1300; us++) {
if(us > 2000){
us = 2000;
}
impuls(us);
}
for(; us >= 400; us--) {
if(us < 900){
us = 900;
}
impuls(us);
}
while(1) {
impuls(900);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment