Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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
You can’t perform that action at this time.