void port_init(){
volatile unsigned char *portb_dir=0x24;
volatile unsigned char *portc_dir=0x27;
*portb_dir=0xFF;
*portc_dir=0xFF;
}
void outputb(unsigned char data1)
{
volatile unsigned char *portb_data=0x25;
*portb_data=data1;
}
void outputc(unsigned char data2)
{
volatile unsigned char *portc_data=0x28;
*portc_data=data2;
}
void clockpulse()
{
outputc(0x01);
delayMicroseconds(500);
outputc(0x00);
delayMicroseconds(500);
}
void latch()
{
outputb(0x02);
delayMicroseconds(500);
outputb(0x00);
}
void shift_out(unsigned char address,unsigned char data)
{
int i;
for(i=0;i<16;i++)
{
if(i<8)
{
outputb(((address<<i)&0x80)>>7);
}
else{
outputb(((data<<i-8)&0x80)>>7);
}
clockpulse();
}
}
void setup() {
port_init();
byte a[8] = {
0x3C, // 00111100
0x42, // 01000010
0xA5, // 10100101 (Eyes)
0x81, // 10000001
0xA5, // 10100101
0x99, // 10011001 (Smile Curve)
0x42, // 01000010
0x3C // 00111100
};
for(int i=0;i<=7;i++){
shift_out(i,a[i]);
latch();
}
/* delay(2000);
for(int i=0;i<=7;i++){
shift_out(arr[i],0x00);
shift_out(arr[i],0x00);
shift_out(arr[i],0x00);
shift_out(arr[i],0x00);
delay(10);
latch();
}
}*/
}
void loop() {
// put your main code here, to run repeatedly:
}
/*int arrd[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
int arrd2[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
//int arrd[]={0x10,0x30,0x50,0x10,0x10,0x10,0x10,0x7C}; digit 1
//int arr2[]={0x38,0x44,0x04,0x04,0x08,0x10,0x20,0x7E}; digit 2
//int arrs[] = {0x7C, 0x40, 0x40, 0x78, 0x04, 0x04, 0x7C, 0x00};
//int arrb[] = {0x7C, 0x44, 0x44, 0x78, 0x44, 0x44, 0x7C, 0x00};
int arrE[] = {0x7C, 0x40, 0x40, 0x78, 0x40, 0x40, 0x7C, 0x00};
int arrT[] = {0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00};
int arrA[] = {0x18, 0x24, 0x24, 0x3C, 0x24, 0x24, 0x24, 0x00};
int arrL[] = {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7C, 0x00};
int arr1[] = {0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x00};
int arr2[] = {0x3C, 0x66, 0x06, 0x0C, 0x18, 0x30, 0x7E, 0x00};
int arr3[] = {0x3C, 0x66, 0x06, 0x1C, 0x06, 0x66, 0x3C, 0x00};
int arr4[] = {0x0C, 0x1C, 0x2C, 0x4C, 0x7E, 0x0C, 0x0C, 0x00};*/
// to display the text from right side.
/*for(int i=0;i<=7;i++){
shift_out(arr[i],arrE[i]);
latch();
}
delay(2000);
for(int i=0;i<=7;i++){
shift_out(arr[i],arrE[i]);
shift_out(arr[i],arrT[i]);
latch();
}
delay(1000);
for(int i=0;i<=7;i++){
shift_out(arr[i],arrE[i]);
shift_out(arr[i],arrT[i]);
shift_out(arr[i],arrA[i]);
latch();
}
delay(1000);
for(int i=0;i<=7;i++){
shift_out(arr[i],arrE[i]);
shift_out(arr[i],arrT[i]);
shift_out(arr[i],arrA[i]);
shift_out(arr[i],arrL[i]);
latch();
}
delay(1000);
int arr[]={0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08};
int arr1[] = {0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x00};
int arr2[] = {0x3C, 0x66, 0x06, 0x0C, 0x18, 0x30, 0x7E, 0x00};
int arr3[] = {0x3C, 0x66, 0x06, 0x1C, 0x06, 0x66, 0x3C, 0x00};
int arr4[] = {0x0C, 0x1C, 0x2C, 0x4C, 0x7E, 0x0C, 0x0C, 0x00};
while(1){
for(int i=0;i<=7;i++){
shift_out(arr[i],arr1[i]);
shift_out(arr[i],0x00);
shift_out(arr[i],0x00);
shift_out(arr[i],0x00);
latch();
}
delay(1000);
for(int i=0;i<=7;i++){
shift_out(arr[i],arr1[i]);
shift_out(arr[i],arr2[i]);
shift_out(arr[i],0x00);
shift_out(arr[i],0x00);
latch();
}
delay(1000);
for(int i=0;i<=7;i++){
shift_out(arr[i],arr1[i]);
shift_out(arr[i],arr2[i]);
shift_out(arr[i],arr3[i]);
shift_out(arr[i],0x00);
latch();
}
delay(1000);
for(int i=0;i<=7;i++){
shift_out(arr[i],arr1[i]);
shift_out(arr[i],arr2[i]);
shift_out(arr[i],arr3[i]);
shift_out(arr[i],arr4[i]);
latch();
}
delay(1000);*/