/*int counter = 1;
void setup() {
DDRD = 0xFF; // 255 ali ob11111111
//Serial.begin(115200);
}
void loop() {
for(int x = 0; x < 8; x++){
PORTD = counter;
delay(100);
counter *= 2;
//Serial.println(counter);
if(counter > 128) counter = 128;
}
for( int x = 0; x < 8; x++){
PORTD = counter;
delay(100);
counter = counter / 2;
if(counter < 1) counter = 1;
}
}*/
/*
unsigned int counter = 1;
int direction = 1;
unsigned long changeTime = 0;
int timeDelay = 200;
void setup() {
DDRD = 0xFF; // 255 ali ob11111111
//Serial.begin(115200);
changeTime = millis();
}
void loop() {
PORTD = counter;
if((millis() - changeTime) > timeDelay){
if(direction == 1) counter *= 2;
else counter /=2;
changeTime = millis();
if(counter > 64) direction = 0;
if(counter <= 1) direction = 1;
}
}
unsigned int counter = 1;
int direction = 1;
static unsigned long changeTime;
int timeDelay = 200;
byte value = 0;
void setup() {
DDRD = 0xFF; // 255 ali ob11111111
DDRB &=0b11111110;
changeTime = millis();
}
void loop() {
value = PINB & 0b00000001; // 0x01
if((millis() - changeTime) > timeDelay){
if(value == 0){
if(counter > 128 || counter < 1) counter = 1;
PORTD = counter;
counter *= 2;
}
if(value == 1){
if(counter <= 0 || counter > 128) counter = 128;
PORTD = counter;
counter /= 2;
}
changeTime = millis();
}
}*/
int ledPin [] = {1, 2, 4, 8, 16, 32, 64, 128, 0, 255, 0, 255, 0x0F, 0, 0xF0, 0};
int ledPin1[] = {255, 0, 255, 0};
byte value = 0;
void setup() {
DDRD = 0xFF;
DDRB &=0b11111110;
}
void loop(){
value = PINB & 0b00000001;
if(value == 0){
for(int x = 0; x < (sizeof(ledPin) / sizeof(ledPin[0])); x++){
PORTD = ledPin[x];
delay(200);
}
}
if(value == 1){
for(int x = 0; x < (sizeof(ledPin1) / sizeof(ledPin1[0])); x++){
PORTD = ledPin1[x];
delay(200);
}
}
}