Abhinav SP
Published

The TCP Packet Badge

A badge that features an entire TCP packet design with funky LED show and an "Internet Explorer" mode that slows all of it down.

IntermediateFull instructions provided5,549
The TCP Packet Badge

Things used in this project

Hardware components

ATmega8A
×1
LEDs SMD 1206 Package
×28
Resistors SMD 470 Ohm
×3
Coin Cell Battery CR2032
Coin Cell Battery CR2032
×1
Battery Holder, 2032 x1
Battery Holder, 2032 x1
×1
Slide Switch, SPDT-CO
Slide Switch, SPDT-CO
×2
Male-Header 10 Position 2 Row (0.1") Right Angle
Male-Header 10 Position 2 Row (0.1") Right Angle
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Tiny AVR Programmer
SparkFun Tiny AVR Programmer
×1

Software apps and online services

Microchip Studio
Microchip Studio

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Code

Badgepattern3.c

C/C++
#include<avr/io.h>
#include<util/delay.h>
#include<avr/interrupt.h>

int a=0;
//typedef unsigned char byte;
volatile int x=0;
void delay1()
{
	_delay_ms(50);
}
void delay2()
{
	_delay_ms(10);
}

void uart_send (unsigned char d)
{
	while((UCSRA & 0x20)==0)
	 {
	 }
	 UDR=d;
}
unsigned char uart_rec(void)
{
	while (!(UCSRA & (1<<RXC)));
	return UDR;
}
void uart_string(char *data)
{
	while(*data)
	{
		uart_send(*data);
		data++;
	}
}

void init_uart(void)
{
   UCSRA |= (1<<U2X) |(1<<RXC);
   UCSRB |= (1<<RXCIE)|(1<<TXEN)|(1<<RXEN);
   UBRRL=12; 	
}



ISR(USART_RXC_vect)
{	
	x=uart_rec();
}

	
int main()
{
	
	init_uart();
	DDRB=0b11111111;
	DDRC=0b11111111;
	DDRD=0b11101110;
	
		while(1)
		{
			 sei();

			if(bit_is_set(PIND,PD4) && (x=='A'))

			{    
			    
		             PORTC |=(1<<4);
				     delay1();
					 PORTC &= ~(1<<4);
					 delay1();
					 PORTC |=(1<<3);
					 delay1();
					 PORTD |=(1<<6);
					 delay1();
					 PORTC &=~(1<<3);
					 delay1();
					 PORTD &=~(1<<6);
					 delay1();
			   	    PORTC |=(1<<2);
					 delay1();
					 PORTD |=(1<<7);
			    	 delay1();
					 PORTC &=~(1<<2);
					 delay1();
				     PORTD &=~(1<<7);
			    	 delay1();
					 PORTC |=(1<<1);
					 delay1();
					 PORTB |=(1<<0);
					 delay1();
					 PORTC &=~(1<<1);
					 delay1();
					 PORTB &=~(1<<0);
					 delay1();
					 PORTC |=(1<<0);
					 delay1();
					 PORTB |=(1<<1);//
			    	 delay1();
					 PORTC &=~(1<<0);
					 delay1();
					 PORTB &=~(1<<1);
			    	 delay1();
					 PORTD |=(1<<5);
				     delay1();
					 PORTB |=(1<<2);
					 delay1();
					 PORTD &=~(1<<5);
				     delay1();
					 PORTB &=~(1<<2);
					 delay1();
					 PORTD |=(1<<3);
					 delay1();
					 PORTB |=(1<<3);
				     delay1();
					 PORTD &=~(1<<3);
					 delay1();
					 
					 PORTB &=~(1<<3);
				     delay1();
					 PORTC |=(1<<5);
				     delay1();

					 PORTB |=(1<<4);
					 delay1();
					 PORTC &=~(1<<5);
				     delay1();
					 PORTB &=~(1<<4);
					 delay1();
					  PORTB |=(1<<6);
				     delay1();
					 PORTB &=~(1<<6);
				     delay1();
					 PORTB |=(1<<7);
					 delay1();
					 PORTB |=(1<<5);
					 delay1();
					 PORTB &=~(1<<7);
					 delay1();
					 PORTB &=~(1<<5);
					 delay1();
				 
			}
		
                        else if(bit_is_set(PIND,PD4) && (x=='D'))
			{
			      
				 PORTC |=(1<<4);
			     delay1();
				 PORTC |=(1<<3);
				 delay1();
				 PORTC |=(1<<2);
				 delay1();
				 PORTC |=(1<<1);
				 delay1();
				 PORTC |=(1<<0);
				 delay1();
				 PORTD |=(1<<5);
			     delay1();
				 PORTD |=(1<<3);
				 delay1();
				 PORTC |=(1<<5);
			     delay1();
				 PORTB |=(1<<6);
			     delay1();
				 PORTB |=(1<<7);
				 delay1();

				 PORTB &=~(1<<7);
				 delay1();
				 PORTB &=~(1<<6);
			     delay1();
                 PORTC &= ~(1<<5);
				 delay1();
				 PORTD &=~(1<<3);
				 delay1();
				 PORTD &=~(1<<5);
			     delay1();
				 PORTC &=~(1<<0);
				 delay1();
				 PORTC &=~(1<<1);
				 delay1();
				 PORTC &=~(1<<2);
				 delay1();
			     PORTC &=~(1<<3);
				 delay1();
				 PORTC &= ~(1<<4);
				 delay1();
				 							 
			}

			else if(bit_is_clear(PIND,PD4))
			{
			
				PORTC=0b00000000;
				PORTD=0b00000000;
				PORTB=0b00000000;

	    
			}
			else
			{
				PORTC=0b00000000;
				PORTD=0b00000000;
				PORTB=0b00000000;
			}
		}
}

Badgepattern1.c

C/C++
#include<avr/io.h>
#include<util/delay.h>
#include<avr/interrupt.h>

int a=0;
//typedef unsigned char byte;
volatile int x=0;
void delay1()
{
	_delay_ms(10);
}
void delay2()
{
	_delay_ms(10);
}

void uart_send (unsigned char d)
{
	while((UCSRA & 0x20)==0)
	 {
	 }
	 UDR=d;
}
unsigned char uart_rec(void)
{
	while (!(UCSRA & (1<<RXC)));
	return UDR;
}
void uart_string(char *data)
{
	while(*data)
	{
		uart_send(*data);
		data++;
	}
}

void init_uart(void)
{
   UCSRA |= (1<<U2X) |(1<<RXC);
   UCSRB |= (1<<RXCIE)|(1<<TXEN)|(1<<RXEN);
   UBRRL=12; 	
}



ISR(USART_RXC_vect)
{	
	x=uart_rec();
}

	
int main()
{
	
	init_uart();
	DDRB=0b11111111;
	DDRC=0b11111111;
	DDRD=0b11101110;
	
		while(1)
		{
			 sei();

			if(x=='A')

			{        PORTD |=(1<<6);
					 delay1();
					 PORTD &=~(1<<6);
					 delay1();
					 PORTD |=(1<<7);
			    	 delay1();
					 PORTC |=(1<<4);
				     delay1();
					 PORTD &=~(1<<7);
			    	 delay1();
					 PORTC &= ~(1<<4);
					 delay1();

					 PORTB |=(1<<0);
					 delay1();
					 PORTB &=~(1<<0);
					 delay1();
					 PORTB |=(1<<1);
			    	 delay1(); 
					 PORTC |=(1<<3);
					 delay1();
					 PORTB &=~(1<<1);
			    	 delay1();
					  PORTC &=~(1<<3);
					 delay1();

					 PORTB |=(1<<2);
					 delay1();
					 PORTB &=~(1<<2);
					 delay1();
					 PORTB |=(1<<3);
				     delay1();
					 PORTC |=(1<<2);
					 delay1();
					 PORTB &=~(1<<3);
				     delay1();
					 PORTC &=~(1<<2);
					 delay1();

					 PORTB |=(1<<4);
					 delay1();
					 PORTC |=(1<<1);
					 delay1();
					 PORTB &=~(1<<4);
					 delay1();
					 PORTC &=~(1<<1);
					 delay1();

					 PORTB |=(1<<5);
					 delay1();
					 PORTC |=(1<<0);
					 delay1();
					 PORTB &=~(1<<5);
					 delay1();
					 PORTC &=~(1<<0);
					 delay1();			 	 
			}
		
            else if(x=='D')
			{
			      PORTB |=(1<<5);
				  delay2();
				  PORTB &=~(1<<5);
				  delay2();
				  PORTB |=(1<<4);
				  delay2();
				  PORTB |=(1<<7);
				  delay2();
				  PORTB &=~(1<<4);
				  delay2();
                  PORTB &=~(1<<7);
				  delay2();

				  PORTB |=(1<<3);
			      delay2();
				  PORTB &=~(1<<3);
			      delay2();
				  PORTB |=(1<<2);
				  delay2();
				  PORTB |=(1<<6);
			      delay2();
				  PORTB &=~(1<<2);
				  delay2();
				  PORTB &=~(1<<6);
			      delay2();

				  PORTB |=(1<<1);
		    	  delay2();
				  PORTB &=~(1<<1);
		    	  delay2();
				  PORTB |=(1<<0);
				  delay2();
				  PORTC |=(1<<5);
			      delay2();
				  PORTB &=~(1<<0);
				  delay2();
				  PORTC &=~(1<<5);
			      delay2();

				  PORTD |=(1<<7);
		    	  delay2();
				  PORTD |=(1<<3);
				  delay2();
				  PORTD &=~(1<<7);
		    	  delay2();
				  PORTD &=~(1<<3);
				  delay2();
				  
				  PORTD |=(1<<6);
				  delay2();
				  PORTD |=(1<<5);
			      delay2();
				  PORTD &=~(1<<6);
				  delay2();
				  PORTD &=~(1<<5);
			      delay2();	
			}
			else
			{
			
				PORTC=0b00000000;
				PORTD=0b00000000;
				PORTB=0b00000000;

	    
			}
		}
}

Badgepattern2.c

C/C++
#include<avr/io.h>
#include<util/delay.h>
#include<avr/interrupt.h>

int a=0;
//typedef unsigned char byte;
volatile int x=0;
void delay1()
{
	_delay_ms(50);
}
void delay2()
{
	_delay_ms(10);
}

void uart_send (unsigned char d)
{
	while((UCSRA & 0x20)==0)
	 {
	 }
	 UDR=d;
}
unsigned char uart_rec(void)
{
	while (!(UCSRA & (1<<RXC)));
	return UDR;
}
void uart_string(char *data)
{
	while(*data)
	{
		uart_send(*data);
		data++;
	}
}

void init_uart(void)
{
   UCSRA |= (1<<U2X) |(1<<RXC);
   UCSRB |= (1<<RXCIE)|(1<<TXEN)|(1<<RXEN);
   UBRRL=12; 	
}



ISR(USART_RXC_vect)
{	
	x=uart_rec();
}

	
int main()
{
	
	init_uart();
	DDRB=0b11111111;
	DDRC=0b11111111;
	DDRD=0b11101110;
	
		while(1)
		{
			 sei();

			if(x=='A')

			{   
			     PORTC |=(1<<4);
			     delay1();
				 PORTC |=(1<<3);
				 delay1();
				 PORTC |=(1<<2);
				 delay1();
				 PORTC |=(1<<1);
				 delay1();
				 PORTC |=(1<<0);
				 delay1();
				 PORTD |=(1<<5);
			     delay1();
				 PORTD |=(1<<3);
				 delay1();
				 PORTC |=(1<<5);
			     delay1();
				 PORTB |=(1<<6);
			     delay1();
				 PORTB |=(1<<7);
				 delay1();

				 PORTC &= ~(1<<4);
				 delay1();
				 PORTC &=~(1<<3);
				 delay1();
				 PORTC &=~(1<<2);
				 delay1();
				 PORTC &=~(1<<1);
				 delay1();
		         PORTC &=~(1<<0);
				 delay1();
				 PORTD &=~(1<<5);
			     delay1();
				 PORTD &=~(1<<3);
				 delay1();
				 PORTC &= ~(1<<5);
				 delay1();
				 PORTB &=~(1<<6);
			     delay1();
				 PORTB &=~(1<<7);
				 delay1();	 	 
			}
		
            else if(x=='D')
			{
			      
				 PORTC |=(1<<4);
			     delay1();
				 PORTC |=(1<<3);
				 delay1();
				 PORTC |=(1<<2);
				 delay1();
				 PORTC |=(1<<1);
				 delay1();
				 PORTC |=(1<<0);
				 delay1();
				 PORTD |=(1<<5);
			     delay1();
				 PORTD |=(1<<3);
				 delay1();
				 PORTC |=(1<<5);
			     delay1();
				 PORTB |=(1<<6);
			     delay1();
				 PORTB |=(1<<7);
				 delay1();

				 PORTB &=~(1<<7);
				 delay1();
				 PORTB &=~(1<<6);
			     delay1();
                 PORTC &= ~(1<<5);
				 delay1();
				 PORTD &=~(1<<3);
				 delay1();
				 PORTD &=~(1<<5);
			     delay1();
				 PORTC &=~(1<<0);
				 delay1();
				 PORTC &=~(1<<1);
				 delay1();
				 PORTC &=~(1<<2);
				 delay1();
			     PORTC &=~(1<<3);
				 delay1();
				 PORTC &= ~(1<<4);
				 delay1();
				 					 
			}
			else
			{
			
				PORTC=0b00000000;
				PORTD=0b00000000;
				PORTB=0b00000000;

	    
			}
		}
}

Credits

Abhinav SP

Abhinav SP

23 projects • 21 followers
College dropout artist, hacker and entrepreneur trying to make hardware learning creative. Founder, Hackerware.io

Comments