0% found this document useful (0 votes)
22 views1 page

Led 01

The provided C++ code is for an Arduino program that controls four output pins and two input pins. It reads the state of two buttons and adjusts the output of LEDs based on the button states, shifting the active LED left or right. The program includes a delay of 500 milliseconds between each loop iteration.

Uploaded by

kangjoon1004
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)
22 views1 page

Led 01

The provided C++ code is for an Arduino program that controls four output pins and two input pins. It reads the state of two buttons and adjusts the output of LEDs based on the button states, shifting the active LED left or right. The program includes a delay of 500 milliseconds between each loop iteration.

Uploaded by

kangjoon1004
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
You are on page 1/ 1

// C++ code

//
void setup()
{
pinMode(4,OUTPUT);pinMode(5,OUTPUT);
pinMode(6,OUTPUT);pinMode(7,OUTPUT);
pinMode(2,INPUT) ;pinMode(3,INPUT);
}

int bt1, bt2,powerOn=1;


int leftShift,rightShift,ledPin=3;

void loop()
{
bt1 = digitalRead(3);
bt2 = digitalRead(2);
if(bt1 || bt2) powerOn=0;
if(powerOn)
{ leftShift=1;rightShift=0; }
else if(bt1)
{ leftShift=1;rightShift=0;}
else
{ leftShift=0;rightShift=1;}

if(leftShift)
{ledPin++; if(ledPin>7) ledPin=4;}
else
{ledPin--; if(ledPin<4) ledPin=7;}
if(ledPin==4) digitalWrite(4,HIGH);
else digitalWrite(4,LOW);
if(ledPin==5) digitalWrite(5,HIGH);
else digitalWrite(5,LOW);
if(ledPin==6) digitalWrite(6,HIGH);
else digitalWrite(6,LOW);
if(ledPin==7) digitalWrite(7,HIGH);
else digitalWrite(7,LOW);
delay(500);

You might also like