DEV Community

nopekun
nopekun

Posted on

Arduino flip flop #1

flip flop demo

Berikut kode untuk membuat rangkaian flip flop seperti gambar diatas.

void setup () {
   digitalWrite(0, HIGH);
   digitalWrite(7, HIGH);
}

int curr = 0;
int isUp = 1;

void loop() {
   delay(500);
   if(curr==0) isUp =1;
   if(curr==3) isUp = 0;
   digitalWrite(curr, LOW);
   digitalWrite(7-curr, LOW);
   if(isUp) {
      curr++;
   } else {
      curr--;
   }
   digitalWrite(curr, HIGH);
   digitalWrite(7-curr, HIGH);
}
Enter fullscreen mode Exit fullscreen mode

Cara kerjanya pertama pin 0 dan pin 7 akan menyala, lalu akan looping increment hingga pin ke - 3. Setelah sampai posisi pin 3 maka akan looping ke bawah dan seterusnya,

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more