Last active
August 29, 2015 14:01
-
-
Save omarayad1/0ab6e538f1ee1a0cc171 to your computer and use it in GitHub Desktop.
code uploaded in the arduino so it can increment the 7-segment display each time it detects an infra-red light
This file contains 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
int num=0; | |
int flag=0; | |
char * p[]={"1101111", //0 | |
"1000100", //1 | |
"1110011", //2 | |
"1110110",//3 | |
"1011100",//4 | |
"0111110",//5 | |
"0111111",//6 | |
"1100100",//7 | |
"1111111",//8 | |
"1111110"//9 | |
}; | |
void setup() { | |
for (int i=2; i<9; i++) pinMode(i,OUTPUT); | |
pinMode(10,INPUT); | |
} | |
void loop() { | |
if(digitalRead(10)==HIGH) flag=1; | |
else if(flag==1){ | |
increment(); | |
flag=0; | |
delay(500); | |
} | |
} | |
void increment() | |
{ | |
num=num%10; | |
for(int i=2;i<9;i++) | |
{ | |
if(p[num][i-2]=='1') digitalWrite(i,HIGH); | |
else digitalWrite(i,LOW); | |
} | |
num++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment