Last active
October 28, 2019 07:20
-
-
Save RobolinkAkademi/bdb3372ae13f719f9d88f84e8bb444ce to your computer and use it in GitHub Desktop.
tum_yil_icin_arduino_mufredati_27
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
#define resett 15 | |
#define dice 14 | |
char digit[6]={0x02, 0x79, 0x24, 0x30, 0x19, 0x12}; | |
int pin[7]={9,8,7,6,5,4,3}; //displayin bağlantı pinleri | |
void setup() | |
{ | |
for(int i=0;i<7;i++) | |
pinMode(pin[i], OUTPUT); | |
pinMode(dice, INPUT); | |
pinMode(resett, INPUT); | |
digitalWrite(dice, HIGH); | |
digitalWrite(resett, HIGH); | |
int temp=0x40; | |
for(int i=0;i<7;i++) | |
{ | |
int temp1=temp&0x01; | |
digitalWrite(pin[i], temp1); | |
temp=temp>>1; | |
} | |
delay(1000); | |
} | |
void loop() | |
{ | |
int temp=rand(); //rastgele seçilen bir sayının temp değiş. atanması | |
if(digitalRead(dice)==0) | |
{ | |
int k=temp%6; | |
temp=digit[k]; | |
wait(); | |
for(int i=0;i<7;i++) | |
{ | |
int temp1=temp&0x01; | |
digitalWrite(pin[i], temp1); | |
temp=temp>>1; | |
} | |
delay(200); | |
} | |
if(digitalRead(resett)==0) | |
{ | |
temp=0x40; | |
for(int i=0;i<7;i++) | |
{ | |
int temp1=temp&0x01; | |
digitalWrite(pin[i], temp1); | |
temp=temp>>1; | |
} | |
} | |
} | |
void wait() | |
{ | |
for(int m=0;m<10;m++) | |
{ | |
for(int k=0;k<6;k++) | |
{ | |
int ch=digit[k]; | |
for(int l=0;l<7;l++) | |
{ | |
char tem2=ch&0x01; | |
digitalWrite(pin[l], tem2); | |
ch=ch>>1; | |
} | |
delay(50); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment