Don't ad-block us - support your favorite websites. We have safe, unobstrusive, robotics related ads that you actually want to see - see here for more.
0 Members and 1 Guest are viewing this topic.
PORT_OFF(PORTD,4); _delay_ms(1000); PORT_ON(PORTD,4); _delay_ms(1000);
PORT_OFF(PORTD,4); for(int x=0;x<222;x++){ delay_cycles(655); } PORT_ON(PORTD,4); for(int x=0;x<222;x++){ delay_cycles(655); }
#include <avr/interrupt.h> // Defines pins, ports, etc to make programs easier to read#define F_CPU 1000000 // Sets up the default speed for delay.h#include <util/delay.h>#define PORT_ON( port_letter, number ) port_letter |= (1<<number)#define PORT_OFF( port_letter, number ) port_letter &= ~(1<<number)void delay_cycles(unsigned long int cycles){ while(cycles > 0){ cycles--; }}int main(){ DDRD = _BV(PD4); while(1){ PORT_ON(PORTD, 4); delay_cycles(35); PORT_OFF(PORTD, 4); delay_cycles(200); } return(0);}
Which worked just fine, however when I counted the blinks over a period of 1 minute I got about 27 blinks (when it should have been 30).