tum_yil_icin_arduino_mufredati_29
#include <LiquidCrystal_I2C.h> | |
LiquidCrystal_I2C lcd(0x3F,16,2); | |
int ledr=8;//ledin kırmızı bacağına bağlı pin | |
int ledb=7;//ledin mavi bacağına bağlı pin | |
int ledgr=6;//ledin yeşil bacağına bağlı pin | |
int buton=9;//push butona bağlı pin | |
int color; | |
int Beep; | |
int pse;//değişken bekleme | |
int tme;//süre | |
int rtme=0;//tepki süresi | |
void setup() { | |
lcd.begin(); | |
pinMode(ledr,OUTPUT); | |
pinMode(ledb,OUTPUT); | |
pinMode(ledgr,OUTPUT); | |
pinMode(buton,INPUT); | |
digitalWrite(ledr,HIGH); | |
digitalWrite(ledr,HIGH); | |
digitalWrite(ledr,HIGH); | |
} | |
void loop() { | |
lcd.clear(); | |
lcd.print("Basmaya hazırlan"); | |
lcd.setCursor(0,1); | |
lcd.print("BAŞLA"); | |
while(digitalRead(buton)==LOW) | |
{ tone(13,1200,30); | |
delay(1400); | |
noTone(13); | |
} | |
lcd.clear(); | |
digitalWrite(ledr,LOW); | |
digitalWrite(ledgr,LOW); | |
digitalWrite(ledb,LOW); | |
randomSeed(analogRead(0)); | |
color=random(1,4); | |
pse=random(500,1200); | |
while(color!=1 && digitalRead(buton)==HIGH){ | |
digitalWrite(ledgr,LOW); | |
digitalWrite(ledb,LOW); | |
delay(pse); | |
randomSeed(analogRead(0)); | |
Beep=random(1,4); | |
pse=random(750,1200); | |
if(Beep=1) | |
{ | |
tone(13,1600,350); | |
delay(750); | |
noTone(13); | |
} | |
if(color=2) | |
{digitalWrite(ledgr,HIGH); | |
} | |
if(color=3) | |
{digitalWrite(ledb,HIGH); | |
} | |
delay(pse); | |
randomSeed(analogRead(0)); | |
color=random(1,4); | |
} | |
if(color==1 && buton==HIGH){ | |
digitalWrite(ledgr,LOW); | |
digitalWrite(ledb,LOW); | |
delay(pse); | |
tme=millis(); | |
digitalWrite(ledr,HIGH); | |
while(digitalRead(buton)==HIGH){ | |
delay(1); | |
} | |
lcd.display(); | |
rtme=millis()-tme; | |
lcd.print("Tepki Süresi:"); | |
lcd.setCursor(0,1); | |
lcd.print(rtme); | |
} | |
if(color!=1){ | |
lcd.print("Released too"); | |
lcd.setCursor(0,1); | |
lcd.print("soon!!"); | |
tone(13,3000,1500); | |
delay(500); | |
noTone(13); | |
} | |
while(digitalRead(buton)==LOW){ | |
delay(10);} | |
digitalWrite(ledr,HIGH); | |
digitalWrite(ledgr,HIGH); | |
digitalWrite(ledb,HIGH); | |
lcd.clear(); | |
lcd.print("Basmaya hazırlan"); | |
lcd.setCursor(0,1); | |
lcd.print("BAŞLA"); | |
int Time=0; | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment