const int dim[] = {0, 1, 2, 4, 8, 16, 32, 64, 128, 255};
void setup() {
// put your setup code here, to run once:
volatile char *dirf;
volatile char *outf;
volatile long i, j, x;
dirf = 0x30;
outf = 0x31;
*dirf = 0xFF;
/*while(1)
{
for(int i = 0; i <= 255; i++)
{
OCR0A = i;
while (!(TIFR0 & (1 << OCF0A)));
}
for(int i = 255; i >= 0; i--)
{
OCR0A = i;
while (!(TIFR0 & (1 << OCF0A)));
}
}*/
while(1)
{
*outf = 0x00;
delay(500);
for(i=0; i< sizeof(dim)/sizeof(dim[0]); i++)
{
*outf = (dim[i]>0) ? 0x01 : 0x00;
delay(100);
//*outf = 0x00;
//delay(100);
}
*outf = 0x01;
delay(500);
for(i = (sizeof(dim)/sizeof(dim[0]))-1; i>=0; i--)
{
*outf = (dim[i]>0) ? 0x01 : 0x00;
delay(100);
//*outf = 0x01;
//delay(100);
}
}
/*while(1)
{
for(i=0; i<=255; i++)
{
*outf = (i>0) ? 0x01 : 0x00;
delay(100);
}
for(i=255; i>=0; i--)
{
*outf = (i>0) ? 0x01 : 0x00;
delay(100);
}
}*/
/*while(1)
{
for(i=0; i<360; i++)
{
x = (int)(sin(i*3.14159/180)*255);
*outf = (x>0) ? 0x01 : 0x00;
delay(10);
}
for(i=360; i>=0; i--)
{
x = (int)(sin(i*3.14159/180)*255);
*outf = (x>0) ? 0x01 : 0x00;
delay(10);
}
}*/
/*while(1)
{
for(int i = 0; i <= 255; i++)
{
set(i);
delay(10);
}
for(int i = 255; i >= 0; i--)
{
set(i);
delay(10);
}
}
}
void set(long i)
{
volatile char *outf;
volatile long j;
*outf = 0x31;
for(j = 0; j < 255; j++)
{
if(j<i)
{
*outf |= 0x01;
}
else
{
*outf &= 0x00;
}
delayMicroseconds(30);
}
}*/
}
void loop() {
// put your main code here, to run repeatedly:
}