12. Output devices

  • This week I started working on the final project.

Group Assignment Page

Important note :

for this assignment I have used Arduino first , then I used my own pcd which I designed week 7 “Electronic design”

This week I started working on the final project

Group Assignment Page

Move the servo or “servo motor” actuator either rotating or linear allowing precise control of both position whether angular or linear, speed and acceleration. The servo consists of a suitable motor coupled with a sensor to review upcoming signals regarding the position. The device requires relatively advanced control, often a dedicated unit designed for use with the same servo model.

Servo motors are not considered a specific class of motors, although the term is used in the event that a high-precision motor is required to perform a task in a closed circuit control system such as robotics, computer numerical control machines, automated manufacturing machines, packing lines, lines Packaging, loading and carrying lines.

project (1) SERVO ARM

  • SERVO ARM

  • This week, I wanted to do an educational workshop for the children, and I made a simple robot that the children would assemble and thereby program it and make several dance movements. At the same time, I worked on the Final Project, which I tested the servo motors with the robot that I used for children and I controlled it via the Arduino Nano, but the arm was controlled by the circuit that I manufactured in the final project page.

Servo Arm Design

This week, I designed the arm for the servo motor that I can control with my circus medium

schematic

Simple servo arm code

// Variables
#include <Servo.h>
 //#include <SoftwareSerial.h>
//SoftwareSerial mySerial(0, 1); // RX, TX

// Variables
int b1, b2, b3, b4 = 0;

// Moving Time Interval
unsigned long time_space_reading  = 0;
unsigned long time_space_motor    = 0;

#define   B1              A0
#define   B1_MIN_VALUE    750       // Min Position AnalogRead Value
#define   B1_MAX_VALUE    0         // Max Position AnalogRead Value
#define   B1_MIN_MAP      0
#define   B1_MAX_MAP      180
#define   readB1          constrain(map(readAnalog(B1, 10), B1_MIN_VALUE, B1_MAX_VALUE, B1_MIN_MAP, B1_MAX_MAP), B1_MIN_MAP, B1_MAX_MAP)
Servo     B1_MOTOR;

#define   B2              A1
#define   B2_MIN_VALUE    0
#define   B2_MAX_VALUE    466
#define   B2_MIN_MAP      0
#define   B2_MAX_MAP      180
#define   readB2          constrain(map(readAnalog(B2, 10), B2_MIN_VALUE, B2_MAX_VALUE, B2_MIN_MAP, B2_MAX_MAP), B2_MIN_MAP, B2_MAX_MAP)
Servo     B2_MOTOR;

#define   B3              A2
#define   B3_MIN_VALUE    0
#define   B3_MAX_VALUE    335
#define   B3_MIN_MAP      0
#define   B3_MAX_MAP      180
#define   readB3          constrain(map(readAnalog(B3, 10), B3_MIN_VALUE, B3_MAX_VALUE, B3_MIN_MAP, B3_MAX_MAP), B3_MIN_MAP, B3_MAX_MAP)
Servo     B3_MOTOR;

#define   B4              A3
#define   B4_MIN_VALUE    0
#define   B4_MAX_VALUE    590
#define   B4_MIN_MAP      0
#define   B4_MAX_MAP      180
#define   readB4          constrain(map(readAnalog(B4, 10), B4_MIN_VALUE, B4_MAX_VALUE, B4_MIN_MAP, B4_MAX_MAP), B4_MIN_MAP, B4_MAX_MAP)
Servo     B4_MOTOR;

void setup() {
  Serial.begin(9600);
  B1_MOTOR.attach(5);
  B2_MOTOR.attach(6);
  B3_MOTOR.attach(7);
  B4_MOTOR.attach(9);
//mySerial.begin(9600);
//mySerial.println("Hello, world?");
}

void loop() {
  // Serial Monitor
  Serial.println(String(b1) + " " + String(b2) + " " + String(b3) + " " + String(b4));
//mySerial.println(String(b1) + " " + String(b2) + " " + String(b3) + " " + String(b4));

  // Interval for Reading Values
  if(millis() - time_space_reading >= 10) {
    b1 = readB1;
    b2 = readB2;
    b3 = readB3;
    b4 = readB4;
    time_space_reading = millis();
  }

  // Interval for Writing To Motors
  if(millis() - time_space_motor >= 10) {
    B1_MOTOR.write(b1);
    B2_MOTOR.write(b2);
    B3_MOTOR.write(b3);
    B4_MOTOR.write(b4);
    time_space_motor = millis();
  }
}

