100% found this document useful (5 votes)
1K views247 pages

The Best Twenty Six Project With The Arduino PDF

The document describes how to build an Android controlled robot using an Arduino. It provides links to download the necessary 3D printed parts and provides the Arduino code to control 12 servo motors to move the robot's 4 legs. It describes how to assemble the robot parts, insert the servo motors, and attach them to the Arduino. The code provided controls the movement of the legs to allow the robot to stand, walk forward/backward, turn, wave its hands, and sit.

Uploaded by

monkbernal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (5 votes)
1K views247 pages

The Best Twenty Six Project With The Arduino PDF

The document describes how to build an Android controlled robot using an Arduino. It provides links to download the necessary 3D printed parts and provides the Arduino code to control 12 servo motors to move the robot's 4 legs. It describes how to assemble the robot parts, insert the servo motors, and attach them to the Arduino. The code provided controls the movement of the legs to allow the robot to stand, walk forward/backward, turn, wave its hands, and sit.

Uploaded by

monkbernal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 247

THE BEST TWENTY SIX PROJECT WITH

THE ARDUiNO

1-) ARDUINO CAR PARK SENSOR PROJECT

2-) ARDUINO ANDROID CONTROLLED


ORIGINAL ROBOT CONSTRUCTION

3-) ARDUINO AUTOMATIC FISH FEEDING


MACHINE WOOD PROJECT

4-) ARDUINO EMG SENSOR PROSTHESIS


ARM PROJECT

5-) ARDUINO ULTRASONIC RADAR PROJECT

6-) SERVO MOTOR CONTROL WITH


ARDUINO IR INFRARED CONTROL

7-) DIGITAL METER CONSTRUCTION WITH


ARDUINO

8-) Arduino Shaking Tea Machine

9)ARDUINO DC MOTOR SPEED DIMENSION


10) REMOTE CONTROL APPLICATION WITH
ARDUINO AND NRF24L01

11) 3D ROBOT PROJECT WITH BOB


LOCATED WITH ARDUINO

12) ARDUİNO FUZZY LOGIC TEMPERATURE


MOISTURE PROJECT

13) DRAWING ROBOT CAR

14) HOVERBOARD CONSTRUCTION WITH ARDUİNO

15) ROBOT ARM WITH ARDUİNO LASER CUTTING

16) BOMB DISPOSAL ROBOT PROJECT WITH


ARDUiNO

17) ARDUİNO SPIDER ROBOT CONSTRUCTION

18) HUMAN ROBOT CONSTRUCTION WITH ARDUiNO

19) ARDUINO OLLIE ROBOT CONSTRUCTION

20) ROBOT MAKING FAST LINE WITH ARDUİNO

21) ROBOT PRODUCTION TREATED WITH ARDUiNO

22) ROBOT CONSTRUCTION PROJECT WITH


ARDUİNO
23) TANK PRODUCTION WITH ARDUiNO

24) SUMO ROBOT PROJECT WITH ARDUiNO

25) ROBOT CONTROL PROJECT WITH ARDUiNO


TELEVISION CONTROL

26) ARDUiNO ANDROID CONTROLLED RC CAR


PROJECT
1-) ARDUINO CAR PARK SENSOR
PROJECT
I'll tell you a fun project that you can do on a low budget. A
small copy of your parking

sensor we have seen in our life. First I will tell you what
Arduino is doing. We can easily

program with Arduino libraries. Using the signals from the


sensors, we can design

robots and systems that interact with the environment.


Arduino has various cards and

modules designed to provide solutions to different needs. We


can develop your projects

using these cards and modules.

NECESSARY MATERIALS:
ARDUINO
4 LEDs
5 PCS 220 OHM RESISTANCE
1 PIECE BUZZER
BREAD BOARD
QUANTITY JUMPER CABLE
Scheme showing the links of our Project
Deviation Codes:

const int trigger_pin = 12;

const int echo_pin = 13;

const int aled = 2 ;


const int bled = 3;.

const int cled = 4;

const int dled = 5;


const int buzzer = 6;

int sure ;

int mesafe ;

 

void setup() {

pinMode(aled , OUTPUT);

pinMode(bled , OUTPUT);

pinMode(cled , OUTPUT);

pinMode(dled , OUTPUT);

pinMode(buzzer , OUTPUT

pinMode(trigger_pin , OUTPUT);

pinMode(echo_pin , INPUT);

void loop()

digitalWrite(trigger_pin , HIGH);
delayMicroseconds(1000); //

digitalWrite(trigger_pin , LOW);

sure = pulseIn(echo_pin , HIGH);

mesafe = (sure / 2) / 29.1;

 

if (mesafe <= 10)

digitalWrite(aled , HIGH);

digitalWrite(bled , HIGH);

digitalWrite(cled , HIGH);

digitalWrite(dled , HIGH);

digitalWrite(buzzer , HIGH);

delay(250);

digitalWrite(buzzer , LOW);

else if (mesafe <= 25)


{

digitalWrite(aled , LOW);

digitalWrite(bled , HIGH);

digitalWrite(cled , HIGH);

digitalWrite(dled , HIGH);

digitalWrite(buzzer , HIGH);

delay(500);

digitalWrite(buzzer , LOW);

else if ( mesafe <= 50)

digitalWrite(aled , LOW);

digitalWrite(bled , LOW);.

digitalWrite(cled , HIGH);

digitalWrite(dled , HIGH);

digitalWrite(buzzer , HIGH);
delay(750);

digitalWrite(buzzer , LOW);

else

digitalWrite(aled , LOW);

digitalWrite(bled , LOW);

digitalWrite(cled , LOW);

digitalWrite(dled , HIGH);
}

2-) ARDUINO ANDROID


CONTROLLED ORIGINAL ROBOT
CONSTRUCTION
NECESSARY MATERIALS:
12 Pieces sg90 servo motor
Arduino Uno
Arduino ProtoShield
HC-05 or HC-06 bluetooth module
3D Parts
Power source

Download link for robotic body:

http://www.thingiverse.com/thing:1009659
http://www.instructables.com/id/DIY-Spider-RobotQuad-robot-
Quadruped/step1/Test-the-main-board/
Parts Required:
1x body_d.stl
1x body_u.stl
2x coxa_l.stl
2x coxa_r.stl
2x tibia_l.stl
2x tibia_r.stl
4x femur_1.stl
8x s_hold.stl

Now all the plastic parts are going to be assembled after the
punch. The first thing you need to do is to insert the servo
motors into the places where you need to enter, remove the 4
screws under the servos and lift the lid so as not to damage the
servo cable. Screw in the cover again after inserting the servo
into place.

NOTE-2: Do not screw the upper plastic parts of servo motors.


Observe the sources I supply when replacing the servomotors
and pay attention to what direction the motors are facing.

The motors need to be connected according to the leg order. The


engines are numbered according to the leg order. At the same
time, the Arduino code records which motor should be
connected to which pine.
There is a setting code for setting the angles of the motors after
assembly is finished. The upper plastic parts of the servos need
to be screwed after this test code is loaded. Try to make the
positions and alignments of the parts as symmetrical as possible,
and then screw the upper plastic part of the servo motors, as
shown in the source I should pay attention to here.

Setting Code of Servos:


http://www.instructables.com/id/DIY-Spider-RobotQuad-robot-
Quadruped/step11/Locate-the-initial-position-for-legs/
If the servos are not screwed in after the setting code, the process
is complete. You can now download the actual code.

Arduino Code:
http://www.instructables.com/id/DIY-Spider-RobotQuad-robot-
Quadruped/step13/It-is-showtime/
/* Includes ------------------------------------------------------------------*/
#include <Servo.h> //to define and control servos
#include <FlexiTimer2.h>//to set a timer to manage all servos
/* Servos --------------------------------------------------------------------*/
//define 12 servos for 4 legs
Servo servo[4][3];
//define servos' ports
const int servo_pin[4][3] = { {2, 3, 4}, {5, 6, 7}, {8, 9, 10}, {11, 12, 13}
};
/* Size of the robot ---------------------------------------------------------*/
const float length_a = 55;
const float length_b = 77.5;
const float length_c = 27.5;
const float length_side = 71;
const float z_absolute = -28;
/* Constants for movement ----------------------------------------------------*/
const float z_default = -50, z_up = -30, z_boot = z_absolute;
const float x_default = 62, x_offset = 0;
const float y_start = 0, y_step = 40;
/* variables for movement ----------------------------------------------------*/
volatile float site_now[4][3]; //real-time coordinates of the end of each
leg
volatile float site_expect[4][3]; //expected coordinates of the end of each
leg
float temp_speed[4][3]; //each axis' speed, needs to be recalculated before
each movement
float move_speed; //movement speed
float speed_multiple = 1; //movement speed multiple
const float spot_turn_speed = 4;
const float leg_move_speed = 8;
const float body_move_speed = 3;
const float stand_seat_speed = 1;
volatile int rest_counter; //+1/0.02s, for automatic rest
//functions' parameter
const float KEEP = 255;
//define PI for calculation
const float pi = 3.1415926;
/* Constants for turn --------------------------------------------------------*/
//temp length
const float temp_a = sqrt(pow(2 * x_default + length_side, 2) +
pow(y_step, 2));
const float temp_b = 2 * (y_start + y_step) + length_side;
const float temp_c = sqrt(pow(2 * x_default + length_side, 2) + pow(2 *
y_start + y_step + length_side, 2));
const float temp_alpha = acos((pow(temp_a, 2) + pow(temp_b, 2) -
pow(temp_c, 2)) / 2 / temp_a / temp_b);
//site for turn
const float turn_x1 = (temp_a - length_side) / 2;
const float turn_y1 = y_start + y_step / 2;
const float turn_x0 = turn_x1 - temp_b * cos(temp_alpha);
const float turn_y0 = temp_b * sin(temp_alpha) - turn_y1 - length_side;
/* ---------------------------------------------------------------------------*/

/*
- setup function
---------------------------------------------------------------------------*/
void setup()
{
//start serial for debug
Serial.begin(115200);
Serial.println("Robot starts initialization");
//initialize default parameter
set_site(0, x_default - x_offset, y_start + y_step, z_boot);
set_site(1, x_default - x_offset, y_start + y_step, z_boot);
set_site(2, x_default + x_offset, y_start, z_boot);
set_site(3, x_default + x_offset, y_start, z_boot);
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 3; j++)
{
site_now[i][j] = site_expect[i][j];
}
}
//start servo service
FlexiTimer2::set(20, servo_service);
FlexiTimer2::start();
Serial.println("Servo service started");
//initialize servos
servo_attach();
Serial.println("Servos initialized");
Serial.println("Robot initialization Complete");
}
void servo_attach(void)
{
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 3; j++)
{
servo[i][j].attach(servo_pin[i][j]);
delay(100);
}
}
}

void servo_detach(void)
{
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 3; j++)
{
servo[i][j].detach();
delay(100);
}
}
}
/*
- loop function
---------------------------------------------------------------------------*/
void loop()
{
Serial.println("Stand");
stand();
delay(2000);
Serial.println("Step forward");
step_forward(5);
delay(2000);
Serial.println("Step back");
step_back(5);
delay(2000);
Serial.println("Turn left");
turn_left(5);
delay(2000);
Serial.println("Turn right");
turn_right(5);
delay(2000);
Serial.println("Hand wave");
hand_wave(3);
delay(2000);
Serial.println("Hand wave");
hand_shake(3);
delay(2000);
Serial.println("Sit");
sit();
delay(5000);
}

/*
- sit
- blocking function
---------------------------------------------------------------------------*/
void sit(void)
{
move_speed = stand_seat_speed;
for (int leg = 0; leg < 4; leg++)
{
set_site(leg, KEEP, KEEP, z_boot);
}
wait_all_reach();
}

/*
- stand
- blocking function
---------------------------------------------------------------------------*/
void stand(void)
{
move_speed = stand_seat_speed;
for (int leg = 0; leg < 4; leg++) { set_site(leg, KEEP, KEEP, z_default); }
wait_all_reach(); } /* - spot turn to left - blocking function - parameter
step steps wanted to turn ---------------------------------------------------------
------------------*/ void turn_left(unsigned int step) { move_speed =
spot_turn_speed; while (step-- > 0)
{
if (site_now[3][1] == y_start)
{
//leg 3&1 move
set_site(3, x_default + x_offset, y_start, z_up);
wait_all_reach();
set_site(0, turn_x1 - x_offset, turn_y1, z_default);
set_site(1, turn_x0 - x_offset, turn_y0, z_default);
set_site(2, turn_x1 + x_offset, turn_y1, z_default);
set_site(3, turn_x0 + x_offset, turn_y0, z_up);
wait_all_reach();

set_site(3, turn_x0 + x_offset, turn_y0, z_default);


wait_all_reach();

set_site(0, turn_x1 + x_offset, turn_y1, z_default);


set_site(1, turn_x0 + x_offset, turn_y0, z_default);
set_site(2, turn_x1 - x_offset, turn_y1, z_default);
set_site(3, turn_x0 - x_offset, turn_y0, z_default);
wait_all_reach();

set_site(1, turn_x0 + x_offset, turn_y0, z_up);


wait_all_reach();

set_site(0, x_default + x_offset, y_start, z_default);


set_site(1, x_default + x_offset, y_start, z_up);
set_site(2, x_default - x_offset, y_start + y_step, z_default);
set_site(3, x_default - x_offset, y_start + y_step, z_default);
wait_all_reach();

set_site(1, x_default + x_offset, y_start, z_default);


wait_all_reach();
}
else
{
//leg 0&2 move
set_site(0, x_default + x_offset, y_start, z_up);
wait_all_reach();

set_site(0, turn_x0 + x_offset, turn_y0, z_up);


set_site(1, turn_x1 + x_offset, turn_y1, z_default);
set_site(2, turn_x0 - x_offset, turn_y0, z_default);
set_site(3, turn_x1 - x_offset, turn_y1, z_default);
wait_all_reach();

set_site(0, turn_x0 + x_offset, turn_y0, z_default);


wait_all_reach();

set_site(0, turn_x0 - x_offset, turn_y0, z_default);


set_site(1, turn_x1 - x_offset, turn_y1, z_default);
set_site(2, turn_x0 + x_offset, turn_y0, z_default);
set_site(3, turn_x1 + x_offset, turn_y1, z_default);
wait_all_reach();

set_site(2, turn_x0 + x_offset, turn_y0, z_up);


wait_all_reach();

set_site(0, x_default - x_offset, y_start + y_step, z_default);


set_site(1, x_default - x_offset, y_start + y_step, z_default);
set_site(2, x_default + x_offset, y_start, z_up);
set_site(3, x_default + x_offset, y_start, z_default);
wait_all_reach();

set_site(2, x_default + x_offset, y_start, z_default);


wait_all_reach();
}
}
}

/*
- spot turn to right
- blocking function
- parameter step steps wanted to turn
---------------------------------------------------------------------------*/
void turn_right(unsigned int step)
{
move_speed = spot_turn_speed;
while (step-- > 0)
{
if (site_now[2][1] == y_start)
{
//leg 2&0 move
set_site(2, x_default + x_offset, y_start, z_up);
wait_all_reach();

set_site(0, turn_x0 - x_offset, turn_y0, z_default);


set_site(1, turn_x1 - x_offset, turn_y1, z_default);
set_site(2, turn_x0 + x_offset, turn_y0, z_up);
set_site(3, turn_x1 + x_offset, turn_y1, z_default);
wait_all_reach();

set_site(2, turn_x0 + x_offset, turn_y0, z_default);


wait_all_reach();

set_site(0, turn_x0 + x_offset, turn_y0, z_default);


set_site(1, turn_x1 + x_offset, turn_y1, z_default);
set_site(2, turn_x0 - x_offset, turn_y0, z_default);
set_site(3, turn_x1 - x_offset, turn_y1, z_default);
wait_all_reach();

set_site(0, turn_x0 + x_offset, turn_y0, z_up);


wait_all_reach();

set_site(0, x_default + x_offset, y_start, z_up);


set_site(1, x_default + x_offset, y_start, z_default);
set_site(2, x_default - x_offset, y_start + y_step, z_default);
set_site(3, x_default - x_offset, y_start + y_step, z_default);
wait_all_reach();

set_site(0, x_default + x_offset, y_start, z_default);


wait_all_reach();
}
else
{
//leg 1&3 move
set_site(1, x_default + x_offset, y_start, z_up);
wait_all_reach();

set_site(0, turn_x1 + x_offset, turn_y1, z_default);


set_site(1, turn_x0 + x_offset, turn_y0, z_up);
set_site(2, turn_x1 - x_offset, turn_y1, z_default);
set_site(3, turn_x0 - x_offset, turn_y0, z_default);
wait_all_reach();

set_site(1, turn_x0 + x_offset, turn_y0, z_default);


wait_all_reach();

set_site(0, turn_x1 - x_offset, turn_y1, z_default);


set_site(1, turn_x0 - x_offset, turn_y0, z_default);
set_site(2, turn_x1 + x_offset, turn_y1, z_default);
set_site(3, turn_x0 + x_offset, turn_y0, z_default);
wait_all_reach();

set_site(3, turn_x0 + x_offset, turn_y0, z_up);


wait_all_reach();

set_site(0, x_default - x_offset, y_start + y_step, z_default);


set_site(1, x_default - x_offset, y_start + y_step, z_default);
set_site(2, x_default + x_offset, y_start, z_default);
set_site(3, x_default + x_offset, y_start, z_up);
wait_all_reach();

set_site(3, x_default + x_offset, y_start, z_default);


wait_all_reach();
}
}
}

/*
- go forward
- blocking function
- parameter step steps wanted to go
---------------------------------------------------------------------------*/
void step_forward(unsigned int step)
{
move_speed = leg_move_speed;
while (step-- > 0)
{
if (site_now[2][1] == y_start)
{
//leg 2&1 move
set_site(2, x_default + x_offset, y_start, z_up);
wait_all_reach();
set_site(2, x_default + x_offset, y_start + 2 * y_step, z_up);
wait_all_reach();
set_site(2, x_default + x_offset, y_start + 2 * y_step, z_default);
wait_all_reach();

move_speed = body_move_speed;

set_site(0, x_default + x_offset, y_start, z_default);


set_site(1, x_default + x_offset, y_start + 2 * y_step, z_default);
set_site(2, x_default - x_offset, y_start + y_step, z_default);
set_site(3, x_default - x_offset, y_start + y_step, z_default);
wait_all_reach();

move_speed = leg_move_speed;

set_site(1, x_default + x_offset, y_start + 2 * y_step, z_up);


wait_all_reach();
set_site(1, x_default + x_offset, y_start, z_up);
wait_all_reach();
set_site(1, x_default + x_offset, y_start, z_default);
wait_all_reach();
}
else
{
//leg 0&3 move
set_site(0, x_default + x_offset, y_start, z_up);
wait_all_reach();
set_site(0, x_default + x_offset, y_start + 2 * y_step, z_up);
wait_all_reach();
set_site(0, x_default + x_offset, y_start + 2 * y_step, z_default);
wait_all_reach();

move_speed = body_move_speed;

set_site(0, x_default - x_offset, y_start + y_step, z_default);


set_site(1, x_default - x_offset, y_start + y_step, z_default);
set_site(2, x_default + x_offset, y_start, z_default);
set_site(3, x_default + x_offset, y_start + 2 * y_step, z_default);
wait_all_reach();

move_speed = leg_move_speed;

set_site(3, x_default + x_offset, y_start + 2 * y_step, z_up);


wait_all_reach();
set_site(3, x_default + x_offset, y_start, z_up);
wait_all_reach();
set_site(3, x_default + x_offset, y_start, z_default);
wait_all_reach();
}
}
}

/*
- go back
- blocking function
- parameter step steps wanted to go
---------------------------------------------------------------------------*/
void step_back(unsigned int step)
{
move_speed = leg_move_speed;
while (step-- > 0)
{
if (site_now[3][1] == y_start)
{
//leg 3&0 move
set_site(3, x_default + x_offset, y_start, z_up);
wait_all_reach();
set_site(3, x_default + x_offset, y_start + 2 * y_step, z_up);
wait_all_reach();
set_site(3, x_default + x_offset, y_start + 2 * y_step, z_default);
wait_all_reach();

move_speed = body_move_speed;

set_site(0, x_default + x_offset, y_start + 2 * y_step, z_default);


set_site(1, x_default + x_offset, y_start, z_default);
set_site(2, x_default - x_offset, y_start + y_step, z_default);
set_site(3, x_default - x_offset, y_start + y_step, z_default);
wait_all_reach();

move_speed = leg_move_speed;

set_site(0, x_default + x_offset, y_start + 2 * y_step, z_up);


wait_all_reach();
set_site(0, x_default + x_offset, y_start, z_up);
wait_all_reach();
set_site(0, x_default + x_offset, y_start, z_default);
wait_all_reach();
}
else
{
//leg 1&2 move
set_site(1, x_default + x_offset, y_start, z_up);
wait_all_reach();
set_site(1, x_default + x_offset, y_start + 2 * y_step, z_up);
wait_all_reach();
set_site(1, x_default + x_offset, y_start + 2 * y_step, z_default);
wait_all_reach();

move_speed = body_move_speed;

set_site(0, x_default - x_offset, y_start + y_step, z_default);


set_site(1, x_default - x_offset, y_start + y_step, z_default);
set_site(2, x_default + x_offset, y_start + 2 * y_step, z_default);
set_site(3, x_default + x_offset, y_start, z_default);
wait_all_reach();

move_speed = leg_move_speed;

set_site(2, x_default + x_offset, y_start + 2 * y_step, z_up);


wait_all_reach();
set_site(2, x_default + x_offset, y_start, z_up);
wait_all_reach();
set_site(2, x_default + x_offset, y_start, z_default);
wait_all_reach();
}
}
}

// add by RegisHsu

void body_left(int i)
{
set_site(0, site_now[0][0] + i, KEEP, KEEP);
set_site(1, site_now[1][0] + i, KEEP, KEEP);
set_site(2, site_now[2][0] - i, KEEP, KEEP);
set_site(3, site_now[3][0] - i, KEEP, KEEP);
wait_all_reach();
}
void body_right(int i)
{
set_site(0, site_now[0][0] - i, KEEP, KEEP);
set_site(1, site_now[1][0] - i, KEEP, KEEP);
set_site(2, site_now[2][0] + i, KEEP, KEEP);
set_site(3, site_now[3][0] + i, KEEP, KEEP);
wait_all_reach();
}

void hand_wave(int i)
{
float x_tmp;
float y_tmp;
float z_tmp;
move_speed = 1;
if (site_now[3][1] == y_start)
{
body_right(15);
x_tmp = site_now[2][0];
y_tmp = site_now[2][1];
z_tmp = site_now[2][2];
move_speed = body_move_speed;
for (int j = 0; j < i; j++)
{
set_site(2, turn_x1, turn_y1, 50);
wait_all_reach();
set_site(2, turn_x0, turn_y0, 50);
wait_all_reach();
}
set_site(2, x_tmp, y_tmp, z_tmp);
wait_all_reach();
move_speed = 1;
body_left(15);
}
else
{
body_left(15);
x_tmp = site_now[0][0];
y_tmp = site_now[0][1];
z_tmp = site_now[0][2];
move_speed = body_move_speed;
for (int j = 0; j < i; j++)
{
set_site(0, turn_x1, turn_y1, 50);
wait_all_reach();
set_site(0, turn_x0, turn_y0, 50);
wait_all_reach();
}
set_site(0, x_tmp, y_tmp, z_tmp);
wait_all_reach();
move_speed = 1;
body_right(15);
}
}

void hand_shake(int i)
{
float x_tmp;
float y_tmp;
float z_tmp;
move_speed = 1;
if (site_now[3][1] == y_start)
{
body_right(15);
x_tmp = site_now[2][0];
y_tmp = site_now[2][1];
z_tmp = site_now[2][2];
move_speed = body_move_speed;
for (int j = 0; j < i; j++)
{
set_site(2, x_default - 30, y_start + 2 * y_step, 55);
wait_all_reach();
set_site(2, x_default - 30, y_start + 2 * y_step, 10);
wait_all_reach();
}
set_site(2, x_tmp, y_tmp, z_tmp);
wait_all_reach();
move_speed = 1;
body_left(15);
}
else
{
body_left(15);
x_tmp = site_now[0][0];
y_tmp = site_now[0][1];
z_tmp = site_now[0][2];
move_speed = body_move_speed;
for (int j = 0; j < i; j++)
{
set_site(0, x_default - 30, y_start + 2 * y_step, 55);
wait_all_reach();
set_site(0, x_default - 30, y_start + 2 * y_step, 10);
wait_all_reach();
}
set_site(0, x_tmp, y_tmp, z_tmp);
wait_all_reach();
move_speed = 1;
body_right(15);
}
}

/*
- microservos service /timer interrupt function/50Hz
- when set site expected,this function move the end point to it in a straight
line
- temp_speed[4][3] should be set before set expect site,it make sure the
end point
move in a straight line,and decide move speed.
---------------------------------------------------------------------------*/
void servo_service(void)
{
sei();
static float alpha, beta, gamma;

for (int i = 0; i < 4; i++)


{
for (int j = 0; j < 3; j++) { if (abs(site_now[i][j] - site_expect[i][j]) >=
abs(temp_speed[i][j]))
site_now[i][j] += temp_speed[i][j];
else
site_now[i][j] = site_expect[i][j];
}

cartesian_to_polar(alpha, beta, gamma, site_now[i][0], site_now[i][1],


site_now[i][2]);
polar_to_servo(i, alpha, beta, gamma);
}

rest_counter++;
}

/*
- set one of end points' expect site
- this founction will set temp_speed[4][3] at same time
- non - blocking function
---------------------------------------------------------------------------*/
void set_site(int leg, float x, float y, float z)
{
float length_x = 0, length_y = 0, length_z = 0;

if (x != KEEP)
length_x = x - site_now[leg][0];
if (y != KEEP)
length_y = y - site_now[leg][1];
if (z != KEEP)
length_z = z - site_now[leg][2];

float length = sqrt(pow(length_x, 2) + pow(length_y, 2) + pow(length_z,


2));

temp_speed[leg][0] = length_x / length * move_speed * speed_multiple;


temp_speed[leg][1] = length_y / length * move_speed * speed_multiple;
temp_speed[leg][2] = length_z / length * move_speed * speed_multiple;

if (x != KEEP)
site_expect[leg][0] = x;
if (y != KEEP)
site_expect[leg][1] = y;
if (z != KEEP)
site_expect[leg][2] = z;
}

/*
- wait one of end points move to expect site
- blocking function
---------------------------------------------------------------------------*/
void wait_reach(int leg)
{
while (1)
if (site_now[leg][0] == site_expect[leg][0])
if (site_now[leg][1] == site_expect[leg][1])
if (site_now[leg][2] == site_expect[leg][2])
break;
}

/*
- wait all of end points move to expect site
- blocking function
---------------------------------------------------------------------------*/
void wait_all_reach(void)
{
for (int i = 0; i < 4; i++) wait_reach(i); } /* - trans site from cartesian to
polar - mathematical model 2/2 -------------------------------------------------
--------------------------*/ void cartesian_to_polar(volatile float &alpha,
volatile float &beta, volatile float &gamma, volatile float x, volatile
float y, volatile float z) { //calculate w-z degree float v, w; w = (x >= 0 ?
1 : -1) * (sqrt(pow(x, 2) + pow(y, 2)));
v = w - length_c;
alpha = atan2(z, v) + acos((pow(length_a, 2) - pow(length_b, 2) + pow(v,
2) + pow(z, 2)) / 2 / length_a / sqrt(pow(v, 2) + pow(z, 2)));
beta = acos((pow(length_a, 2) + pow(length_b, 2) - pow(v, 2) - pow(z, 2)) /
2 / length_a / length_b);
//calculate x-y-z degree
gamma = (w >= 0) ? atan2(y, x) : atan2(-y, -x);
//trans degree pi->180
alpha = alpha / pi * 180;
beta = beta / pi * 180;
gamma = gamma / pi * 180;
}

/*
- trans site from polar to microservos
- mathematical model map to fact
- the errors saved in eeprom will be add
---------------------------------------------------------------------------*/
void polar_to_servo(int leg, float alpha, float beta, float gamma)
{
if (leg == 0)
{
alpha = 90 - alpha;
beta = beta;
gamma += 90;
}
else if (leg == 1)
{
alpha += 90;
beta = 180 - beta;
gamma = 90 - gamma;
}
else if (leg == 2)
{
alpha += 90;
beta = 180 - beta;
gamma = 90 - gamma;
}
else if (leg == 3)
{
alpha = 90 - alpha;
beta = beta;
gamma += 90;
}

servo[leg][0].write(alpha);
servo[leg][1].write(beta);
servo[leg][2].write(gamma);
}
Bluetooth Connection:

The pins of the bluetooth module are connected to the COM part
on the sensor shield. Connection pins:
Arduino Bluetooth
RX————-TX
TX————-RX
VCC———–VCC
GND———-GND

Android App:

The application will be installed when you open the file from
your phone by dropping the Spider.apk file contained in the
download file to any folder on your phone. If Allow unknown
sources is set and you allow the settings, the application will be
installed without problems.

Project File Download Link: (3D Parts not included)


https://yadi.sk/d/y4WuEOeD35XrEb

3-) ARDUINO AUTOMATIC FISH


FEEDING MACHINE WOOD PROJECT

You will be out for the Bayram vacation but are you worried
about your fish in the aquarium?

If you have such a problem, it's time to introduce your fish to


Arduino. In this project you will

learn how to feed your fish with Arduino when you are not at
home.

With the development of technology, the number of intelligent


systems used in homes has
increased considerably. These systems are being developed and
are continuing to be

developed to bring rational solutions to the problems we


experience in daily life. Programs

like Arduino and products which are very easy to prepare the
project give us the chance to

create our own solutions against the troubles we have


experienced. In this article, we have

come up with an easy solution to bringing the problem of


feeding the fish frequently

encountered in fish-fed homes.

Required Hardware:

► Arduino (Uno-Duemilanove-Leonardo-Mega)
► One Servo Motor
► A-B Usb Cable
► 9V battery
► Cable
Schematic of power:

As you can see on the schematic I draw in the Fritzing program,


the connections are very

easy. We connect the black wire to the ground (GND), the red
wire to + 5V and the yellow
wire to the 9th pin. We did not need to install the circuit on the
breadboard because we did not

use the resistor in the circuit and thought it would be easier to do


so. You can install it on the

breadboard if you like.

Construction Stages

1-) We connect the servo motor to the Arduino as shown in the


Fritzing drawing.
2-) Then we connect the servo motor with a thin wire with fine
output as shown in the picture.

3-) Then we attach any obstacle in the dimensions similar to the


plastic image on the end of the servo motor.

4-) When we attach the end of the servo motor to the motor, the
hardware part of our project is completed and finally we connect
the USB cable to Arduino and my computer to connect with the
computer.
So the hardware part is now in the software part.

Running the Arduino Program and Installing the Software


First we run the Arduino IDE program and check the connection
between Arduino and the
computer. Then we compile the code below and send it to
Arduino. Thus, the progeny is
ready. Now that you have entrusted your fish to Arduino, you
can now go on vacation with
peace of mind. ElectricPort has good holidays and good wishes.

Deviation Codes:

#include <Servo.h>
Servo myservo;
int pos = 0;
void setup()
{
myservo.attach(9); // servo pin 9
}
void loop()
{
myservo.write(90);

delay(10000);
myservo.write(55);
delay(300); // kapakların açık olacağı süre.
}

4-) ARDUINO EMG SENSOR


PROSTHESIS ARM PROJECT
With the development of 3D writing technology, the production
of a lot of prosthetic limbs has been facilitated. It has expanded
in working with robotic limbs. Now we will see a new
application area of arduino and its sensors. How can we use a
robotic hand like our own? with the help of the necessary
sensors. The first applications were usually done with a flex
sensor, but since we did not give any precise results, we can say
that the work on this method has been terminated.

EMG sensor (Electromyography) meaning, electronic muscle


and nerve graphy. It is a method that can actually measure
muscle and nerve movements. Materials that we use in our
project.

Required Hardware:

1- Arduino UNO
2- EMG sensor
3- Servo motor shild
4- Robotic Hand

Now we will talk about the electronic hardware and software of


your business. First you will install the following code in your
arduino uno card. Then we place the servo motor connections on
the shild.

Schematic of power:

Deviation Codes:
#include <Servo.h>

#define THRESHOLD 150

#define EMGPIN 3 //Analog pin connected to Muscle Sensor V3 Board

#define LITTLEPIN 3 //Digital pin used by Little servo

#define RINGPIN 5 //Digital pin used by Ring servo

#define MIDDLEPIN 6 //Digital pin used by Middle servo

#define INDEXPIN 9 //Digital pin used by Index servo


#define THUMBPIN 10 //Digital pin used by Thumb servo

//Constants used to open and close the fingers

#define LITTLE 1

#define RING 2

#define MIDDLE 3

#define INDEX 4

#define THUMB 5

Servo servoLittleFinger; // Define servo fingers

Servo servoRingFinger; // Define servo fingers

Servo servoMiddleFinger; // Define servo fingers

Servo servoIndexFinger; // Define servo fingers

Servo servoThumbFinger; // Define servo fingers

int finger;

// Motion routines for handopen and handclose

void openhand(){for(finger = 1; finger < 6; finger++)


{openFinger(finger);}}

void closehand(){for(finger = 1; finger < 6 ;

finger++){closeFinger(finger);}}
void openFinger(int finger){

if(finger==LITTLE){servoLittleFinger.write(0);} // Little finger

else if(finger==RING){servoRingFinger.write(170);}// Ring finger

else if(finger==MIDDLE){servoMiddleFinger.write(170);}// Middle


finger

else if(finger==INDEX){servoIndexFinger.write(170);}// Index finger

else if(finger==THUMB){servoThumbFinger.write(0);}//Thumb finger

void closeFinger(int finger){

if(finger==LITTLE){servoLittleFinger.write(170);} // Little finger

else if(finger==RING){servoRingFinger.write(0);}// Ring finger

else if(finger==MIDDLE){servoMiddleFinger.write(0);}// Middle finger

else if(finger==INDEX){servoIndexFinger.write(0);}// Index finger

else if(finger==THUMB){servoThumbFinger.write(170);}//Thumb finger

void setup(){
Serial.begin(115200);

servoLittleFinger.attach(LITTLEPIN); // Set Little finger servo to

digital pin 3

servoRingFinger.attach(RINGPIN); // Set Ring finger servo to digital pin


5

servoMiddleFinger.attach(MIDDLEPIN); // Set Middle finger servo to


digital

pin 6

servoIndexFinger.attach(INDEXPIN); // Set Index finger servo to digital

pin 9

servoThumbFinger.attach(THUMBPIN); // Set Thumb finger servo to


digital

pin 10

}//end setup

void loop() {// Nothing to do here, all is done in the interrupt function

int value = analogRead(EMGPIN); //Sampling analog signal

if(value>THRESHOLD)

{closehand();}

else //Otherwise the hand is open


{openhand();}

Serial.println(value);

3D Prosthetic arm link:

https://www.thingiverse.com/thing:17773

5-) ARDUINO ULTRASONIC RADAR


PROJECT
In this project, we will make ultrasonic radar, as you know,
military radars are measured by the reflection of radio
frequencies. These radars are used in the detection of air
vehicles. our radar can scan an area of 150º.

Arduino is written in c ++. Prosessing is made in java. We share


the codes open source and you can develop on this board.

NECESSARY MATERIALS
Arduino UNO
Tower Pro Servo Motor 9g
HCSR-04 Ultrasonic Sensor
Jumper Cable
Devastation project scheme:

After installing the project, connect your arduino card with usb,
then run the processing program when you see the connection id,
and if you give the program com port error, you wrote the
wrong port. So you have to enter your own port.

The arduino codes of the project are below and you need to copy
these codes and install your arduino card.

#include <Servo.h>.
const int trigPin = 10;

const int echoPin = 11;

long duration;

int distance;

Servo myServo;

void setup() {

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

Serial.begin(9600);

myServo.attach(12); // Servo motor

void loop() {

for(int i=15;i<=165;i++){ myServo.write(i); delay(30); distance


=

calculateDistance(); Serial.print(i); Serial.print(",");

Serial.print(distance); Serial.print("."); } for(int i=165;i>15;i--){


myServo.write(i);

delay(30);

distance = calculateDistance();

Serial.print(i);

Serial.print(",");

Serial.print(distance);

Serial.print(".");

int calculateDistance(){

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);

distance= duration*0.034/2;

return distance;

Process the proce- ding codes, here line 23, set the com port
to your own, type in which port your Arduino card is
communicating with.!!!!!!!

import processing.serial.*;

import java.awt.event.KeyEvent;

import java.io.IOException;

Serial myPort;

String angle="";

String distance="";
String data="";

String noObject;

float pixsDistance;

int iAngle, iDistance;

int index1=0;

int index2=0;

PFont orcFont;

void setup() {

size (1366, 700);


smooth();

myPort = new Serial(this,"COM3", 9600); // Com port!!!!!!

myPort.bufferUntil('.');

void draw() {

fill(98,245,31);

noStroke();
fill(0,4);

rect(0, 0, width, 1010);

fill(98,245,31);

drawRadar();

drawLine();

drawObject();

drawText();

void serialEvent (Serial myPort) {

data = myPort.readStringUntil('.');

data = data.substring(0,data.length()-1);

index1 = data.indexOf(",");

angle= data.substring(0, index1);

distance= data.substring(index1+1, data.length());

iAngle = int(angle);
iDistance = int(distance);

void drawRadar() {

pushMatrix();

translate(683,700);

noFill();
strokeWeight(2);

stroke(98,245,31);

// draws the arc lines

arc(0,0,1300,1300,PI,TWO_PI);

arc(0,0,1000,1000,PI,TWO_PI);

arc(0,0,700,700,PI,TWO_PI);

arc(0,0,400,400,PI,TWO_PI);

// draws the angle lines

line(-700,0,700,0);

line(0,0,-700*cos(radians(30)),-700*sin(radians(30)));
line(0,0,-700*cos(radians(60)),-700*sin(radians(60)));

line(0,0,-700*cos(radians(90)),-700*sin(radians(90)));

line(0,0,-700*cos(radians(120)),-700*sin(radians(120)));

line(0,0,-700*cos(radians(150)),-700*sin(radians(150)));

line(-700*cos(radians(30)),0,700,0);

popMatrix();

void drawObject() {

pushMatrix();

translate(683,700);

strokeWeight(9);

stroke(255,10,10);

pixsDistance = iDistance*22.5;

if(iDistance<40){ line(pixsDistance*cos(radians(iAngle)),-

pixsDistance*sin(radians(iAngle)),700*cos(radians(iAngle)),-
700*sin(radians(iAngle))); } popMatrix(); } void drawLine() {
pushMatrix();

strokeWeight(9); stroke(30,250,60); translate(683,700);

line(0,0,700*cos(radians(iAngle)),-700*sin(radians(iAngle)));
popMatrix();

} void drawText() { pushMatrix(); if(iDistance>40) {

noObject = "Out of Range";

else {

noObject = "In Range";

fill(0,0,0);

noStroke();

rect(0, 1010, width, 1080);

fill(98,245,31);

textSize(25);

text("10cm",800,690);
text("20cm",950,690);

text("30cm",1100,690);

text("40cm",1250,690);

textSize(40);

text("Object: " + noObject, 240, 1050);

text("Angle: " + iAngle +" °", 1050, 1050);

text("Distance: ", 1380, 1050);

if(iDistance<40) {

text(" " + iDistance +" cm", 1400, 1050);

textSize(25);

fill(98,245,60);

translate(390+960*cos(radians(30)),780-960*sin(radians(30)));

rotate(-radians(-60));

text("30°",0,0);

resetMatrix();
translate(490+960*cos(radians(60)),920-960*sin(radians(60)));

rotate(-radians(-30));

text("60°",0,0);

resetMatrix();

translate(630+960*cos(radians(90)),990-960*sin(radians(90)));

rotate(radians(0));

text("90°",0,0);

resetMatrix();

translate(760+960*cos(radians(120)),1000-
960*sin(radians(120)));

rotate(radians(-38));

text("120°",0,0);

resetMatrix();

translate(840+900*cos(radians(150)),920-
960*sin(radians(150)));

rotate(radians(-60));

text("150°",0,0);
popMatrix();

6-) SERVO MOTOR CONTROL WITH ARDUINO IR


INFRARED CONTROL

Infrared Control is used for different purposes in nearly every


home, and is often
used to remotely control televisions. The controls give use, air
and convenience
to many arduino projects. If we use these projects in real life by
enlarging them,
we are seriously benefiting from technology.

The infrared rays of many sensors are used in the mz80, the
infrared sensor and
many other sensors and modules. We will use this day to find the
sensor and the

control set very suitable for internet. But if you take this from the
land, it will

work like mine. It is handy to be reasonably priced and a sensor


that many

people can congratulate if you make it into a project. Our sensors


have the
possibility to work with other controls and with our other
sensors. However,

these binary sets work very well because they are designed
exactly to each other.
The project we do is a project that does not have much on the
internet. Usually there are LEDs
and car videos for these two sets, but we will set the servos'
ratings today. If you want to
replace the if and else if sections that I write in the code, you can
write the project you want to
do. The first day I will show you two alternative codes today is
to increase the degree with 4
keys and the other way to decrease it, that is, to set the degree
with numbers.

NOTE: both codes can read both the project and the HEX
number. The HEX number is the
value that comes up when the key is pressed. Before you try,
change your HEX codes with

mine because chances of not being the same are very high.

NECESSARY MATERIALS
One infrared control and sensor;
One Arduino
One servo
Jumper cables
5v breadboard to replicate
Connections = sensor 11 servo 9;

Scheme showing the links of our Project


Deviation Codes

#include <Servo.h>
#include <IRremote.h>

int RECV_PIN = 11;

Servo servo;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()

servo.attach(9);

Serial.begin(9600);

irrecv.enableIRIn();

servo.write(0);

void loop() {

if (irrecv.decode(&results)) {

Serial.println(results.value, HEX);

irrecv.resume();

if(results.value==0xC101E57B){

servo.write(0);
}

else if(results.value==0x9716BE3F){

servo.write(10);

else if(results.value==0x3D9AE3F7){

servo.write(20);

else if(results.value==0x6182021B){

servo.write(30);

else if(results.value==0x8C22657B){

servo.write(40);

else if(results.value==0x488F3CBB){

servo.write(50);

else if(results.value==0x449E79F){

servo.write(60);
}

else if(results.value==0x32C6FDF7){

servo.write(70);

else if(results.value==0x1BC0157B){

servo.write(80);

else if(results.value==0x3EC3FC1B){

servo.write(90);

delay(10);

}
7-) DIGITAL METER CONSTRUCTION
WITH ARDUINO

What is an ultrasonic sensor? An ultrasonic sensor is a tool that


measures the distance to an
object using ultrasonic sound waves. An ultrasonic sensor uses a
transducer to send and
receive ultrasonic pulses that transmit back information about the
proximity of an object.
High frequency sound waves are reflected from the boundaries
to produce different echo
patterns.

How Ultrasonic Sensors Work Ultrasonic sound vibrates on a


frekans on the human hearing
range. Transducers are microphones used to receive and transmit
ultrasonic sound. Our
ultrasonic sensors, like the others, use a single transducer to send
a pulse and receive an echo.
The sensor identifies the distance to a target by measuring the
time interval between the
sending and receiving of the ultrasonic pulse.

NECESSARY MATERIALS
Arduino Nano
16 × 2 LCD I2C Display
Ultrasonic Sensor
9v Jack Cable
Mini Breadboard
3D Printing Parts (download)
Why Ultrasonic Sensor? Ultrasonics is reliable in any lighting
environment and can be used

inside or outside. Ultrasonic sensors can accomplish avoiding


collisions for a robot and

moving too often without being too fast. Ultrasonic applications


are widely used and can be

reliably applied in cereal warehouse detection applications, water


level sensors, drone

applications and detection tools in your local powered restaurant


or bank. Ultrasonic

telemeters are often used as devices that detect a collision.


Scheme showing the links of our Project
Deviation Codes

#include <NewPing.h>

#include <LiquidCrystal_I2C.h>

#include <Wire.h>

LiquidCrystal_I2C lcd(0x3f, 16, 2);

#define TRIGGER_PIN 13 // Trig pin

#define ECHO_PIN 12 // Echo pin


#define MAX_DISTANCE 400 //

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

void setup() {

lcd.begin();

lcd.backlight();

lcd.print("distance :");

void loop() {

delay(50);

lcd.setCursor(0,1);

lcd.print(sonar.ping_cm() );

lcd.print(" cm");

}
<pre>
8-) Arduino Shaking Tea Machine

The shaking tea machine project allows you to drip your tea in
your special cup of tea
according to the tea type you choose, and when it is over time
you will not be able to give a
little taste by lifting your tea tea from the bacon.You have to stop
in a 1.5 min cup for a nice
black tea brew.
Our project was designed not to make our life easier but to add
more color. The materials
used in the project consist of the materials found in the boxes of
many makers.

NECESSARY MATERIALS
Arduino UNO
16 × 2 LCD Display I2C
Servo-motor
buzzer
Potentiometer
Led
Button
3D Printing Parts (Tea Maker)
Scheme showing the links of our Project
Deviation Codes

#include <LiquidCrystal_I2C.h>

#include <Servo.h>

#include <Wire.h>

LiquidCrystal_I2C lcd(0x3f, 16, 2);

Servo servoMotor;

int screenLED = 6;

int servoPin = 7;

int startButton = 8;

int buzzer = 9;

int teaPot = A0;

boolean diagnosticBit = LOW;


int timer = 0;

int oldTimer = 0;

boolean inProcess = LOW;

int servoHighPosition = 120;

int servoMidPosition = 100;

int servoLowPosition = 70;

int servoSpeed = 35;

long idleTime = 0;

void setup() {

pinMode(screenLED, OUTPUT);

pinMode(servoPin, OUTPUT);

pinMode(startButton, INPUT_PULLUP);

pinMode(buzzer, OUTPUT);

Serial.begin(9600);

servoMotor.attach(servoPin);

servoMotor.write(servoHighPosition);
if (!diagnosticBit){

tone(buzzer, 1000, 200);


}

Serial.println("Sistem Tamam");

lcd.begin();

lcd.backlight();

lcd.print("Cay Makinesi");

lcd.setCursor(0, 1);

lcd.print("Proje Hocam");

fadeLightOn(screenLED);

clearScreen();

if (!diagnosticBit){

tone(buzzer, 1000, 200);

updateIdleTime();

}
void loop() {

if (idleTime < millis()){

fadeLightOff(screenLED);

idleTime = 2147483647;

if (diagnosticBit && millis()%1000 == 0){

Serial.println(idleTime);

Serial.println(millis());

Serial.println("");

if (millis() % 30 == 0){

oldTimer = timer;

timer = rawToTime(analogRead(teaPot));

if (oldTimer != timer){
lcd.setCursor(0, 0);

lcd.print(teaName(rawToTime(analogRead(teaPot))));

lcd.setCursor(3, 1);

lcd.print(timeString(0));

lcd.setCursor(8, 1);

lcd.print(timeString(timer));

delay(300);

updateIdleTime();

}
}

if (!digitalRead(startButton)){

inProcess = HIGH;

Serial.println("Start Button is pressed");

// Move servo to low position to dunk tea (0-179)

servoMotor.write(servoLowPosition);

updateIdleTime();
delay(300);

if (inProcess == HIGH){

Serial.println("inProcess is HIGH");

for (int i = 0; i < timer; i++){

lcd.setCursor(3, 1);

lcd.print(timeString(i));

delay(1000);

for (int i = servoLowPosition; i < servoHighPosition; i++){

servoMotor.write(i);

delay(servoSpeed);

}
for (int i = 0; i < 3; i ++){

servoMotor.write(servoHighPosition);

delay(200);
if (!diagnosticBit){

tone(buzzer, 1000, 100);

servoMotor.write(servoMidPosition);

delay(servoLowPosition);

servoMotor.write(servoHighPosition);

updateIdleTime();

inProcess = LOW;

9 ARDUINO DC MOTOR SPEED DIMENSION


Speed measurement of DC motors is one of the greatest
problems in the projects. In this
project we will show speed meter. Some of the motors have
problems in going straight on the
cars because of skating. We can solve this problem by measuring
the speed of the dc motor
and using the algorithm of equalizing the motors.

The sensor to be used is an infrared IR sensor. Basically the


operation logic of the sensor is
very simple. The perforated disk placed on the motor is
positioned as the sensor can see. The
basic logic does not count the hole. and finds the speed of the
engine.

NECESSARY MATERIALS
Arduino UNO
16 × 2 LCD Display
DC Motor
LM393 Speed Sensor
L298N Motor Driver
Mini Breadboard
Potentiometer
Jumper Cable

Scheme showing the links of our Project

Deviation Codes

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3f, 16, 2);


int in1 = 9;

int in2 = 5;

int ena = 6;

const int dataIN = 2;

unsigned long prevmillis;

unsigned long duration;

unsigned long lcdrefresh;

int rpm;

boolean currentstate;

boolean prevstate;

void setup()

Serial.begin(9600);

lcd.begin();

lcd.backlight();

pinMode(in1, OUTPUT);

pinMode(in2, OUTPUT);
pinMode(ena, OUTPUT);

digitalWrite(in1, HIGH);

digitalWrite(in2, LOW);

pinMode(dataIN,INPUT);

prevmillis = 0;

prevstate = LOW;

void loop()

currentstate = digitalRead(dataIN);

if( prevstate != currentstate)

if( currentstate == HIGH )

duration = ( micros() - prevmillis );

rpm = (6000000/duration);

prevmillis = micros();

}
}

prevstate = currentstate;

if( ( millis()-lcdrefresh ) >= 100 )

lcd.clear();

lcd.setCursor(0,0);

lcd.print("Motor Hizi");

lcd.setCursor(0,1);

lcd.print("RPM = ");

lcd.print(rpm);

lcdrefresh = millis();

int pot_deger = analogRead(1);

int motor_hizi = map(pot_deger, 0, 1023, 255, 0);

analogWrite(ena, motor_hizi);

}
10) REMOTE CONTROL
APPLICATION WITH ARDUINO
AND NRF24L01

Hello there. I will talk about the use of the NRF24L01 RF


module from the modules that are
frequently used in wireless communication. The module is easy
to use and its range (1km) is
very good and you can use it easily in your projects. It is also
very suitable for the price. Low
power consumption and also working at 2.4GHz frequency
provides us convenience and
usability.
Almost everybody who is interested in Arduino wants to make a
quadrocopter with a remote
controlled car, a remote controlled boat or a high range at a time.
In this article we will tell
you how to control the servoval with the potentiometer which is
far away from servo, for
friends who want to make high-range remote control projects.
So in this article we will communicate the two Arduino via the
NRF24L01 module and, as I
mentioned, we will remotely control the servos with the
potentiometer. The simple part of our
work is that if you do RC Car you will still have the same logic,
and the potentiometer will be
the joystick and the servo will be the dc motor. We'll just tell you
how to send data from one
Arduino to another. It's up to you to handle it once you get it.

There are many ways to wirelessly communicate two Arduino.


These could be GPS or GSM
modules, which are really far away, but at a slightly higher price,
X-bee modules, which are
more expensive. However, I think that in this project quality,
money and usage have emerged
in the current time and in a short time I will use the wireless
module named NRF24L01 which
is many projects and shopping on internet.
NRF24L01 2.4GHz Transceiver Module
The module is available in different (external and pcb) and also
with (external) antenna. The
range of the PCB is 250 m and the range of the external model is
1000 m.
You can use the module as a receiver and transmitter.
I used an external antenna radio frequency module with a range
of 1000 m in the project.
If you like, you can also choose the version of pcb with 250 m
range.
NECESSARY MATERIALS
2 PCS NRF24L01
JUMPER CABLE
2 PIECE CAPACITORS (V + PIN IN EACH TWO WED
(UNITED) 3V3E)
2 PCS ARDUINO UNO
1 pc SERVO
1 POTENTIOMETER

Scheme showing the links of our Project

TRANSMITTER RECEIVER
CIRCUIT
nRF24L01 Arduino Uno
VCC 3.3 V
GND GND
CS 7
CE 8
MOSI 11
MISO 12
SCK 13
pot=A0 servo=9
Deviation Codes

Potentiometer code (Transmitter Code)

#include <SPI.h>

#include "RF24.h"

int msg[1];

//SCK -> 13//MISO -> 12//MOSI -> 11//CSN -> 7//CE -> 8

RF24 radio(8,7);

const uint64_t pipe = 0xE8E8F0F0E1LL;

int potpin = 0;

int val;

void setup(void){

radio.begin();

radio.openWritingPipe(pipe);
}

void loop(void){

val = analogRead(potpin);

val = map(val, 0, 1023, 0, 179);

msg[0] = val;
radio.write(msg, 1);

Servo code (Receiver Code)

#include <Servo.h>

#include <SPI.h>

#include "RF24.h"

Servo myservo;

//SCK -> 13//MISO -> 12//MOSI -> 11//CSN -> 7//CE -> 8

RF24 radio(8,7);

const uint64_t pipe = 0xE8E8F0F0E1LL;

int msg[1];

void setup()

myservo.attach(9);

radio.begin();

radio.openReadingPipe(1,pipe);

radio.startListening();

}
void loop()

if (radio.available()){

bool done = false;

while (!done){

done = radio.read(msg, 1);

myservo.write (msg[0]);

11) 3D ROBOT PROJECT WITH BOB LOCATED


WITH ARDUINO
3D printer-based robots have been used in recent years. Many of
these cute robots named
BOB have long ago received a robot that I saw and wanted to
share. This robot has been
removed with almost all parts of the 3D printer and only motors
and electronic circuits are
left.
NECESSARY MATERIALS
Arduino Nano
Ultrasonic Sensor HC-SR04
Servo motor 4 (from blue small servos)
Battery
On / off switch
Bolts
You can download STL files for 3D printing of the project here.
https://www.thingiverse.com/thing:43708
(Printing at 30% coverage is recommended)

Once you have supplied the plastic parts of the robot, we go


through the installation. First you have to install the collars.
Once you have installed the Servo, prepare the head electronics
assembly and make the connections as follows.

Scheme showing the links of our Project


Deviation Codes
#include "PowerLEDController.h"
#include "types.h"
#include <Servo.h>
#include <NewPing.h>
#include <Serial.h>
#include <String.h>

#define TRIGGER_PIN 2
#define ECHO_PIN 3
#define LED_PIN 4
#define MAX_DISTANCE 200
//#define IRPin 8

// 4 servos
Servo leftFootServo;
Servo leftHipServo;
Servo rightFootServo;
Servo rightHipServo;

const int offset = 20; //how many degrees we want to move the servos

// Servo positions
// Left foot servo
const int leftFootC = 92; // centered
const int leftFootD = leftFootC+offset; // foot down
const int leftFootU = leftFootC-offset-6; // foot up

// Left hip servo


const int leftHipC = 107; // centered
const int leftHipL = leftHipC+offset; // hip left
const int leftHipR = leftHipC-offset; // hip right

// Right foot servo


const int rightFootC = 98;
const int rightFootD = rightFootC-offset;
const int rightFootU = rightFootC+offset;

// Right hip servo


const int rightHipC = 82;
const int rightHipL = rightHipC-offset;
const int rightHipR = rightHipC+offset+8;

// Servo positions we want the servo to move to (in small steps)


float leftFootPos;
float leftHipPos;
float rightFootPos;
float rightHipPos;

// Servo postions written to the servos


float leftFootPosInt = leftFootC;
float leftHipPosInt = leftHipC;
float rightFootPosInt = rightFootC;
float rightHipPosInt = rightHipC;

// Calculated values for moving servos in small steps (position we want to


move to - current servo position / steps)
float leftFootStep;
float leftHipStep;
float rightFootStep;
float rightHipStep;

const int steps = 20; // divide every servo move in 20 steps


byte speed = 30; // time between steps
unsigned long SuperTurboTimer;
byte SuperTurboStep = 1;
unsigned long SuperTurboMillis;
unsigned long timer;
byte direction = 1;
byte legInStep = 1;

byte isTurning = 0;
Turning turning;
unsigned long turningStarted;
unsigned long turningDuration;

byte isMovingBackwards = 0;
int movingBackwardsDuration = 10000;
unsigned long movingBackwardsStarted;

unsigned int previousDist;


unsigned long startWander;
unsigned long nextWander;

unsigned long startCurrentState;


unsigned long currentStateDuration;

State state;

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

char* directions[]={"", "Forward", "Backward", "Left", "Right"};

LED led(LED_PIN);
PowerLEDController powerLEDController(LED_PIN);

void setup()
{
//Serial.begin(9600);
randomSeed(analogRead(0));

leftHipServo.attach(9);
rightHipServo.attach(10);
leftFootServo.attach(11);
rightFootServo.attach(12);

leftHipServo.write(leftHipC);
rightHipServo.write(rightHipC);
leftFootServo.write(leftFootC);
rightFootServo.write(rightFootC);

turning.Avoiding = 3000;
turning.Wandering = 1250;

led.on();
delay(250);
led.off();
delay(250);
led.on();
delay(250);
led.off();
delay(250);
led.on();
delay(250);
led.off();

wakeUp();
}

void loop()
{
switch(state)
{
case Walking:
updateDirection();
powerLEDController.update();
break;
case Sleeping:
if (millis() - startCurrentState > 2000)
{
delay(10000);
}
break;
}

updateCurrentState();
led.update();
walk();
}

void updateCurrentState()
{
if (millis() > startCurrentState + currentStateDuration)
{
startCurrentState = millis();
switch(state)
{
case Walking:
sleep();
break;
case Sleeping:
wakeUp();
break;
}

led.flash();
}

void updateDirection()
{
unsigned int dist;

updateWandering();

switch(direction)
{
case 1: // forward
dist = moveForward();
updateWandering();
break;
case 2: // backward
led.flash();
moveBackwards();
break;
case 3: // left
case 4: // right
led.flash();
makeTurn();
break;
}

previousDist = dist;
}

unsigned int moveForward()


{
unsigned int dist = readDistance();

if (dist < 7 && previousDist < 7)


{
nextWander = movingBackwardsDuration + getNextWander();
direction = 2;
}
else if (dist < 15 && previousDist < 15)
{
nextWander = turning.Avoiding + getNextWander();
makeRandomTurn(turning.Avoiding);
}

return dist;
}

void makeRandomTurn(unsigned int duration)


{
turningDuration = duration;
if (nextWander % 2) // oneven...
{
direction = 3;
}
else // even..
{
direction = 4;
}
}

void makeTurn()
{
if (isTurning)
{
if (millis() - turningStarted > turningDuration)
{
isTurning = false;
direction = 1;
previousDist = 9999;
}
}
else
{
isTurning = true;
turningStarted = millis();
}
}

void moveBackwards()
{
if (isMovingBackwards)
{
if(millis() - movingBackwardsStarted > movingBackwardsDuration)
{
isMovingBackwards = false;
if(random(2) == 0)
{
direction = 4;
}
else
{
direction = 3;
}
}
}
else
{
isMovingBackwards = true;
movingBackwardsStarted = millis();
}
}

void walk()
{
SuperTurboMillis = millis();

if (SuperTurboMillis >= timer){


timer = timer+speed;

legInStep = legInStep + 1;
if (legInStep == steps + 1){
legInStep = 1;
}
if (legInStep == 1)
{
leftFootStep = (leftFootPos - leftFootPosInt) / steps;
leftHipStep = (leftHipPos - leftHipPosInt) / steps;
rightFootStep = (rightFootPos - rightFootPosInt) / steps;
rightHipStep = (rightHipPos - rightHipPosInt) / steps;
}

leftFootPosInt = leftFootPosInt + leftFootStep;


leftHipPosInt = leftHipPosInt + leftHipStep;
rightFootPosInt = rightFootPosInt + rightFootStep;
rightHipPosInt = rightHipPosInt + rightHipStep;
}

if (SuperTurboMillis >= SuperTurboTimer){


SuperTurboTimer = SuperTurboTimer+(steps*speed);
SuperTurboStep = SuperTurboStep +1;
if (SuperTurboStep == 7){
SuperTurboStep = 1;
}
}

if (direction == 0) // stop, both feet on the ground


{
leftFootPos = leftFootC;
leftHipPos = leftHipC;
rightFootPos = rightFootC;
rightHipPos = rightHipC;
}

if (direction == 1) // forward walking gait


{
if (SuperTurboStep == 1)
{
leftFootPos = leftFootU;
rightFootPos = rightFootD;
}
if (SuperTurboStep == 2)
{
leftHipPos = leftHipL;
rightHipPos = rightHipR;
}
if (SuperTurboStep == 3)
{
leftFootPos = leftFootC;
rightFootPos = rightFootC;
}
if (SuperTurboStep == 4)
{
leftFootPos = leftFootD;
rightFootPos = rightFootU;
}

if (SuperTurboStep == 5)
{
leftHipPos = leftHipR;
rightHipPos = rightHipL;
}
if (SuperTurboStep == 6)
{
leftFootPos = leftFootC;
rightFootPos = rightFootC;
}
}

if (direction == 2) // backward walking gait


{
if (SuperTurboStep == 1)
{
leftFootPos = leftFootU;
rightFootPos = rightFootD;
}

if (SuperTurboStep == 2)
{
leftHipPos = leftHipR;
rightHipPos = rightHipL;
}

if (SuperTurboStep == 3)
{
leftFootPos = leftFootC;
rightFootPos = rightFootC;
}

if (SuperTurboStep == 4)
{
leftFootPos = leftFootD;
rightFootPos = rightFootU;
}

if (SuperTurboStep == 5)
{
leftHipPos = leftHipL;
rightHipPos = rightHipR;
}

if (SuperTurboStep == 6)
{
leftFootPos = leftFootC;
rightFootPos = rightFootC;

}
}
if (direction == 3) // left walking gait
{
if (SuperTurboStep == 1)
{
leftFootPos = leftFootU;
rightFootPos = rightFootD;
}
if (SuperTurboStep == 2)
{
leftHipPos = leftHipL;
rightHipPos = rightHipL;
}
if (SuperTurboStep == 3)
{
leftFootPos = leftFootC;
rightFootPos = rightFootC;
}
if (SuperTurboStep == 4)
{
leftFootPos = leftFootD;
rightFootPos = rightFootU;
}

if (SuperTurboStep == 5)
{
leftHipPos = leftHipR;
rightHipPos = rightHipR;
}
if (SuperTurboStep == 6)
{
leftFootPos = leftFootC;
rightFootPos = rightFootC;
}
}
if (direction == 4) // right walking gait
{
if (SuperTurboStep == 1)
{
leftFootPos = leftFootU;
rightFootPos = rightFootD;
}
if (SuperTurboStep == 2)
{
leftHipPos = leftHipR;
rightHipPos = rightHipR;
}
if (SuperTurboStep == 3)
{
leftFootPos = leftFootC;
rightFootPos = rightFootC;
}
if (SuperTurboStep == 4)
{
leftFootPos = leftFootD;
rightFootPos = rightFootU;
}

if (SuperTurboStep == 5)
{
leftHipPos = leftHipL;
rightHipPos = rightHipL;
}
if (SuperTurboStep == 6)
{
leftFootPos = leftFootC;
rightFootPos = rightFootC;
}
}
leftFootServo.write(leftFootPosInt);
leftHipServo.write(leftHipPosInt);
rightFootServo.write(rightFootPosInt);
rightHipServo.write(rightHipPosInt);
}

int readDistance()
{
int uS = sonar.ping();
int uScm = uS / US_ROUNDTRIP_CM;
if (uScm == 0)
{
uScm = 9999;
}

return uScm;
}

unsigned long getNextWander()


{
return random(15000, 30000) * ((30 / (float)speed));
}

void updateWandering()
{
if (millis() > startWander + nextWander)
{
makeRandomTurn(turning.Wandering);
startWander = millis();
nextWander = getNextWander();
led.flash();
}
}
void sleep()
{
state = Sleeping;
direction = 0;
currentStateDuration = random(60000, 5 * 60000);
}

void wakeUp()
{
startWander = millis();
nextWander = getNextWander();
state = Walking;
currentStateDuration = random(40000, 120000);
speed = random(20, 40);
timer = millis();
direction = 1;
led.flash();

}
12) ARDUİNO FUZZY LOGIC TEMPERATURE
MOISTURE PROJECT

Fuzzy logic is a control mechanism that is widely used in the


new generation control mechanisms.

Blur is the process of converting input variables and output


variables into linguistic expressions. Therefore, the first input
and output variables to be determined, as input variables for the
air conditioning system; the ambient temperature is selected as
the target temperature and as the output variables; Air
conditioning output is selected. Afterwards, the degree of
membership is determined by giving linguistic expressions to the
input and output variables.
NECESSARY MATERIALS
Arduino UNO
DHT11 Temperature Humidity
L293D Motor Driver
RGB Led
16 × 2 LCD Display
2 pcs computer fan
Working Logic of the Project

Ambient temperature and target (reference) temperatures are our


fuzzy logic inputs. The output of the air conditioner is our fuzzy
logic output. We create membership function by converting the
environment and target temperature into linguistic expressions.
We created them with 5 membership functions. These are very
cold, cold, comfortable, warm, very hot and in the same way we
express our output with 5 membership functions. These are Very
Low, Low, Normal, High, Very High Since we have 2 attempts
and 5 membership functions in one and 5 in the other, we must
have 5 * 5 = 25 rules

Scheme showing the links of our Project


Deviation Codes

#include "DHT.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3f, 16, 2);
#define DHTPIN 2
#define DHTTYPE DHT11
const int fansogut=9;
const int enablesogut=3;
const int fanisit=10;
const int enableisit=5;
int fanhiz;
int fanhiz2;
int mavi=13;
int kirmizi=12;
DHT dht(DHTPIN, DHTTYPE);

void setup() {
Serial.begin(9600);
Serial.println("Bulanik Mantik");
pinMode(fansogut,OUTPUT);
pinMode(enablesogut, OUTPUT);
pinMode(fanisit,OUTPUT);
pinMode(enableisit, OUTPUT);
pinMode(mavi, OUTPUT);
pinMode(kirmizi, OUTPUT);
dht.begin();
lcd.begin();
lcd.backlight();

void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();

if (isnan(t) || isnan(h))
{
Serial.println("DHT Hatası");
}
else
{

float Kapali[3] = {0};


float OrtaHalli[3] = {0};
float AzHizli[5] = {0};
float TamHizli[4] = {0};

float CokSoguk = 0;
float Soguk = 0;
float Konforlu = 0;
float Sicak = 0;
float CokSicak = 0;

float CokDusuk = 0;
float Dusuk = 0;
float Normal = 0;
float Yuksek = 0;
float CokYuksek = 0;

float Kapali_max = 0;
float Yavas_max = 0;
float OrtaHalli_max = 0;
float AzHizli_max = 0;
float TamHizli_max = 0;

CokSoguk = ucgen(t, 10, 13, 17);


Soguk = ucgen(t, 13, 17, 24);
Konforlu = ucgen(t, 17, 24, 29);
Sicak = ucgen(t, 24, 29, 31);
CokSicak = ucgen(t, 29, 31, 32);

// Nem Üyelik Fonksiyonu


CokDusuk = ucgen(h, 10, 25, 40);
Dusuk = ucgen(h, 25, 40, 55);
Normal = ucgen(h, 40, 55, 70);
Yuksek = ucgen(h, 55, 70, 85);
CokYuksek = ucgen(h, 70, 85, 100);

lcd.setCursor(0,0);
lcd.print("S:");
lcd.print(t);

lcd.setCursor(9,0);
lcd.print("N:");
lcd.print(h);

if ( t <= 24) {
AzHizli[0] = AND(CokDusuk, CokSoguk);
OrtaHalli[0] = AND(CokDusuk, Soguk);
Kapali[0] = AND(CokDusuk, Konforlu);

AzHizli[1] = AND(Dusuk, CokSoguk);


AzHizli[2] = AND(Dusuk, Soguk);
Kapali[1] = AND(Dusuk, Konforlu);

TamHizli[0] = AND(Normal, CokSoguk);


AzHizli[3] = AND(Normal, Soguk);
Kapali[2] = AND(Normal, Konforlu);

TamHizli[1] = AND(Yuksek, CokSoguk);


AzHizli[4] = AND(Yuksek, Soguk);
OrtaHalli[1] = AND(Yuksek, Konforlu);

TamHizli[2] = AND(CokYuksek, CokSoguk);


TamHizli[3] = AND(CokYuksek, Soguk);
OrtaHalli[2] = AND(CokYuksek, Konforlu);

Kapali_max = DiziMax(Kapali, 3);


OrtaHalli_max = DiziMax(OrtaHalli, 3);
AzHizli_max = DiziMax(AzHizli, 5);
TamHizli_max = DiziMax(TamHizli, 4);
float cikis = (Kapali_max*0 + OrtaHalli_max*40 + AzHizli_max*70 +
TamHizli_max*100);
cikis /= (Kapali_max+ OrtaHalli_max+ AzHizli_max+ TamHizli_max);

lcd.setCursor(0,1);
lcd.print("IsitF:");
lcd.print(cikis);
fanhiz = ((cikis/100)*255);
analogWrite(enableisit,fanhiz);
digitalWrite(fanisit,HIGH);
digitalWrite(kirmizi,HIGH);
digitalWrite(mavi,LOW);
}

else {

AzHizli[0] = AND(CokDusuk, CokSicak);


OrtaHalli[0] = AND(CokDusuk, Sicak);
Kapali[0] = AND(CokDusuk, Konforlu);

AzHizli[1] = AND(Dusuk, CokSicak);


AzHizli[2] = AND(Dusuk, Sicak);
Kapali[1] = AND(Dusuk, Konforlu);

TamHizli[0] = AND(Normal, CokSicak);


AzHizli[3] = AND(Normal, Sicak);
Kapali[2] = AND(Normal, Konforlu);
TamHizli[1] = AND(Yuksek, CokSicak);
AzHizli[4] = AND(Yuksek, Sicak);
OrtaHalli[1] = AND(Yuksek, Konforlu);

TamHizli[2] = AND(CokYuksek, CokSicak);


TamHizli[3] = AND(CokYuksek, Sicak);
OrtaHalli[2] = AND(CokYuksek, Konforlu);

Kapali_max = DiziMax(Kapali, 3);


OrtaHalli_max = DiziMax(OrtaHalli, 3);
AzHizli_max = DiziMax(AzHizli, 5);
TamHizli_max = DiziMax(TamHizli, 4);

float cikis2 = (Kapali_max*0 + OrtaHalli_max*40 + AzHizli_max*70


+ TamHizli_max*100);
cikis2 /= (Kapali_max+ OrtaHalli_max+ AzHizli_max+
TamHizli_max);

lcd.setCursor(0,1);
lcd.print("SogutF:");
lcd.print(cikis2);
fanhiz2 = ((cikis2/100)*255);
analogWrite(enablesogut,fanhiz2);
digitalWrite(fansogut,HIGH);
digitalWrite(kirmizi,LOW);
digitalWrite(mavi,HIGH);
}

delay(1000);
}

float DiziMax(float a[], int b) {


float max = a[0];
for (int i = 1; i < b; i++) { if (a[i] > max)
max = a[i];
}
return max;
}

float AND(float a, float b) {


if (a < b) {
return a;
} else {
return b;
}

float ucgen(float x,float a, float b, float c){


float f;
if(x<=a)
f=0;
else if((a<=x)&&(x<=b))
f=(x-a)/(b-a);
else if((b<=x)&&(x<=c))
f=(c-x)/(c-b);
else if(c<=x)
f=0;
return f;
}

13) DRAWING ROBOT CAR

This robot, which writes various shapes on paper, follows the


systems we call xy plotters. This robot is a little different from
these systems. It can act as a car on its wheels.

Pro Trinket - 3V 12MHz card is used in the project is difficult to


find this card in the market. You can use arduino uno instead.
NECESSARY MATERIALS
Adafruit Pro Trinket - 3V 12MHz
5V geared stepper motor (2 pcs)
ULN2803 stepper driver
breadboard
Micro Servo

Motor and wheel connections of the robot are done as shown in


the pictures and then fixed on the wheel with the bolt to the
motor.
Scheme showing the links of our Project
Deviation Codes
#include <Servo.h>

// setup servo
int servoPin = 8;
int PEN_DOWN = 170; // angle of servo when pen is down
int PEN_UP = 80; // angle of servo when pen is up
Servo penServo;

int wheel_dia=66.25; // # mm (increase = spiral out)


int wheel_base=112; //, # mm (increase = spiral in)
int steps_rev=128; //, # 512 for 64x gearbox, 128 for 16x gearbox
int delay_time=6; // # time between steps in ms

// Stepper sequence org->pink->blue->yel


int L_stepper_pins[] = {10, 12, 13, 11};
int R_stepper_pins[] = {3, 5, 6, 4};

int fwd_mask[][4] = {{1, 0, 1, 0},


{0, 1, 1, 0},
{0, 1, 0, 1},
{1, 0, 0, 1}};

int rev_mask[][4] = {{1, 0, 0, 1},


{0, 1, 0, 1},
{0, 1, 1, 0},
{1, 0, 1, 0}};
void setup() {
randomSeed(analogRead(1));
// put your setup code here, to run once:
Serial.begin(9600);
for(int pin=0; pin<4; pin++){
pinMode(L_stepper_pins[pin], OUTPUT);
digitalWrite(L_stepper_pins[pin], LOW);
pinMode(R_stepper_pins[pin], OUTPUT);
digitalWrite(R_stepper_pins[pin], LOW);
}
penServo.attach(servoPin);
Serial.println("setup");
}
void loop(){ // draw a calibration box 4 times
pendown();
for(int x=0; x<12; x++){
forward(100);
left(90);
}
penup();
done(); // releases stepper motor
while(1); // wait for reset
}
// ----- HELPER FUNCTIONS -----------
int step(float distance){
int steps = distance * steps_rev / (wheel_dia * 3.1412); //24.61
/*
Serial.print(distance);
Serial.print(" ");
Serial.print(steps_rev);
Serial.print(" ");
Serial.print(wheel_dia);
Serial.print(" ");
Serial.println(steps);
delay(1000);*/
return steps;
}
void forward(float distance){
int steps = step(distance);
Serial.println(steps);
for(int step=0; step<steps; step++){
for(int mask=0; mask<4; mask++){
for(int pin=0; pin<4; pin++){
digitalWrite(L_stepper_pins[pin], rev_mask[mask][pin]);
digitalWrite(R_stepper_pins[pin], fwd_mask[mask][pin]);
}
delay(delay_time);
}
}
}
void backward(float distance){
int steps = step(distance);
for(int step=0; step<steps; step++){
for(int mask=0; mask<4; mask++){
for(int pin=0; pin<4; pin++){
digitalWrite(L_stepper_pins[pin], fwd_mask[mask][pin]);
digitalWrite(R_stepper_pins[pin], rev_mask[mask][pin]);
}
delay(delay_time);
}
}
}
void right(float degrees){
float rotation = degrees / 360.0;
float distance = wheel_base * 3.1412 * rotation;
int steps = step(distance);
for(int step=0; step<steps; step++){
for(int mask=0; mask<4; mask++){
for(int pin=0; pin<4; pin++){
digitalWrite(R_stepper_pins[pin], rev_mask[mask][pin]);
digitalWrite(L_stepper_pins[pin], rev_mask[mask][pin]);
}
delay(delay_time);
}
}
}
void left(float degrees){
float rotation = degrees / 360.0;
float distance = wheel_base * 3.1412 * rotation;
int steps = step(distance);
for(int step=0; step<steps; step++){
for(int mask=0; mask<4; mask++){
for(int pin=0; pin<4; pin++){
digitalWrite(R_stepper_pins[pin], fwd_mask[mask][pin]);
digitalWrite(L_stepper_pins[pin], fwd_mask[mask][pin]);
}
delay(delay_time);
}
}
}
void done(){ // unlock stepper to save battery
for(int mask=0; mask<4; mask++){
for(int pin=0; pin<4; pin++){
digitalWrite(R_stepper_pins[pin], LOW);
digitalWrite(L_stepper_pins[pin], LOW);
}
delay(delay_time);
}
}
void penup(){
delay(250);
Serial.println("PEN_UP()");
penServo.write(PEN_UP);
delay(250);
}
void pendown(){
delay(250);
Serial.println("PEN_DOWN()");
penServo.write(PEN_DOWN);
delay(250);
}
14) HOVERBOARD CONSTRUCTION WITH
ARDUİNO

This robot is very hard to stand on the level and balance. This is
why the developed PID algorithm was used in coding. In this
type of robot, the motor is normally used with encoder, but we
didn't choose this motors because they are expensive. materials
from a hardware store

As the control card, the Arduino UNO, the L298N model for the
motor drive was preferred. This model responds to the signals
very well. It is also on the market and cheap.
NECESSARY MATERIALS
Arduino UNO
MPU6050 Accelerometer Gyro
L298N Motor driver board
4 Pcs M3 Gijon (Stud) + 24 M3 Nuts
2 Pcs Dagu motor + wheel set
Lipo battery
First try to create a similar frame by looking at the pictures
below. Try to place the motors in the equilibrium center.
Cut three plastic layers of 20 × 8 cm in size. Then cut the gijon
into 20 cm lengths. Insert the gins by drilling through the corners
of the plastic sheets and adjust your robot to 3 bold.

After you have prepared the mechanical part of the project, you
need to add the electronic part. When inserting the cards, such as
the arduino, motor drive, place it again, paying attention to the
center of gravity.
Scheme showing the links of our Project
Then attach the 3 potentiometers to the gijons with silicone and
connect them to the inputs A0, A1 and A2 in the potentiometer
arduino. KP, KD and KI values change when we play with
settings.

The last of our robot.


Deviation Codes

#include <PID_v1.h>
#include <LMotorController.h>
#include "I2Cdev.h"

#include "MPU6050_6Axis_MotionApps20.h"

#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE


#include "Wire.h"
#endif

#define LOG_INPUT 0
#define MANUAL_TUNING 0
#define LOG_PID_CONSTANTS 0
#define MOVE_BACK_FORTH 0

#define MIN_ABS_SPEED 30

//MPU

MPU6050 mpu;
// MPU control/status vars
bool dmpReady = false; // set true if DMP init was successful
uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU
uint8_t devStatus; // return status after each device operation (0 =
success, !0 = error)
uint16_t packetSize; // expected DMP packet size (default is 42 bytes)
uint16_t fifoCount; // count of all bytes currently in FIFO
uint8_t fifoBuffer[64]; // FIFO storage buffer

// orientation/motion vars
Quaternion q; // [w, x, y, z] quaternion container
VectorFloat gravity; // [x, y, z] gravity vector
float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and
gravity vector

//PID

#if MANUAL_TUNING
double kp , ki, kd;
double prevKp, prevKi, prevKd;
#endif
double originalSetpoint = 174.29;
double setpoint = originalSetpoint;
double movingAngleOffset = 0.3;
double input, output;
int moveState=0; //0 = denge ; 1 = geri ; 2 = ileri

#if MANUAL_TUNING
PID pid(&input, &output, &setpoint, 0, 0, 0, DIRECT);
#else
PID pid(&input, &output, &setpoint, 70, 240, 1.9, DIRECT);
#endif
//MOTOR SURUCU

int ENA = 3;
int IN1 = 4;
int IN2 = 8;
int IN3 = 5;
int IN4 = 7;
int ENB = 6;

LMotorController motorController(ENA, IN1, IN2, ENB, IN3, IN4, 0.6,


1);

long time1Hz = 0;
long time5Hz = 0;

volatile bool mpuInterrupt = false; // indicates whether MPU interrupt


pin has gone high
void dmpDataReady()
{
mpuInterrupt = true;
}

void setup()
{
// join I2C bus (I2Cdev library doesn't do this automatically)
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
Wire.begin();
TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz)
#elif I2CDEV_IMPLEMENTATION ==
I2CDEV_BUILTIN_FASTWIRE
Fastwire::setup(400, true);
#endif

// initialize serial communication


// (115200 chosen because it is required for Teapot Demo output, but it's
// really up to you depending on your project)
Serial.begin(115200);
while (!Serial); // wait for Leonardo enumeration, others continue
immediately

// initialize device
Serial.println(F("I2C Kuruluyor..."));
mpu.initialize();

// verify connection
Serial.println(F("Suruculer test ediliyor..."));
Serial.println(mpu.testConnection() ? F("MPU6050 baglanti basarili") :
F("MPU6050 baglanti basarisiz"));

// load and configure the DMP


Serial.println(F("DMP kuruluyor..."));
devStatus = mpu.dmpInitialize();

// supply your own gyro offsets here, scaled for min sensitivity
mpu.setXGyroOffset(220);
mpu.setYGyroOffset(76);
mpu.setZGyroOffset(-85);
mpu.setZAccelOffset(1788); // 1688 factory default for my test chip
// make sure it worked (returns 0 if so)
if (devStatus == 0)
{
// turn on the DMP, now that it's ready
Serial.println(F("Enabling DMP..."));
mpu.setDMPEnabled(true);

// enable Arduino interrupt detection


Serial.println(F("Enabling interrupt detection (Arduino external
interrupt 0)..."));
attachInterrupt(0, dmpDataReady, RISING);
mpuIntStatus = mpu.getIntStatus();

// set our DMP Ready flag so the main loop() function knows it's okay
to use it
Serial.println(F("DMP ready! Waiting for first interrupt..."));
dmpReady = true;

// get expected DMP packet size for later comparison


packetSize = mpu.dmpGetFIFOPacketSize();

//setup PID

pid.SetMode(AUTOMATIC);
pid.SetSampleTime(10);
pid.SetOutputLimits(-255, 255);
}
else
{
// ERROR!
// 1 = initial memory load failed
// 2 = DMP configuration updates failed
// (if it's going to break, usually the code will be 1)
Serial.print(F("DMP Initialization failed (code "));
Serial.print(devStatus);
Serial.println(F(")"));
}
}

void loop()
{
// if programming failed, don't try to do anything
if (!dmpReady) return;

// wait for MPU interrupt or extra packet(s) available


while (!mpuInterrupt && fifoCount < packetSize) { //no mpu data -
performing PID calculations and output to motors pid.Compute();
motorController.move(output, MIN_ABS_SPEED); unsigned long
currentMillis = millis(); if (currentMillis - time1Hz >= 1000)
{
loopAt1Hz();
time1Hz = currentMillis;
}

if (currentMillis - time5Hz >= 5000)


{
loopAt5Hz();
time5Hz = currentMillis;
}
}

// reset interrupt flag and get INT_STATUS byte


mpuInterrupt = false;
mpuIntStatus = mpu.getIntStatus();

// get current FIFO count


fifoCount = mpu.getFIFOCount();

// check for overflow (this should never happen unless our code is too
inefficient)
if ((mpuIntStatus & 0x10) || fifoCount == 1024)
{
// reset so we can continue cleanly
mpu.resetFIFO();
Serial.println(F("FIFO overflow!"));

// otherwise, check for DMP data ready interrupt (this should happen
frequently)
}
else if (mpuIntStatus & 0x02)
{
// wait for correct available data length, should be a VERY short wait
while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount(); //
read a packet from FIFO mpu.getFIFOBytes(fifoBuffer, packetSize); //
track FIFO count here in case there is > 1 packet available
// (this lets us immediately read more without waiting for an
interrupt)
fifoCount -= packetSize;

mpu.dmpGetQuaternion(&q, fifoBuffer);
mpu.dmpGetGravity(&gravity, &q);
mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
#if LOG_INPUT
Serial.print("ypr\t");
Serial.print(ypr[0] * 180/M_PI);
Serial.print("\t");
Serial.print(ypr[1] * 180/M_PI);
Serial.print("\t");
Serial.println(ypr[2] * 180/M_PI);
#endif
input = ypr[1] * 180/M_PI + 180;
}
}

void loopAt1Hz()
{
#if MANUAL_TUNING
setPIDTuningValues();
#endif
}

void loopAt5Hz()
{
#if MOVE_BACK_FORTH
moveBackForth();
#endif
}

//move back and forth

void moveBackForth()
{
moveState++;
if (moveState > 2) moveState = 0;

if (moveState == 0)
setpoint = originalSetpoint;
else if (moveState == 1)
setpoint = originalSetpoint - movingAngleOffset;
else
setpoint = originalSetpoint + movingAngleOffset;
}

//PID Tuning (3 potentiometers)


#if MANUAL_TUNING
void setPIDTuningValues()
{
readPIDTuningValues();

if (kp != prevKp || ki != prevKi || kd != prevKd)


{
#if LOG_PID_CONSTANTS
Serial.print(kp);Serial.print(", ");Serial.print(ki);Serial.print(",
");Serial.println(kd);
#endif

pid.SetTunings(kp, ki, kd);


prevKp = kp; prevKi = ki; prevKd = kd;
}
}

void readPIDTuningValues()
{
int potKp = analogRead(A0);
int potKi = analogRead(A1);
int potKd = analogRead(A2);

kp = map(potKp, 0, 1023, 0, 25000) / 100.0; //0 - 250


ki = map(potKi, 0, 1023, 0, 100000) / 100.0; //0 - 1000
kd = map(potKd, 0, 1023, 0, 500) / 100.0; //0 - 5
}
#endif

15) ROBOT ARM WITH ARDUİNO LASER


CUTTING
Robot arm construction is one of the basic projects to be learned,
because of the logic of operation, it is the most widely used robot
in the industry, so it will be of benefit to those who want to
improve themselves on such projects. In this project, we will see
the construction of a simple but very functional robot which is
formed by combining the robot parts prepared with laser cutting.
First of all, you have to cut the plastic parts of your robot in one
to one dimensions, because it is very detailed, it is impossible for
you to do this manually. So you need to cut parts with laser
cutting, or if you have 3b printer, you can print from your
printer.
But I advise you that laser cutting is a better choice in terms of
both speed and speed, because in our project there are only flat
plate layers. So there are parts you can take out on a plate.
When you print out the project laser cut, you will see a lot of
large and small pieces. You can understand how to assemble by
following the pictures below.
As you can see in the pictures, try to do the assembly, not every
stage can be certain. This is impossible anyway. But the
connection places are already certain you can easily resolve
yourself.
NECESSARY MATERIALS
Arduino UNO
4X SERVO
JOİSTİC
battery

Scheme showing the links of our Project


Deviation Codes

Servo myservo0, myservo1, myservo2, myservo3 ;

int potpin0 = A0;


int potpin1 = A1;
int potpin2 = A2;
int potpin3 = A3;
int val0;
int val1;
int val2;
int val3;
int ledpin = 3;
void setup()
{
Serial.begin(9600);
myservo0.attach(11);
myservo1.attach(10);
myservo2.attach(9);
myservo3.attach(5);
pinMode(ledpin,OUTPUT);
}

void loop()
{
digitalWrite(ledpin,HIGH);
val0 = analogRead(potpin0);
val0 = map(val0, 0, 1023, 0, 179);
myservo0.write(val0);
Serial.println(val0);
delay(15);
val1 = analogRead(potpin1);
val1 = map(val1, 0, 1023, 0, 179);
myservo1.write(val1);
Serial.println(val1);
delay(15);
val2 = analogRead(potpin2);
val2 = map(val2, 0, 1023, 0, 179);
myservo2.write(val2);
Serial.println(val2);
delay(15);
val3 = analogRead(potpin3);
val3 = map(val3, 0, 1023, 0, 179);
myservo3.write(val3);
Serial.println(val3);
delay(15);
}

16) BOMB DISPOSAL ROBOT PROJECT WITH


ARDUiNO

Bomb Disposal Robot is the most common type of robot used by


the police, it is vital to place a detonator in the bombs left in the
package, so the robots have excellent accuracy. The robot we are
going to do is certainly not as sensitive as a real bomb-
destruction robot, but at least you'll understand the principle of
operation. It can be a model robot or you can use it to test
different advanced features.

Our robot is carried out on a tracked kit, the reason for choosing
a crawler kit is that it can be easily moved in difficult terrain. The
robot arm mounted on it is a two-axis and simple piece. It only
moves down and up and left and the third servo runs the holder.
NECESSARY MATERIALS
Arduino Uno
Servo motor 3
Battery
Scheme showing the links of our Project

Motor connections of crawler robot

Engine - Forward - Right = 8. pin


Engine - Forward - Left = 9. pin
Engine - Back - Right = 10th pin
Engine - Back - Left = 11th pin
Servo motor connections
Servo 1> pin 5
Servo 2> pin 6
Servo 3> pin 7
Deviation Codes

#include <SoftwareSerial.h>
#include <Servo.h>
SoftwareSerial BT(52, 53); //set TX and RX on bluetooth to pin 52 and 53
respectively
Servo servo1;
Servo servo2;
Servo servo3;
char command;

int motorPin = 8; //right side to IB - forward


int motorPin2 = 9; //left side to IA - forward
int motorPin3 = 10; //right side to IA - backward
int motorPin4 = 11; //left side to IB - backward

int pos1 = 90;


int pos2 = 90;
int pos3 = 90;

void setup() {
BT.begin (9600);
Serial.begin (9600);
pinMode(motorPin, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);

servo1.attach(5);
servo1.write(pos1);
servo2.attach(6);
servo2.write(pos2);
servo3.attach(7);
servo3.write(pos3);

void stop() {

digitalWrite(motorPin, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);

void forward(){
digitalWrite(motorPin, HIGH);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);

void backward() {

digitalWrite(motorPin, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, HIGH);

void turnLeft() {

digitalWrite(motorPin, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);

void turnRight() {

digitalWrite(motorPin, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);

}
void open() {

for(pos3 = 110; pos3 > 40; pos3 -= 1)


{servo3.write(pos3);

void close() {

for(pos3 = 40; pos3 < 110; pos3 += 1) {servo3.write(pos3); } } void


antiClockwise() { for(pos2 = 90; pos2 > 0; pos2 -= 1)
{servo2.write(pos2);

void clockwise() {

for(pos2 = 0; pos2 < 90; pos2 += 1)


{servo2.write(pos2);

void up () {

for(pos1 = 50; pos1 < 180; pos1 +=1) {servo1.write(pos1); } } void


down() { for(pos1 = 180; pos1 > 50; pos1 -= 1)
{servo1.write(pos1);
}

void loop() {

if (BT.available() > 0) {
command = BT.read();
switch (command) {
case 'w':
forward();
break;

case 'x':
backward();
break;

case 'a':
turnLeft();
break;

case 'd':
turnRight();
break;

case 's':
stop();
break;

case 'y':
open();
break;
case 'u':
close();
break;

case 'h':
antiClockwise();
break;

case 'j':
clockwise();
break;

case 'n':
up();
break;

case 'm':
down();
break;
}
}
}

17) ARDUİNO SPIDER ROBOT CONSTRUCTION


Making a spider robot with a 3D printer is now very simple, we
had previously made insect robot electrical cables and wires. This
project will be much easier because you don't need to do much
more manually. Your 3b printer will handle the whole job. You
can start to do the project after you have output the srt file that
we shared. Using different colors when printing will make you
look more pleasant. So please choose custom colors.

The project is completely done with 3n printer. These days, there


are no such maker devices in everyone's house. So you can get
printouts from places that provide this service cheaply.

NECESSARY MATERIALS
(x1) Output of SRT files (3D Printer)
(x1) Arduino Nano
(x2) Servo motor
(x1) 40-pin socket
(x4) Pencils
Print out the project from the printer. The printing time varies
according to the performance of your printer. I'm guessing you
can print in an average of 10 hours.
Scheme showing the links of our Project
Deviation Codes
#include <Servo.h>

Servo myservo;
Servo myservo1;

int FrontBalanced = 75;


int BackCentered = 100;

//Balans ayarları
int backRight = BackCentered - 20;
int backLeft = BackCentered + 20;

void setup()
{
myservo.attach(8);
myservo1.attach(9);
myservo1.write(FrontBalanced);
myservo.write(BackCentered);
delay(2000);
}

void loop()
{

//Düz yürü
goStraight();
for(int walk = 10 ; walk >= 0; walk -=1) {
walkOn();
}

//Sağa dön
goRight();
for(int walk = 10 ; walk >= 0; walk -=1) {
walkOn();
}

//Düz yürü
goStraight();
for(int walk = 10 ; walk >= 0; walk -=1) {
walkOn();
}

//Sola dön
goLeft();
for(int walk = 10 ; walk >= 0; walk -=1) {
walkOn();
}

//Yürüme fonksiyonu
void walkOn(){
myservo.write(BackCentered + 30);
delay(1000);
myservo.write(BackCentered - 30);
delay(1000);
}

//Sola dönüş fonksiyonu


void goLeft(){
BackCentered = backLeft;
myservo1.write(FrontBalanced + 40);
}

//Sağa dönüş fonksiyonu


void goRight(){
BackCentered = backRight;
myservo1.write(FrontBalanced - 40);
}

//İleri gitme fonksiyonu


void goStraight(){
BackCentered = 100;
myservo1.write(FrontBalanced);
}
18) HUMAN ROBOT CONSTRUCTION WITH ARDUiNO

When we speak of a walking servo robot, we have robots that


are prepared by spending serious money. The robot we are going
to do is stepping on like a human. You need to adjust the balance
center very well when doing this project. Otherwise your robot
will not be stable.

The cheapest servo motors are used in the project. Therefore,


you should not load too much weight. You will need to use
lightweight materials as much as possible.
NECESSARY MATERIALS
1- Arduino UNO
2- Breadboard
3- Servo Motor x4 (TowerPro 9g)
4- Jumper Cables
5- Play dough
The pictures of our project are available below. Try to simulate
looking at the pictures below. First, attach the servo motors
together. Must be like the same pictures. Then tighten the two leg
servos together with silicone. You're going to have to fix them
by 90 degrees.
After fixing the valves, we need to place our electronics on the
servos. Make sure that the

robot is in equilibrium with the entire robot. Otherwise it will tip


when it starts to step.
Scheme showing the links of our Project

Deviation Codes

#include <Servo.h>
Servo rightfoot;
Servo righthigh;
Servo leftfoot;
Servo leftthigh;
int pos;
void setup()
{
rightfoot.attach(3);
righthigh.attach(5);
leftfoot.attach(9);
leftthigh.attach(6);
}

void loop()
{ int pos=120;
rightfoot.write(90);
righthigh.write(90);
leftfoot.write(90);
leftthigh.write(90);delay(500);
leftfoot.write(55);delay(400);
for(int i=90;i<=115;i++)
{rightfoot.write(i);delay(12);}

leftfoot.write(120);delay(100);
leftthigh.write(120);delay(100);
delay(500);
for(int i=90;i<=120;i++)
{righthigh.write(i);delay(12);
leftthigh.write(i);delay(12);}

leftfoot.write(90);delay(300);
for(int i=115;i>=90;i--)
{rightfoot.write(i);delay(12);}

delay(500);

rightfoot.write(120);delay(300);
leftfoot.write(65);
righthigh.write(60);
for(pos=120;pos>=60;pos--)
{leftthigh.write(pos);delay(7);}
rightfoot.write(60);

delay(500);
rightfoot.write(90);delay(300);
leftfoot.write(90);delay(300);
leftthigh.write(60);delay(300);

righthigh.write(60);delay(300);
delay(500);
}

19) ARDUINO OLLIE ROBOT CONSTRUCTION

Many similar types of robots such as Ollie have started to be sold


on the market. These robots are usually sold as high-tech toys for
entertainment purposes. It will be in all children when the prices
are cheaper. Developed by the company Sphero, these toys, both
in terms of quality and technology, loved itself. The only
problems are that the prices are currently sold at the high price in
the market
Since my readers are people who have a spirit of maker, I also
share this project successfully with you for my valuable readers
upon request from my readers.
NECESSARY MATERIALS
1- Arduino Attiny85
2- Servo motor 9g x2
3- 3D printer output
https://www.thingiverse.com/thing:477508
4- Ultrasonic sensor
5- Slim lipo battery or phone battery
Scheme showing the links of our Project
Deviation Codes

#include "Servo8bit.h"
#define trigPin 0
#define echoPin 3

int ir_pin = 4;
int motorPinL = 1;
int motorPinR = 2;
int key;
int start_bit = 2000;
int bin_1 = 1000;
int bin_0 = 400;
unsigned long stoptimer;
boolean autoMode;
Servo8Bit motorL, motorR;

void setup() {

pinMode(ir_pin, INPUT);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
motorL.attach(motorPinL);
motorR.attach(motorPinR);
//Serial.begin(9600);
digitalWrite(0, HIGH);
}

void loop() {
key = getIRKey();
if (key != -1) {
//Serial.println(key);
if (key < 755 && key > 750){moveMotors(160, 160);} //up
if (key < 2805 && key > 2795){moveMotors(10, 10);} //down
if (key < 725 && key > 715){moveMotors(10, 160);} //left
if (key < 3285 && key > 3275){moveMotors(160, 10);} //right
if (key < 2677 && key > 2667){
autoMode = !autoMode;
moveMotors(94, 85);
delay(400);
}
if (key < 2710 && key > 2695){
motorL.detach();
motorR.detach();
}
}
stoptimer = millis();
}

void moveMotors(int speedL, int speedR){


motorL.write(speedL);
motorR.write(180-speedR);
}

int getIRKey() {
int data[12];
while(pulseIn(ir_pin, LOW, 20000) < 2200) {
if(stoptimer+20 < millis() && !autoMode) moveMotors(94, 85);
if(autoMode){
if(getDistance() < 10){
moveMotors(94, 20);
delay(400);
}
else{
moveMotors(120, 120);
}
}
key = 0;
}
stoptimer = millis()+1000;
data[0] = pulseIn(ir_pin, LOW);
data[1] = pulseIn(ir_pin, LOW);
data[2] = pulseIn(ir_pin, LOW);
data[3] = pulseIn(ir_pin, LOW);
data[4] = pulseIn(ir_pin, LOW);
data[5] = pulseIn(ir_pin, LOW);
data[6] = pulseIn(ir_pin, LOW);
data[7] = pulseIn(ir_pin, LOW);
data[8] = pulseIn(ir_pin, LOW);
data[9] = pulseIn(ir_pin, LOW);
data[10] = pulseIn(ir_pin, LOW);
data[11] = pulseIn(ir_pin, LOW);

for(int i=0;i<=11;i++) {

if(data[i] > bin_1) {


data[i] = 1;
} else {
if(data[i] > bin_0) {
data[i] = 0;
} else {
data[i] = 2;
}
}
}

for(int i=0;i<=11;i++) {
if(data[i] > 1) {
return -1;
}
}

int result = 0;
int seed = 1;
for(int i=11;i>=0;i--) {
if(data[i] == 1) {
result += seed;
}
seed = seed * 2;
}

return result;
}

int getDistance(){
long duration;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
return (duration/2) / 29.1;
}

20) ROBOT MAKING FAST LINE WITH ARDUİNO


This line, which is separated from the other examples in terms of
design and weight, can be considered as unrivaled in its own
class. But this line is a step ahead of your competitors with the
following robot. You can also save space because you can
prepare the control card yourself.

In our project, the tb752a1 card was used as a motor drive. Also
with atmega328 processor speed will add speed. A 3.7volt lipo is
used as a power supply in the robot, both small and lightweight.
But I have used the DC-DC converter to amplify the voltage
because the 3.7 volts voltage is insufficient for the robot
NECESSARY MATERIALS
1- Baby Orangutan B-328
2- Pololu 10: 1 Geared Motor x2
3-QTR-8A line tracing sensor
4- Pololu 32 × 7 mm wheel
5- 3/8 ″ drunk wheel
6- 2.5-9.5V converter
7- 3.7 volt lipo battery

Circuit elements: C1 and C2 = 22uF capacitor, R1 R2 and R4 =


470 Ohms resistor, R10 R7 and R8 = 330 Ohms resistor, R3 R5
and R6 = 15K resistor, Robot's source codes are programmed
with C substructure. You can download from the link at the end.
The average weight of the robot is around 108 gr. This gives you
an extra advantage.

Scheme showing the links of our Project


Deviation Codes

#define F_CPU 20000000UL // Baby Orangutan frequency (20MHz)


#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>

//Leds. Salidas.
#define LEDR PORTB1
#define LEDV PORTB2

//Interruptores. Entradas.
#define PULSADOR PORTB0
//Sensores. Entradas y salidas.
#define D3 PORTD7
#define D2 PORTC5
#define D1 PORTC4
#define D0 PORTC3
#define I0 PORTC2
#define I1 PORTC1
#define I2 PORTC0
#define I3 PORTD4
#define LED_ON PORTD2

void inicializar_puertos(void);
void reset(void);
void M1_forward(unsigned char pwm);
void M1_reverse(unsigned char pwm);
void M2_forward(unsigned char pwm);
void M2_reverse(unsigned char pwm);
void motors_init(void);
int obtener_errorp(void);
void inicializar_timer1(void);
int obtener_errord(void);

/*********** Ajuste comportamiento robot *********/


//Constantes Regulador PD.
int Kp = 50; //
int Kd = 2500; //
volatile int velocidad = 160;
/*************************************************/

int main( void )


{

char pulsador = 1;
inicializar_puertos();
motors_init();
reset();

while(pulsador != 0 )
{
pulsador = PINB & (1<<PULSADOR);
}

_delay_ms(500);

inicializar_timer1();

PORTD |= (1<<LED_ON); //Encendemos Sensores.

M1_forward(0); //Motor derecho.


M2_forward(0); //Motor izquierdo.

while ( 1 )
{
}
return 0;
}

void inicializar_puertos(void)
{
DDRD=0x6C; //0110 1100
PORTD=0x00;
DDRB=0x26; //0010 0110
PORTB=0x00;
DDRC=0x00; //0000 0000
PORTC=0x00;
}

void reset(void)
{

PORTB &= ~(1<<LEDV);


PORTB &= ~(1<<LEDR);
_delay_ms(300);

PORTB |= (1<<LEDV);
PORTB |= (1<<LEDR);
_delay_ms(300);

PORTB &= ~(1<<LEDV);


PORTB &= ~(1<<LEDR);
_delay_ms(300);

PORTB |= (1<<LEDV);
PORTB |= (1<<LEDR);
_delay_ms(300);

PORTB &= ~(1<<LEDV);


PORTB &= ~(1<<LEDR);
_delay_ms(300);

PORTB |= (1<<LEDV);
PORTB |= (1<<LEDR);
}

//Funciones para controlar la velocidad y dirección de los


//motores. PWM controla la velocidad, valor entre 0-255.
void M1_reverse(unsigned char pwm)
{
OCR0A = 0;
OCR0B = pwm;
}
void M1_forward(unsigned char pwm)
{
OCR0B = 0;
OCR0A = pwm;
}
void M2_forward(unsigned char pwm)
{
OCR2A = pwm;
OCR2B = 0;
}
void M2_reverse(unsigned char pwm)
{
OCR2B = pwm;
OCR2A = 0;
}

//Configuración del hardware del micro que controla los motores.


void motors_init(void)
{
// configure for inverted PWM output on motor control pins:
// set OCxx on compare match, clear on timer overflow
// Timer0 and Timer2 count up from 0 to 255
TCCR0A = TCCR2A = 0xF3;
// use the system clock/8 (=2.5 MHz) as the timer clock
TCCR0B = TCCR2B = 0x02;
// initialize all PWMs to 0% duty cycle (braking)
OCR0A = OCR0B = OCR2A = OCR2B = 0;
// set PWM pins as digital outputs (the PWM signals will not
// appear on the lines if they are digital inputs)
DDRD |= (1 << PORTD3) | (1 << PORTD5) | (1 << PORTD6);
DDRB |= (1 << PORTB3);
}

void inicializar_timer1(void) //Configura el timer y la interrupción.


{
OCR1A= 0x0138; // 1 ms. 0C35 10ms, 0x0271 2ms.
TCCR1B |=((1<<WGM12)|(1<<CS11)|(1<<CS10)); //Los bits que no
se tocan a 0 por defecto
TIMSK1 |= (1<<OCIE1A);
sei();
}

int obtener_errorp(void)
{
char errorp=0;
static char ultimo_errorp=0;
char contador_sensor=0;

if(((PINC & 0x04) != 0) && ((PINC & 0x08) != 0))


{
errorp=0;
return(0);
}

if((PIND & 0x10) != 0) //I3 PD4 -7


{
errorp = errorp - 0x07;
contador_sensor++;
}

if((PINC & 0x01) != 0) //I2 PC0 -5


{
errorp = errorp - 0x05;
contador_sensor++;
}

if((PINC & 0x02) != 0) //I1 PC1 -3


{
errorp = errorp - 0x03;
contador_sensor++;
}

if((PINC & 0x04) != 0) //I0 PC2 -1


{
errorp = errorp - 0x01;
contador_sensor++;
}

if((PINC & 0x08) != 0) //D0 PC3 +1


{
errorp = errorp + 0x01;
contador_sensor++;
}

if((PINC & 0x10) != 0) //D1 PC4 +3


{
errorp = errorp + 0x03;
contador_sensor++;
}

if((PINC & 0x20) != 0) //D2 PC5 +5


{
errorp = errorp + 0x05;
contador_sensor++;
}

if((PIND & 0x80) != 0) //D3 PD7 +7


{
errorp = errorp + 0x07;
contador_sensor++;
}

if(contador_sensor != 0)
{
errorp = errorp / contador_sensor;
ultimo_errorp = errorp;
return(Kp * (int)errorp);
}
else
{
if(ultimo_errorp < 0)
errorp = -0x09;
else
errorp = 0x09;

ultimo_errorp = errorp;
return((int)errorp * Kp);
}
}

int obtener_errord(void)
{
int error = 0;
static int error_old = 0;
static int errord=0;
static int errord_old = 0;
static int tic = 1; // 1
static int tic_old = 1; //

int diferencia = 0;
if(((PINC & 0x04) != 0) && ((PINC & 0x08) != 0))
error=0;

else if((PINC & 0x08) != 0) //D0 PC3 +1


error = 1;

else if((PINC & 0x04) != 0) //I0 PC2 -1


error = -1;

else if((PINC & 0x10) != 0) //D1 PC4 +3


error = 3;

else if((PINC & 0x02) != 0) //I1 PC1 -3


error = -3;

else if((PINC & 0x20) != 0) //D2 PC5 +5


error = 5;

else if((PINC & 0x01) != 0) //I2 PC0 -5


error = -5;

else if((PIND & 0x80) != 0) //D3 PD7 +7


error = 7;

else if((PIND & 0x10) != 0) //I3 PD4 -7


error = -7;

else
{
if (error_old < 0) error = -9; else if(error_old > 0)
error = 9;
}

//Cálculo de la velocidad media del error.


if (error == error_old)
{
tic = tic + 1;
if(tic > 30000)
tic = 30000;
if(tic > tic_old)
errord = errord_old/tic;
// if(tic > tic_old)
// errord = (errord_old*tic_old)/tic;

}
else
{
tic++;
diferencia = error - error_old;
errord = Kd*(diferencia)/tic; //error medio
errord_old = errord;
tic_old=tic;
tic=0;
}

error_old = error;
return(errord);
}

ISR(TIMER1_COMPA_vect)
{
int errort=0;
int proporcional = obtener_errorp();
int derivativo = obtener_errord();

errort = proporcional + derivativo;


if(errort > velocidad)
errort = velocidad;
else if(errort < - velocidad) errort = - velocidad; if(errort>0)
{
M1_forward(velocidad - errort); //Motor derecho.
M2_forward(velocidad); //Motor izquierdo.
PORTB |= (1<<LEDV);
PORTB &= ~(1<<LEDR);
}
else if(errort<0)
{
M1_forward(velocidad); //Motor derecho.
M2_forward(velocidad + errort); //Motor izquierdo.
PORTB |= (1<<LEDR);
PORTB &= ~(1<<LEDV);
}

else
{
M2_forward(velocidad);
M1_forward(velocidad);
PORTB &= ~(1<<LEDR);
PORTB &= ~ (1<<LEDV);
}

TIFR1 |= (1<<OCF1A);
}

21) ROBOT PRODUCTION TREATED WITH ARDUiNO


Lately Arduino was an electronic card used too much, almost
every electronic project you can do with this card now will make
a simple robot. Our robot is using a sequential shield kit with this
kit thanks to our robot will not hit the wall. Thanks to the
advanced obstacle detection algorithm, it can move in the
direction of the wall.
Arduino
1- Arduino Uno
2- Arduino Prototype Shield
3- HC-SR04 sensor
4- Large Servo Motor (2 pieces)
5- Micro servo motor
6- L293D motor drive
7- 9V Battery and 6V battery
8- Plastic materials and wheels

Firstly, we cut the body of our robot as shown in the pictures


below and we perform the necessary assemblies. Do our project
by taking into account the size of the pictures, otherwise the code
you install with your robot will be a conflict and will not work
healthy.
After cutting the body and assembling the necessary assembly,
the order comes to the arduino assembly. Place the motor drive
connector on the Arduino as shown in the following illustrations
and insert the jumper cables and pins with the pins on the
arduino.
Scheme showing the links of our Project
Deviation Codes

#include <Servo.h>
#include <NewPing.h>

#define LeftMotorForward 9
#define LeftMotorBackward 10
#define RightMotorForward 11
#define RightMotorBackward 12
#define USTrigger 6
#define USEcho 7
#define MaxDistance 100
#define LED 13

Servo servo;
NewPing sonar(USTrigger, USEcho, MaxDistance);

unsigned int duration;


unsigned int distance;
unsigned int FrontDistance;
unsigned int LeftDistance;
unsigned int RightDistance;
unsigned int Time;

void setup()
{pinMode(LeftMotorForward, OUTPUT);
pinMode(LeftMotorBackward, OUTPUT);
pinMode(RightMotorForward, OUTPUT);
pinMode(RightMotorBackward, OUTPUT);
pinMode(LED, OUTPUT);
servo.attach(4);
}

void loop()
{
delay(500);
servo.write(90);
scan();
FrontDistance = distance;
if(FrontDistance > 40 || FrontDistance == 0)
{
moveForward();
}
else
{
moveStop();
servo.write(167);
delay(500);
scan();
LeftDistance = distance;
servo.write(0);
delay(500);
scan();
RightDistance = distance;
if(RightDistance < LeftDistance)
{
moveLeft();
delay(500);
}
else if(LeftDistance < RightDistance)
{
moveRight();
delay(500);
}
else
{
moveBackward();
delay(200);
moveRight();
delay(200);
}
}
}

void moveForward()
{
digitalWrite(LeftMotorBackward, LOW);
digitalWrite(LeftMotorForward, HIGH);
digitalWrite(RightMotorBackward, LOW);
digitalWrite(RightMotorForward, HIGH);
}

void moveBackward()
{
digitalWrite(LeftMotorForward, LOW);
digitalWrite(LeftMotorBackward, HIGH);
digitalWrite(RightMotorForward, LOW);
digitalWrite(RightMotorBackward, HIGH);
}

void moveLeft()
{
digitalWrite(LeftMotorForward, LOW);
digitalWrite(LeftMotorBackward, HIGH);
digitalWrite(RightMotorBackward, LOW);
digitalWrite(RightMotorForward, HIGH);

void moveRight()
{
digitalWrite(LeftMotorBackward, LOW);
digitalWrite(LeftMotorForward, HIGH);
digitalWrite(RightMotorForward, LOW);
digitalWrite(RightMotorBackward, HIGH);
}

void moveStop()
{
digitalWrite(LeftMotorBackward, LOW);
digitalWrite(LeftMotorForward, LOW);
digitalWrite(RightMotorForward, LOW);
digitalWrite(RightMotorBackward, LOW);
}
void scan()
{
delay(50);
Time = sonar.ping();
distance = Time / US_ROUNDTRIP_CM;
}

22) ROBOT CONSTRUCTION PROJECT WITH


ARDUİNO

Working principle of the line following robot:

It follows the line in two different ways.

To follow the white line on a black background


Follow the black line on a white background

Arduino
Arduino Uno
QTR-8RC Infrared Sensor
L293D Motor Driver Board
Robot Kit

There are 8 transceivers on Qtr8rc. We have followed the line


using 5 sensors in Arduino line
following robot project. You can use the 5 sensors you want in
the Arduino connection. But
the 5 sensors must also be in succession, otherwise your sensors
will be out of line because
the empty sensors will not follow the line. Sensors in the
software analog 1 to 5 pin is defined.
The point you need to pay attention to here is that your
connection from the A5 to the same is
the same from left to right. Only connect the motor pins and
check that they are straight.
Scheme showing the links of our Project
Deviation Codes

#include <AFMotor.h>
#include <QTRSensors.h>

AF_DCMotor motor1(1, MOTOR12_8KHZ );


AF_DCMotor motor2(2, MOTOR12_8KHZ );

#define KP .2
#define KD 5
#define M1_minumum_hiz 120
#define M2_minumum_hiz 120
#define M1_maksimum_hiz 210
#define M2_maksimum_hiz 210
#define MIDDLE_SENSOR 3
#define NUM_SENSORS 5
#define TIMEOUT 2500
#define EMITTER_PIN 2
#define DEBUG 0

QTRSensorsRC qtrrc((unsigned char[]) { 19,18,17,16,15}


,NUM_SENSORS, TIMEOUT, EMITTER_PIN);

unsigned int sensorValues[NUM_SENSORS];

void setup()
{
delay(1500);
manual_calibration();
set_motors(0,0);
}

int lastError = 0;
int last_proportional = 0;
int integral = 0;

void loop()
{
unsigned int sensors[5];
int position = qtrrc.readLine(sensors);
int error = position - 2000;

int motorSpeed = KP * error + KD * (error - lastError);


lastError = error;

int leftMotorSpeed = M1_minumum_hiz + motorSpeed;


int rightMotorSpeed = M2_minumum_hiz - motorSpeed;
// set motor speeds using the two motor speed variables above
set_motors(leftMotorSpeed, rightMotorSpeed);
}

void set_motors(int motor1speed, int motor2speed)


{
if (motor1speed > M1_maksimum_hiz ) motor1speed =
M1_maksimum_hiz; //MAKSİMUM MOTOR 1 HIZ LİMİTİ
if (motor2speed > M2_maksimum_hiz ) motor2speed =
M2_maksimum_hiz; // MAKSİMUM MOTOR 2 HIZ LİMİTİ
if (motor1speed < 0) motor1speed = 0; // MİNIMUMMOTOER 1 HIZ
LİMİTİ
if (motor2speed < 0) motor2speed = 0; // MİNİMUM MOTOR 2 HIZ
LİMİTİ
motor1.setSpeed(motor1speed); //1.MOTOR HIZI
motor2.setSpeed(motor2speed);// 2.MOTOR HIZI
motor1.run(FORWARD); //İLERİ
motor2.run(FORWARD); //İLERİ
}

void manual_calibration() {

int i;
for (i = 0; i < 250; i++)
{
qtrrc.calibrate(QTR_EMITTERS_ON);
delay(20);
}

if (DEBUG) {
Serial.begin(9600);
for (int i = 0; i < NUM_SENSORS; i++)
{
Serial.print(qtrrc.calibratedMinimumOn[i]);
Serial.print(' ');
}
Serial.println();

for (int i = 0; i < NUM_SENSORS; i++)


{
Serial.print(qtrrc.calibratedMaximumOn[i]);
Serial.print(' ');
}
Serial.println();
Serial.println();
}
}
23) TANK PRODUCTION WITH ARDUiNO

In this project, we will talk about how the tank robot is made.
With Arduino you can do many projects in a simple way. Due to
the fact that it is an open source library, arduino has been used
too much. This project includes a tracked tank made with
Arduino Nano.

NECESSARY MATERIALS

1- Tiny crawler robot kit


2- Arduino Nano
3- 40 pin bottom socket
We need to modify the servo motors used in the robot kit. As
you know, the servo motor is designed for full rotation. Then
you make connections as shown in the pictures. The 40-pin dip
socket is connected to the tracked robot that you're connecting to
the Arduino Nano on the bottom of the bottom connector you're
connected to. After you install the program in the Arduino Nano,
you can enjoy your robot.
Scheme showing the links of our Project
Deviation Codes

#include <Servo.h>

Servo leftDrive;
Servo rightDrive;

int pos = 0;

void setup()
{
leftDrive.attach(11);
rightDrive.attach(10);
}

void loop()
{

//example routine, drives in a square


turnRight();
driveForward();
turnRight();
driveForward();
turnRight();
driveForward();
turnRight();
driveForward();

}
void turnRight()
{
leftDrive.write(0);
rightDrive.write(180);
delay(450);
}

//turns left about 90 degrees


void turnLeft()
{
leftDrive.write(180);
rightDrive.write(0);
delay(450);
}

//drives straight for 1 second


void driveForward()
{
leftDrive.write(180);
rightDrive.write(180);
delay(1000);
}

void driveBackward()
{
leftDrive.write(0);
rightDrive.write(0);
delay(1000);

}
24) SUMO ROBOT PROJECT WITH ARDUiNO

In this article, we will program and run the sumo robot chassis
we created with 3D printing in arduino. This robot, which is
prepared with the most basic and cheapest materials, will be able
to make your own in your home easily.NECESSARY
MATERIALS
Arduino Uno
L298N motor drive
Sumo robot chassis
MZ80 distance sensor
100 rpm micro motor (2 pcs)
Micro motor compatible wheel
7.4v lipo battery
First, solder the jumper cable to the motors. Then place the
motors with hot silicone into the chassis as shown in the picture.
Make sure the engines are level. After the silicones have dried,
mount the MZ80 distance sensor in the front slot, using the
screw on the end of the sensor and insert it into the slot.
Finally, screw a flat plate onto the chassis or attach it to the
silicone. You will place the arduino and motor drive on the plate.
Scheme showing the links of our Project
Deviation Codes

int ileri =5;


int geri =6;
int sag = 7;
int sol =8;
int inputPin = 2;
int val = 0;

void setup()
{
Serial.begin(9600);
pinMode(ileri,OUTPUT);
pinMode(geri,OUTPUT);
pinMode(sag,OUTPUT);
pinMode(sol,OUTPUT);
pinMode(inputPin, INPUT);

void loop(){

val = digitalRead(inputPin);
Serial.println(val);
if (val == 1) {
digitalWrite(ileri, HIGH);
digitalWrite(sag, HIGH);
digitalWrite(geri, LOW);
digitalWrite(sol, LOW);
}

else if (val == 0) {
digitalWrite(geri, HIGH);
digitalWrite(sol, HIGH);
digitalWrite(ileri, LOW);
digitalWrite(sag, LOW);
}
}

25) ROBOT CONTROL PROJECT WITH ARDUiNO


TELEVISION CONTROL
In this project, how to control a robot with TV control, what we
need in the project, we will talk about them. First of all, how can
we use a car or motor with a controller? Let's examine what we
need for it.

NECESSARY MATERIALS
1 pcs arduino uno
1 pcs l298n motor driver
1 IR sensor
1 control
2 pcs robot and battery for arduino
1 pcs robot kit or toy car

Scheme showing the links of our Project


Deviation Codes

#include <IRremote.h>
int RECV_PIN = 11;
int sagileri = 2;
int saggeri = 3;
int solileri = 4;
int solgeri = 5;

int itsONled[] = {0,0,0,0,0};

#define code1 2131

#define code2 2132

#define code3 2134

#define code4 2133

#define code5 2165

&nbsp;

&nbsp;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(sagileri, OUTPUT);
pinMode(saggeri, OUTPUT);
pinMode(solileri, OUTPUT);
pinMode(solgeri, OUTPUT);
}

void loop() {
if (irrecv.decode(&results)) {
unsigned int value = results.value;
switch(value) {
case code1:
if(itsONled[1] == 1) {
digitalWrite(sagileri, LOW);
digitalWrite(solileri, LOW);
digitalWrite(saggeri, LOW);
digitalWrite(solgeri, LOW);
itsONled[1] = 0;
} else {
digitalWrite(sagileri, HIGH);
digitalWrite(solileri, HIGH);
digitalWrite(saggeri, LOW);
digitalWrite(solgeri, LOW);
itsONled[1] = 1;
}
break;
case code2:
if(itsONled[2] == 1) {
digitalWrite(sagileri, LOW);
digitalWrite(solileri, LOW);
digitalWrite(saggeri, LOW);
digitalWrite(solgeri, LOW);
itsONled[2] = 0;
} else {
digitalWrite(sagileri, LOW);
digitalWrite(solileri, LOW);
digitalWrite(saggeri, HIGH);
digitalWrite(solgeri, HIGH);
itsONled[2] = 1;
}
break;
case code3:
if(itsONled[3] == 1) {
digitalWrite(sagileri, LOW);
digitalWrite(solileri, LOW);
digitalWrite(saggeri, LOW);
digitalWrite(solgeri, LOW);
itsONled[3] = 0;
} else {
digitalWrite(sagileri, LOW);
digitalWrite(solileri, HIGH);
digitalWrite(saggeri, HIGH);
digitalWrite(solgeri, LOW);
itsONled[3] = 1;
}
break;
case code4:
if(itsONled[4] == 1) {
digitalWrite(sagileri, LOW);
digitalWrite(solileri, LOW);
digitalWrite(saggeri, LOW);
digitalWrite(solgeri, LOW);
itsONled[4] = 0;
} else {
digitalWrite(sagileri,HIGH);
digitalWrite(solileri, LOW);
digitalWrite(saggeri, LOW);
digitalWrite(solgeri, HIGH);
itsONled[4] = 1;
}
break;
case code5:
if(itsONled[5] == 1) {
digitalWrite(sagileri, LOW);
digitalWrite(solileri, LOW);
digitalWrite(saggeri, LOW);
digitalWrite(solgeri, LOW);
itsONled[5] = 0;
} else {
digitalWrite(sagileri,HIGH);
digitalWrite(solileri, HIGH);
digitalWrite(saggeri, HIGH);
digitalWrite(solgeri, HIGH);
itsONled[4] = 1;
}
break;

}
Serial.println(value);
irrecv.resume();
}
}
26) ARDUiNO ANDROID CONTROLLED RC CAR
PROJECT
You can easily perform many operations with your Android
phones. At the end of this project you will have an android
controlled rc car. You can make yourself a car by following the
steps below. The purpose of the project is to control your car via
bluetooth as you wish, thanks to the program you install on your
mobile phone.

NECESSARY MATERIALS
1- Arduino UNO
2-L293B Motor Driver
3- HC-06 Bluetooth Module
4- RC Toy Car

Scheme showing the links of our Project


Deviation Codes

char dataIn = 'S';


int pinileri = 3;
int pingeri = 5;
int pinsol = 6;
int pinsag = 9;
char determinant;
char det;

void setup()
{
Serial.begin(9600);
pinMode(pinileri, OUTPUT);
pinMode(pingeri, OUTPUT);
pinMode(pinsol, OUTPUT);
pinMode(pinsag, OUTPUT);
}

void loop()
{
det = check();
while (det == 'F')
{
digitalWrite(pinileri, HIGH);
det = check();
}
while (det == 'B')

{
digitalWrite(pingeri, HIGH);
det = check();
}

while (det == 'L')

{
digitalWrite(pinsol, HIGH);
det = check();
}
while (det == 'R')

{
digitalWrite(pinsag, HIGH);
det = check();
}
while (det == 'G')

{
digitalWrite(pinileri, HIGH);
digitalWrite(pinsol, HIGH);
det = check();
}
while (det == 'I')

{
digitalWrite(pinileri, HIGH);
digitalWrite(pinsag, HIGH);
det = check();
}
while (det == 'H')

{
digitalWrite(pingeri, HIGH);
digitalWrite(pinsol, HIGH);
det = check();
}
while (det == 'J')

{
digitalWrite(pingeri, HIGH);
digitalWrite(pinsag, HIGH);
det = check();
}
while (det == 'S')

{
digitalWrite(pinileri, LOW);
digitalWrite(pingeri, LOW);
digitalWrite(pinsol, LOW);
digitalWrite(pinsag, LOW);
det = check();
}

}
int check()
{
if (Serial.available() > 0)
{
dataIn = Serial.read();
if (dataIn == 'F')
{
determinant = 'F';
}
else if (dataIn == 'B')
{
determinant = 'B';
}
else if (dataIn == 'L')
{
determinant = 'L';
}
else if (dataIn == 'R')
{
determinant = 'R';
}
else if (dataIn == 'G')
{
determinant = 'G';
}
else if (dataIn == 'I')
{
determinant = 'I';
}
else if (dataIn == 'H')
{
determinant = 'H';
}
else if (dataIn == 'J')
{
determinant = 'J';
}
else if (dataIn == 'S')
{
determinant = 'S';
}

}
return determinant;
}

You might also like