//Bibliotecas:
#define __ATmega2560__
#define __AVR_ATmega2560__
#ifndef F_CPU
#define F_CPU 16000000UL
#endif
#include <stdint.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <stdbool.h>
#include <stdint.h>
#include <util/delay.h>
#include <stdint.h>
#include <stdlib.h>
#include <avr/interrupt.h>
int main(void)
{
int on, off;
while (1)
{
DDRB = DDRB | (1 << DDB7); // Out
PORTB = PORTB | (1 << PORTB7)
// 1 Faça todos os bits de DDRB iguais a 0.
DDRB = 0x00; //isso define todos os bits do registrador DDRB como 0, o que significa que
// 2 Faça todos os bits iguais a 1.
DDRB = 0XFF;
// 3 Em PORTB, os bits 1 e 4 devem ser iguais a 1 e os bits 7 e 3 iguais a 0. Os outros
//bits não devem ser modificados.
PORTB |= (1 << 1) | (1 << 4);
PORTB &= ~((1 << 7) | (1 << 3));
// 4 Faça os bits 3 a 0 de PORTB iguais a 1 e o bit 5 igual a 0.
PORTB |= 0x0F;
PORTB &= ~(1 << 5);
// 5 Copie os bits 6 e 3 de PINB para PORTB
PORTB &= ~(1 << 6); // Limpa o bit 6
PORTB |= ((PINB & (1 << 6)) << 3); // Copia o bit 6 para o bit 3 de PORTB
// 6 Copie o bit 3 de PORTB para a posição 0.
PORTB = (PORTB & ~(1 << 0)) | ((PORTB & (1 << 3)) >> 3);
// 7 Inverta os bits 4, 3 e 1 de PORTB.
PORTB ^= ((1 << 4) | (1 << 3) | (1 << 1));
// 8 Isole os 3 bits mais significativos de PINB e guarde nos 3 bits menos significativos
//da variável tmp.
tmp = (PINB >> 5) & 0x07;
// 9 Guarde os bits 5, 3 e 1 de PORTB nos bits 7, 1 e 0, respectivamente, na variável
//tmp
tmp = (tmp & ~(0x47)) | ((PORTB & 0x26) >> 1);
}
return 0;
}