Notes
Notes - notes.io |
int trigPin = 6;
int echoPin = 7;
String voice;
long sure;
long uzaklik;
long on_uzaklik;
long sol_uzaklik;
long sag_uzaklik;
#define TFT_CS 10
#define TFT_RST 9
#define TFT_DC 8
#define TFT_SCLK 13
#define TFT_MOSI 11
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
//motor pinleri
#define out1 5
#define out2 12
#define out3 3
#define out4 2
//bluetooth pinleri
#define tx 1
#define rx 0
Servo servo;
void setup()
{
Serial.begin(9600);
//random(sallama) kodu
randomSeed(666);
//tft ekran
tft.initR(INITR_144GREENTAB);
uint16_t time = millis();
tft.fillScreen(ST7735_BLACK);
tft.setRotation(0);
time = millis() - time;
Serial.println(time, DEC);
delay(500);
//akıllı piksel.
tft.drawPixel(tft.width()/2, tft.height()/2, ST7735_GREEN);
delay(500);
pinMode(out1, OUTPUT);
pinMode(out2, OUTPUT);
pinMode(out3, OUTPUT);
pinMode(out4, OUTPUT);
pinMode(trigPin, OUTPUT);
pinMode(echoPin,INPUT);
servo.attach(4); //servonun pin tanımı
delay(10000);
}
//Sonsuza kadar tekrar edilen döngü
void loop() {
while (Serial.available()){ //Okumak için kullanılabilir bayt olup olmadığını kontrol et
delay(20); //20 milisaniye bekleniliyor.
char c = Serial.read(); //Seri okuma gerçekleştiriliyor.
if (c == '#') {break;} // döngü sonu.
voice += c; //Sesi yazıya çeviriyoruz.
}
if (voice.length() > 0) {
Serial.println(voice); //seri monitöre söylenenler yazdırılıyor.
if(voice == "*geri"||voice == "*geri gel")
{
geri();}
else if(voice == "*serbestsin"||voice == "*gezebilirsin"||voice == "*gezebilirsin kanka"||voice == "*gezebilirsin dostum"
||voice == "*Kafana göre takıl dostum"||voice == "*serbest"||voice == "*Kafana göre takıl kanka")
{
serbest();}
else if(voice == "*İleri"||voice == "*ileri git")
{
ileri();}
else if(voice == "*Sağa git"||voice == "*Sağa dön")
{
sag();}
else if(voice == "*sola git"||voice == "*sol git"||voice == "*sol dön"||voice == "*sola dön")
{
sol();}
else if(voice == "*dur"||voice == "*dur dedim"||voice == "*durur musun")
{dur();
}
else if(voice == "*ileri git dur"||voice == "*biraz ileri git")
{ileri();
delay(1500);
dur();}
else if(voice == "*geri gel dur"||voice == "*biraz geri gel"||voice == "*geri gelip dur")
{geri();
delay(800);
dur();}
else if(voice == "*Sola git dur"||voice == "*biraz Sola git"||voice == "*sola gidip dur")
{sol();
delay(3000);
dur();}
else if(voice == "*Sağına git dur"||voice == "*biraz Sağına git"||voice == "*sağına gidip dur")
{sag();
delay(500);
dur();}
else if(voice == "*sola bak"||voice == "*soluna bak"||voice == "*sol bak")
{
solabak();}
else if(voice == "*Sağa bak"||voice == "*Sağına bak"||voice == "*sabah"||voice == "*salavat"||voice == "*sana bak")
{
sagabak();}
else if(voice == "*önüne bak"||voice == "*öne bak"||voice == "*karşına bak")
{
onunebak();}
else if(voice == "*Merhaba"||voice == "*Selam")
{
merhaba();
}
else if(voice == "*iyi"||voice == "*iyiyim"||voice == "*komik"||voice == "*çok komik"||voice == "*komiksin"||voice == "*çok komiksin"||voice == "*Sağ ol"||voice == "*teşekkürler"||voice == "*sağolasın"
||voice == "*teşekkür ederim"||voice == "*adamsın"||voice == "*çok sağ ol"||voice == "*robotsun"||voice == "*Ben de iyiyim sağol"||voice == "*Ben de iyiyim teşekkür ederim"||voice == "*Ben de iyiyim")
{
gul();
}
else if(voice == "*nasılsın"||voice == "*ne haber")
{iyiyim();
}
else if(voice == "*adın ne"||voice == "*ismin ne")
{
isimsor();}
else if(voice == "*yaşın kaç"||voice == "*kaç yaşındasın"||voice == "*kaç yıldır yaşıyorsun")
{
yas();}
else if(voice == "*nerelisin")
{
nereli();}
else if(voice == "*Seni seviyorum")
{
sevgi();}
else if(voice == "*hiç"||voice == "*öylesine sordum"||voice == "*boşver")
{
nereli();}
else if(voice == "*güzel"||voice == "*güzel isim"||voice == "*güzelmiş"||voice == "*ismin güzelmiş")
{
sagol();}
voice="";
}
}
// robotun yön komutları
void ileri()
{
digitalWrite(out2, LOW);
digitalWrite(out1, HIGH);
digitalWrite(out4, LOW);
digitalWrite(out3, HIGH);
}
void geri()
{
digitalWrite(out1, LOW);
digitalWrite(out2, HIGH);
digitalWrite(out3, LOW);
digitalWrite(out4, HIGH);
}
void sag()
{
digitalWrite(out1, LOW);
digitalWrite(out2, LOW);
digitalWrite(out4, HIGH);
digitalWrite(out3, LOW);
}
void sol()
{
digitalWrite(out2, HIGH);
digitalWrite(out1, LOW);
digitalWrite(out3, LOW);
digitalWrite(out4, LOW);
}
void dur()
{
digitalWrite(out2, LOW);
digitalWrite(out1, LOW);
digitalWrite(out3, LOW);
digitalWrite(out4, LOW);
}
void iyiyim()
{
char *ad[]={"IYI SEN?", "EH İYİ SEN?","SAGOL SEN?","KOTU SEN?","YORGUN SEN?",};
long ad1;
ad1 = random(sizeof(ad)/sizeof(char*));
tft.setTextWrap(false);
tft.fillScreen(ST7735_BLACK);
tft.setRotation(0);
tft.setCursor(0, 5);
tft.setTextColor(ST7735_CYAN);
tft.setTextSize(2);
tft.println(" ");
tft.println(" ");
tft.println(ad[ad1]);
}
void merhaba()
{
char *kelime[]={" Merhaba", " Selam",};
long kelime1;
char *kelime2[]={" Dostum"," Adamim"," Kanka"," Kanki",};
long kelime3;
kelime1 = random(sizeof(kelime)/sizeof(char*));
tft.setTextWrap(false);
tft.fillScreen(ST7735_BLACK);
tft.setRotation(0);
tft.setCursor(0, 5);
tft.setTextColor(ST7735_CYAN);
tft.setTextSize(2);
tft.println(" ");
tft.println(" ");
tft.println(kelime[kelime1]);
kelime3 = random(sizeof(kelime2)/sizeof(char*));
tft.println(" ");
tft.println(kelime2[kelime3]);
delay(1000);
}
void isimsor()
{
char *actors[]={"Adim Golge", " Golge", "Ben Golge",};
long actor1;
actor1 = random(sizeof(actors)/sizeof(char*));
tft.setTextWrap(false);
tft.fillScreen(ST7735_BLACK);
tft.setRotation(0);
tft.setCursor(0, 5);
tft.setTextColor(ST7735_CYAN);
tft.setTextSize(2);
tft.println(" ");
tft.println(" ");
tft.println(actors[actor1]);
}
void sagol()
{
char *sag[]={" Sagol", "Tesekkurler", " Yaa <3",};
long sag1;
sag1 = random(sizeof(sag)/sizeof(char*));
tft.setTextWrap(false);
tft.fillScreen(ST7735_BLACK);
tft.setRotation(0);
tft.setCursor(0, 5);
tft.setTextColor(ST7735_CYAN);
tft.setTextSize(2);
tft.println(" ");
tft.println(" ");
tft.println(sag[sag1]);
}
void gul()
{
tft.setTextWrap(false);
tft.fillScreen(ST7735_BLACK);
tft.setRotation(1);
tft.setCursor(0, 5);
tft.setTextColor(ST7735_CYAN);
tft.setTextSize(5);
tft.println(" ");
tft.print(" )");
}
void yas()
{
char *yas[]={" 18",};
long yas1;
char *yas2[]={" DOSTUM"," KANKA"," ADAMIM",};
long yas3;
yas1 = random(sizeof(yas)/sizeof(char*));
tft.setTextWrap(false);
tft.fillScreen(ST7735_BLACK);
tft.setRotation(0);
tft.setCursor(0, 5);
tft.setTextColor(ST7735_CYAN);
tft.setTextSize(2);
tft.println(" ");
tft.println(" ");
tft.println(yas[yas1]);
yas3 = random(sizeof(yas2)/sizeof(char*));
tft.println(" ");
tft.println(yas2[yas3]);
}
void nereli()
{
char *nere[]={"ISTANBUL","DUNYALIYIM","HEMSERIYIZ","OF SANANE",};
long nere1;
nere1 = random(sizeof(nere)/sizeof(char*));
tft.setTextWrap(false);
tft.fillScreen(ST7735_BLACK);
tft.setRotation(0);
tft.setCursor(0, 5);
tft.setTextColor(ST7735_CYAN);
tft.setTextSize(2);
tft.println(" ");
tft.println(" ");
tft.println(nere[nere1]);
}
void sevgi()
{
char *sevgi[]={"Utandirma","Yaa Utandim","Bende be!",};
long sevgi1;
sevgi1 = random(sizeof(sevgi)/sizeof(char*));
tft.setTextWrap(false);
tft.fillScreen(ST7735_BLACK);
tft.setRotation(0);
tft.setCursor(0, 5);
tft.setTextColor(ST7735_CYAN);
tft.setTextSize(2);
tft.println(" ");
tft.println(" ");
tft.println(sevgi[sevgi1]);
}
void serbest()
{
int i = 0;
while( i++ < 25) {
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
sure = pulseIn(echoPin, HIGH);
uzaklik = sure /29.1/2;
if(uzaklik > 200)
uzaklik = 200;
Serial.print("Uzaklik ");
Serial.print(uzaklik);
Serial.println(" Cm cinsinden.");
delay(500);
on_uzaklik = uzaklik;
if(on_uzaklik > 15)
{
servo.write(90);
ileri();
delay(5000);
}
else
{
dur();
servo.write(180);
delay(400);
sol_uzaklik = uzaklik;
if(sol_uzaklik > 15)
sol();
delay(700);
ileri();
if(sol_uzaklik < 15)
{
sag();
delay(700);
ileri();
}
else
{
geri();
delay(700);
}
}
}
}
void sagabak()
{
servo.write(0);
delay(300);
}
void solabak()
{
servo.write(180);
delay(300);
}
void onunebak()
{
servo.write(90);
delay(300);
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team