int readAnalog(uint8_t Pin, uint8_t Readings) {
  int result = 0;
  for(int i=0; i<Readings; i++) {
    result += analogRead(Pin);
  }
  return result/Readings;
}

project (2) JAZ-ROBOT

  • JAZ-ROBOT
  • Simple explanation It is a small robot consisting of (4) Servo motors and Arduino nano and it can be programmed with different programs by writing the codes with different orders The robot can dance and walk

This week I’m going to make a robot to make a session for kids on how to make an Arduino robot

The robot can dance, walk and even run.

  • Step1:Required parts

You will need:

. Arduino Nano

. 14 male-male wires

. small protoboard

. 4 SG90 servos

. 1 9V battery

. 1 9V battery connector

. 2 rubber bands

  • Step3: Parts installation

  • All the pieces needed

  • It determines the degree of motor rotation and it starts from “0” to “180”

  • You install all parts with the same steps

  • Step4: Steps to connect the motor to the Arduino

  • How to connect wires with Arduino

  • In this drawing I connected the wires to the Arduino Uno board instead of the nano because if it is available in the design program the Arduino nano board you have to use the same steps only with the change of the board used

  • Step5: Programming code

Code Example

  • This experimental code checks you for all of the commands, if they are on the right angle, and if it is different, there may be an error in the direction of the motor directions.
  • code(1)
#include <Servo.h>

Servo rightfoot;

Servo rightthigh;

Servo leftfoot;

Servo leftthigh;

void setup()
{rightfoot.attach(9);

rightthigh.attach(5);

leftfoot.attach(3);

leftthigh.attach(11);

leftfoot.write(90);

leftthigh.write(90);

rightthigh.write(90);

rightfoot.write(90);}

void loop()

{delay (500);
  • Walking code 1
  • code(2)
#include

Servo rightfoot;

Servo rightthigh;

Servo leftfoot;

Servo leftthigh;

void setup()

{rightfoot.attach(9);

rightthigh.attach(5);

leftfoot.attach(3);

leftthigh.attach(11);

leftfoot.write(90);

leftthigh.write(90);

rightthigh.write(90);

rightfoot.write(90);}

void loop()

{//primer movimiento pata derecha

leftfoot.write(90);

rightfoot.write(110);

rightthigh.write(90);

leftthigh.write(90);

delay (500);

//segundo movimento pata derecha

leftfoot.write(90);

rightfoot.write(90);

rightthigh.write(90);

leftthigh.write(90);

delay (500);

//tercer movimiento pata derecha

leftfoot.write(90);

rightfoot.write(90);

rightthigh.write(110);

leftthigh.write(90);

delay (500);

//cuarto movimento pata derecha

leftfoot.write(90);

rightfoot.write(90);

rightthigh.write(70);

leftthigh.write(90);

delay (500);

//primer movimiento pata izda

leftfoot.write(70);

rightfoot.write(90);

rightthigh.write(90);

leftthigh.write(90);

delay (500);

//segundo movimento pata izda

leftfoot.write(90);

rightfoot.write(90);

rightthigh.write(90);

leftthigh.write(90);

delay (500);

//tercer movimiento pata izda

leftfoot.write(90);

rightfoot.write(90);

rightthigh.write(90);

leftthigh.write(70);

delay (500);

//cuarto movimento pata izda

leftfoot.write(90);

rightfoot.write(90);

rightthigh.write(90);

leftthigh.write(110);

delay (500);}
  • code(3)
#include <Servo.h>
Servo rightfoot;
Servo rightthigh;
Servo leftfoot;
Servo leftthigh;
int posleftfoot;
int posrightfoot;
int posrighttigh;
int poslefttigh;

void setup()
{
  rightfoot.attach(9);
  rightthigh.attach(5);
  leftfoot.attach(3);
  leftthigh.attach(11);
  leftfoot.write(90);
  leftthigh.write(90);
  rightthigh.write(90);
  rightfoot.write(90);
delay (5000);
}


void loop()
{
  //primer movimiento pata derecha
  leftfoot.write(90);
  rightfoot.write(110);
  rightthigh.write(90);
  leftthigh.write(90);
  delay (500);
  //segundo movimento pata derecha
  leftfoot.write(90);
  rightfoot.write(90);
  rightthigh.write(90);
  leftthigh.write(90);
  delay (500);
    //tercer movimiento pata derecha
  leftfoot.write(90);
  rightfoot.write(90);
  rightthigh.write(110);
  leftthigh.write(90);
  delay (500);
  //cuarto movimento pata derecha
  leftfoot.write(90);
  rightfoot.write(90);
  rightthigh.write(70);
  leftthigh.write(90);
  delay (500);
  //primer movimiento pata izda
  leftfoot.write(70);
  rightfoot.write(90);
  rightthigh.write(90);
  leftthigh.write(90);
  delay (500);
  //segundo movimento pata izda
  leftfoot.write(90);
  rightfoot.write(90);
  rightthigh.write(90);
  leftthigh.write(90);
  delay (500);
    //tercer movimiento pata izda
  leftfoot.write(90);
  rightfoot.write(90);
  rightthigh.write(90);
  leftthigh.write(70);
  delay (500);
  //cuarto movimento pata izda
  leftfoot.write(90);
  rightfoot.write(90);
  rightthigh.write(90);
  leftthigh.write(110);
  delay (500);
}  
  • code(4)
#include <Servo.h>
Servo rightfoot;
Servo rightthigh;
Servo leftfoot;
Servo leftthigh;
int posleftfoot;
int posrightfoot;
int posrighttigh;
int posleftthigh;

void setup()
{
rightfoot.attach(9);
rightthigh.attach(5);
leftfoot.attach(3);
leftthigh.attach(11);
leftfoot.write(90);
leftthigh.write(90);
rightthigh.write(90);
rightfoot.write(90);
}


void loop()
{

  for(posleftfoot = 70; posleftfoot <= 110; posleftfoot++)  
  {                                  
    leftfoot.write(posleftfoot);        
    delay(50);                   
  }

for(posrightfoot = 110; posrightfoot >= 70; posrightfoot--)  
  {
    rightfoot.write(posrightfoot);
    delay(50);                   
  }
  for(posrightfoot = 70; posrightfoot <= 110; posrightfoot++)  
  {
    rightfoot.write(posrightfoot);
    delay(50);                   
  }
  for(posleftfoot = 110; posleftfoot >= 70; posleftfoot--)  
  {                                  
    leftfoot.write(posleftfoot);        
    delay(50);                   
  }


 }
  • code(5)
#include <Servo.h>
Servo rightfoot;
Servo rightthigh;
Servo leftfoot;
Servo leftthigh;
int posleftfoot;
int posrightfoot;
int posrighttigh;
int posleftthigh;

void setup()
{
rightfoot.attach(9);
rightthigh.attach(5);
leftfoot.attach(3);
leftthigh.attach(11);
leftfoot.write(90);
leftthigh.write(90);
rightthigh.write(90);
rightfoot.write(90);
}


void loop()
{
  //segundo movimiento pata derecha
  for(posleftfoot = 90; posleftfoot <= 180; posleftfoot++)  
  {                                  
    leftfoot.write(posleftfoot);               
    delay(15);                   
  }
  //primer movimiento pata derecha
for(posrightfoot = 90; posrightfoot <= 135; posrightfoot++)  
  {
    rightfoot.write(posrightfoot);               
    delay(15);                   
  }

  //tercer movimento pata derecha
  for(posrighttigh = 90; posrighttigh <= 135; posrighttigh++)  
  {                                  
    rightthigh.write(posrighttigh);               
    delay(15);                   
  }
    //cuarto movimiento pata derecha
  for(posleftfoot = 180; posleftfoot >= 90; posleftfoot--)  
  {                                  
    leftfoot.write(posleftfoot);               
    delay(15);                   
  }
  //quinto movimiento pata derecha  
  for(posrightfoot = 135; posrightfoot >= 90; posrightfoot--)  
  {                                  
    rightfoot.write(posrightfoot);               
    delay(15);                   
  }
  //sexto movimiento pata derecha  
  for(posrighttigh = 135; posrighttigh >= 90; posrighttigh--)  
  {                                  
    rightthigh.write(posrighttigh);               
    delay(15);                   
  }
  //segundo movimiento pata izda
  for(posrightfoot = 90; posrightfoot >= 0; posrightfoot--)  
  {                                  
    rightfoot.write(posrightfoot);               
    delay(15);                   
  }
  //primer movimiento pata izda

for(posleftfoot = 90; posleftfoot >=45; posleftfoot--)  
  {                                  
    leftfoot.write(posleftfoot);               
    delay(15);                   
  }
  //tercer movimento pata izda
  for(posleftthigh = 90; posleftthigh >= 45; posleftthigh--)  
  {                                  
    leftthigh.write(posleftthigh);               
    delay(15);                   
  }
    //cuarto movimiento pata izda
  for(posrightfoot = 0; posrightfoot <= 90; posrightfoot++)  
  {                                  
    rightfoot.write(posrightfoot);               
    delay(15);                   
  }
  //quinto movimiento pata izda  
  for(posleftfoot = 45; posleftfoot <= 90; posleftfoot++)  
  {                                  
    leftfoot.write(posleftfoot);               
    delay(15);                   
  }
    //sexto movimiento pata izda  
  for(posleftthigh = 45; posleftthigh <= 90; posleftthigh++)  
  {                                  
    leftthigh.write(posleftthigh);               
    delay(15);                   
  }
 }
  • code(6)
#include <Servo.h>

Servo piederecho;
Servo pieizquierdo;
Servo caderaderecha;
Servo caderaizquierda;
Servo hombroderecho;
Servo hombroizquierdo;

void setup() {

  Serial.begin(9600);

  hombroderecho.attach(7);
  hombroizquierdo.attach(8);
  piederecho.attach(9);
  pieizquierdo.attach(10);
  caderaderecha.attach(11);
  caderaizquierda.attach(12);
  hombroderecho.write(90);
  hombroizquierdo.write(90);
  piederecho.write(90);
  pieizquierdo.write(90);
  caderaderecha.write(90);
  caderaizquierda.write(90);

}

void loop() {
  parado();
  hithere();
  fight();
}


void parado() {
hombroderecho.write(90);
  hombroizquierdo.write(90);
  piederecho.write(90);
  pieizquierdo.write(90);
  caderaderecha.write(90);
  caderaizquierda.write(90);
  delay(1000);
}


void hithere() {
hombroderecho.write(180);
  hombroizquierdo.write(90);
  piederecho.write(90);
  pieizquierdo.write(90);
  caderaderecha.write(90);
  caderaizquierda.write(90);
  delay(1000);
}

  void fight() {
hombroderecho.write(45);
  hombroizquierdo.write(135);
  piederecho.write(90);
  pieizquierdo.write(90);
  caderaderecha.write(110);
  caderaizquierda.write(70);
  delay(250);
  hombroderecho.write(135);
  hombroizquierdo.write(45);
  piederecho.write(90);
  pieizquierdo.write(90);
  caderaderecha.write(110);
  caderaizquierda.write(70);
  delay(250);
  hombroderecho.write(45);
  hombroizquierdo.write(135);
  piederecho.write(90);
  pieizquierdo.write(90);
  caderaderecha.write(110);
  caderaizquierda.write(70);
  delay(250);
  hombroderecho.write(135);
  hombroizquierdo.write(45);
  piederecho.write(90);
  pieizquierdo.write(90);
  caderaderecha.write(110);
  caderaizquierda.write(70);
  delay(250);
}  
  • code(7)
#include <Servo.h>
Servo rightfoot;
Servo rightthigh;
Servo leftfoot;
Servo leftthigh;
int posleftfoot;
int posrightfoot;
int posrightthigh;
int posleftthigh;

void setup()
{
  rightfoot.attach(3);
  rightthigh.attach(5);
  leftfoot.attach(9);
  leftthigh.attach(11);
  leftfoot.write(90);
  leftthigh.write(90);
  rightthigh.write(90);
  rightfoot.write(90);
}

void loop()
{
  for (posleftfoot = 90; posleftfoot <= 120; posleftfoot++)
  {
    leftfoot.write(posleftfoot);
    delay(50);
  }

  for (posrightfoot = 90; posrightfoot <= 120; posrightfoot++)
  {
    rightfoot.write(posrightfoot);
    delay(50);
  }
  for (posrightthigh = 90; posrightthigh <= 120; posrightthigh++)
  {
    rightthigh.write(posrightthigh);
    delay(50);
  }
  for (posrightthigh = 120; posrightthigh >= 90; posrightthigh--)
  {
    rightthigh.write(posrightthigh);
    delay(50);
  }
  for (posrightfoot = 120; posrightfoot >= 90; posrightfoot--)
  {
    rightfoot.write(posrightfoot);
    delay(50);
  }

  for (posleftfoot = 120; posleftfoot >= 90; posleftfoot--)
  {
    leftfoot.write(posleftfoot);
    delay(50);
  }

}