Created
May 18, 2017 16:31
-
-
Save niloy-barua/52e8204adbb997d30c6031bc0206f230 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
byte ccCode[16]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71}; | |
byte counter=0; | |
void setup() | |
{ | |
//setting direction of PORTB & partial PORTD registers | |
DDRB=B00111111; | |
DDRD=B11000001; | |
pinMode(3,INPUT_PULLUP); | |
digitalWrite(0,LOW); | |
} | |
void loop() | |
{ | |
bool buttonReleased=false; | |
if(!digitalRead(3)) | |
{ | |
while(!buttonReleased) | |
{ | |
delay(10); //delay added to avoid switch bouncing problem | |
if(digitalRead(3)) buttonReleased = true; | |
} | |
} | |
if(buttonReleased && counter<16) counter++; | |
else if(counter == 16) counter=0; | |
byte y=ccCode[counter]; | |
PORTB=y; | |
bitWrite(PORTD,6,bitRead(y,6)); | |
bitWrite(PORTD,7,bitRead(y,7)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment