//AQUI COLOCAMOS TODOS LOS PINES DEL PUERTO D COMO SALIDA
//PINES 7 6 5 4 3 2 1 0
//PUERTO D = A G F E D C B VACIO
//CERO = 1 0 1 1 1 1 1 0
//UNO = 0 0 0 0 0 1 1 0
//DOS = 1 1 0 1 1 0 1 0
//TRES = 1 1 0 0 1 1 1 0
//CUATRO = 0 1 1 0 0 1 1 0
//SIETE = 1 0 0 0 0 1 1 0
// DDRD = B11111111; //AQUI COLOCAMOS TODOS LOS PINES DEL PUERTO D COMO SALIDA
// Initialise Serial Communication to see Register Values
//0x --> así indicamos que es un número en formato hexadecimal
//b o B --> así indicamos que es un numero en formato binario
int dig[] = {0xBE,0x06,0xDA,0xCE,0x66,0x86};
//int dig[] ={190,6,218,206,102,134};
//int dig[] ={B10111110,B00000110,B11011010,B11001110,B01100110 ,B10000110};
int bin = B11111111;
int del = 2000;
void setup()
{
//DDR = DIRECT PORT MANIPULATION
DDRD = B11111111; //TODOS LOS PINES COMO SALIDAS TODOS LOS PINES EN 1 SON DE SALIDA
/* pinMode(0, OUTPUT); //el equivalente DDR
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);*/
}
void loop()
{
/* for(int i=0;i<=5;i++)
{
PORTD = dig[i];
delay(1500);
}*/
bin = 0b00000001 ;
PORTD = bin ; //Encendemos todos los leds;
delay(del);
/* int c = ~ bin ; //negamos el contenido de bin
PORTD = c; //negamos el puerto D;
delay(del);*/
int c= 0;
/* c = (bin & 0b01000101); //realizamos la operación AND
PORTD = c;
delay(del);*/
/* c = (bin & 0b00001111);
PORTD = c;
delay(del);*/
/* bin = 0b00000001 ;
PORTD = bin;
delay(del);*/
c = bin << 4;
PORTD = c;
delay(del);
c = bin >> 3;
PORTD = c;
delay(del);
// bin =0b11110000;
c = bin | 0b00001110; //REALIZAMOS LA OPERACIÓN OR
PORTD = c;
delay(del);
c = bin ^ 0b00001110; //REALIZAMOS LA OPERACIÓN OR
PORTD = c;
delay(del);
bin = 0b00000001 ;
for(int i=0; i<=7 ;i++){
c = bin << i ;
PORTD = c;
delay(50);
}
delay(del);
bin = 0b10000000 ;
for(int i=0; i<=7;i++){
c = bin >> i ;
PORTD = c;
delay(50);
}
delay(del);
}