Arun_Sharma
Published

Project-1, Binary Counting

Using LEDs as Binary No. and 2 button switches to add or subtract 1 point per push.

BeginnerProtip9,486
Project-1, Binary Counting

Things used in this project

Story

Read more

Schematics

Circuit Diagram

I tried to make it as presentable as its originally made in. Except resistors, because I didn't had correct values of resistors. Make sure you use 10 ohm resistors

Code

code

Arduino
It's temporary, only for use, it will not work if something goes incorrect
int l[]={0,0,0,0,0,0},T=6,a,p;
const int b1=12,b2=13;
void setup() {
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(b1,INPUT);
pinMode(b2,INPUT);
}
void loop() {
p=0;
p=digitalRead(b1) ;
while(digitalRead(b1)!=0)
{
  
}
delay(100);
a=T-1;
while(a>=0&&p==1)
{
  if(l[a]==1)
  {
    l[a]=0;
    a--;
  }
  else
  {
    l[a]=1;
    p=0;
  }
}
p=digitalRead(b2) ;
while(digitalRead(b2)!=0)
{
  
}
delay(100);
a=T-1;
while(a>=0&&p==1)
{
  if(l[a]==0)
  {
    l[a]=1;
    a--;
  }
  else
  {
    l[a]=0;
    p=0;
  }
}
a=T-1;
for(int c=0;c<T;c++)
{
    if(l[c]==1)
    digitalWrite(T-c+1,HIGH);
  else
    digitalWrite(T-c+1,LOW);
  a--;
}
}

Credits

Arun_Sharma
1 project • 1 follower

Comments