Postingan

Running LED dan Button - Arduino

Gambar
rangkailah rangkaian berikut




upload sketch berikut kearduino


int i,val; int button1=8; int button2=9; unsigned char led[8]={~0x01, ~0x02, ~0x04, ~0x08, ~0x10, ~0x20, ~0x40, ~0x80}; unsigned char leda[8]={0b11111100, 0b11111001, 0b11110011, 0b11100111, 0b11001111, 0b10011111, 0b00111111, 0b01111111}; void ledplus() { for(i=0;i<=7;i++) { if(digitalRead(button2)==LOW) { return;// delay(500); } PORTD=led[i]; delay(300); } PORTD=0xC3; delay(1000); for(i=7;i>=0;i--) { if(digitalRead(button2)==LOW) { return;//break; //delay(500); } PORTD=~led[i]; delay(200); } PORTD=0xFF; } void ledmin() { for(i=0;i<=7;i++) { if(digitalRead(button1)==LOW) { return;//break; //delay(5…