Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define F_CPU 8000000L
- #include <avr/io.h>
- #include <util/delay.h>
- // TESTING JARTZA'S MACROS
- #include "avr_common_macros.h"
- int main(void)
- {
- // -------------------------------------------------------------------
- // Setup port directions and make pb0 til pb2 outputs.
- // -------------------------------------------------------------------
- BITS_SET(DDRB, PB0, PB1, PB2, PB3, PB4);
- // VS some messy code,
- //DDRB |= (1 << PB0) | (1 << PB1) | (1 << PB2) | (1 << PB3) | (1 << PB4);
- while(1)
- {
- // -------------------------------------------------------------------
- // Set one side of the chip high and the oher side of the chip low.
- BITS_SET(PORTB, PB0, PB1, PB2);
- BITS_CLEAR(PORTB, PB3, PB4);
- // VS some messy code.
- /*
- PORTB |= (1 << PB0);
- PORTB |= (1 << PB1);
- PORTB |= (1 << PB2);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB4);
- */
- _delay_ms(500);
- // -------------------------------------------------------------------
- // Now do the opposite,
- BITS_CLEAR(PORTB, PB0, PB1, PB2);
- BITS_SET(PORTB, PB3, PB4);
- // VS some messy code.
- /*
- PORTB &= ~(1 << PB0);
- PORTB &= ~(1 << PB1);
- PORTB &= ~(1 << PB2);
- PORTB |= (1 << PB3);
- PORTB |= (1 << PB4);
- */
- _delay_ms(500);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement