0% found this document useful (0 votes)
5 views2 pages

Arduino Button Control Logic Code

The document contains code for an Arduino program that uses input buttons and LED outputs to toggle a sequence of 6 LEDs on and off. It defines arrays and variables, sets pin modes, and contains loops to read button inputs and update the LED array and outputs.

Uploaded by

rahafzorba2002
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Arduino Button Control Logic Code

The document contains code for an Arduino program that uses input buttons and LED outputs to toggle a sequence of 6 LEDs on and off. It defines arrays and variables, sets pin modes, and contains loops to read button inputs and update the LED array and outputs.

Uploaded by

rahafzorba2002
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

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--;
}
}

You might also like