Cep telefonu ya da tablet ile robotunuzu kontrol etmek isterseniz örnek program, açıklama ve android yazılım burada.
Android yazılımı yüklemek için resme tıklayınız.
ARDUINO PROGRAM
// ahmet emre ceyhan. ekim 2015
#include <SoftwareSerial.h>
SoftwareSerial mySerial(11, 12);
int hz=100;
int motor1Pin1 = 9;
int motor1Pin2 = 10;
int enable1Pin = 5;
int motor2Pin1 = 13;
int motor2Pin2 = 7;
int enable2Pin =8;
int state;
int flag=0;
int stateStop=0;
void setup() {
// giris cikis ayarlari
pinMode(motor1Pin1, OUTPUT);
pinMode(motor1Pin2, OUTPUT);
pinMode(enable1Pin, OUTPUT);
pinMode(motor2Pin1, OUTPUT);
pinMode(motor2Pin2, OUTPUT);
pinMode(enable2Pin, OUTPUT);
// motora verilen piinlerin ayarlanmasi
//seri haberlesme katsayisi def 9600 kullannin
Serial.begin(9600);
mySerial.begin(9600);
}
void loop() {
if(mySerial.available() > 0){
state = mySerial.read();
flag=0;
}
if (state >=10 || state <=150)
{
hz=state;
delay(15);
if(flag == 0){
flag=1;
}
}
// arac ileri hareket eder
if (state == 201) {
analogWrite(enable1Pin, hz);
analogWrite(enable2Pin, hz);
digitalWrite(motor1Pin1, HIGH);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, HIGH);
if(flag == 0){
flag=1;
}
}
// arac sola doner
else if (state == 204) {
analogWrite(enable1Pin, hz);
analogWrite(enable2Pin, hz);
digitalWrite(motor1Pin1, HIGH);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin1, HIGH);
digitalWrite(motor2Pin2, LOW);
if(flag == 0){
flag=1;
}
delay(25);
state=3;
stateStop=1;
}
// arac durur
else if (state == 200 || stateStop == 1) {
analogWrite(enable1Pin, hz);
analogWrite(enable2Pin, hz);
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, LOW);
if(flag == 0){
flag=1;
}
stateStop=0;
}
// arac saga doner
else if (state == 203) {
analogWrite(enable1Pin, hz);
analogWrite(enable2Pin, hz);
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, HIGH);
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, HIGH);
if(flag == 0){
flag=1;
}
delay(25);
state=3;
stateStop=1;
}
// arac geri gider
else if (state == 202) {
analogWrite(enable1Pin, hz);
analogWrite(enable2Pin, hz);
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, HIGH);
digitalWrite(motor2Pin1, HIGH);
digitalWrite(motor2Pin2, LOW);
if(flag == 0){
flag=1;
}
}
}