user13675: Please give me a code and diagram use makeblock i.r sensor V2.1 and makeblock remote. It should be connected to a d.c motor that works with a h-bridge.It also has to be a dual motor which combines these two codes:
1:This one for the movement
const int controlPin1 = 2; // connected to pin 7 on the H-bridge
const int controlPin2 = 3; // connected to pin 2 on the H-bridge
const int enablePin = 9; // connected to pin 1 on the H-bridge
const int directionSwitchPin = 4; // connected to the switch for direction
const int onOffSwitchStateSwitchPin = 5; // connected to the switch for turning the motor on and off
const int potPin = A0; // connected to the potentiometer's output

// create some variables to hold values from your inputs
int onOffSwitchState = 0; // current state of the On/Off switch
int previousOnOffSwitchState = 0; // previous position of the on/off switch
int directionSwitchState = 0; // current state of the direction switch
int previousDirectionSwitchState = 0; // previous state of the direction switch

int motorEnabled = 0; // Turns the motor on/off
int motorSpeed = 0; // speed of the motor
int motorDirection = 1; // current direction of the motor

void setup()
{
    // intialize the inputs and outputs
    pinMode(directionSwitchPin, INPUT);
    pinMode(onOffSwitchStateSwitchPin, INPUT);
    pinMode(controlPin1, OUTPUT);
    pinMode(controlPin2, OUTPUT);
    pinMode(enablePin, OUTPUT);

    // pull the enable pin LOW to start
    digitalWrite(enablePin, LOW);
}

void loop()
{
    // read the value of the on/off switch
    onOffSwitchState = digitalRead(onOffSwitchStateSwitchPin);
    delay(1);

    // read the value of the direction switch
    directionSwitchState = digitalRead(directionSwitchPin);

    // read the value of the pot and divide by 4 to get 
    // a value that can be used for PWM
    motorSpeed = analogRead(potPin) / 4;

    // if the on/off button changed state since the last loop()
    if (onOffSwitchState != previousOnOffSwitchState)
    {
        // change the value of motorEnabled if pressed
        if (onOffSwitchState == HIGH)
        {
            motorEnabled = !motorEnabled;
        }
    }

    // if the direction button changed state since the last loop()
    if (directionSwitchState != previousDirectionSwitchState)
    {
        // change the value of motorDirection if pressed 
        if (directionSwitchState == HIGH)
        {
            motorDirection = !motorDirection;
        }
    }

    // change the direction the motor spins by talking
    // to the control pins on the H-Bridge
    if (motorDirection == 1)
    {
        digitalWrite(controlPin1, HIGH);
        digitalWrite(controlPin2, LOW);
    }
    else
    {
        digitalWrite(controlPin1, LOW);
        digitalWrite(controlPin2, HIGH);
    }

    // if the motor is supposed to be on
    if (motorEnabled == 1)
    {
        // PWM the enable pin to vary the speed
        analogWrite(enablePin, motorSpeed);
    }
    else
    { // if the motor is not supposed to be on
        //turn the motor off
        analogWrite(enablePin, 0);
    }
    // save the current On/Offswitch state as the previous 
    previousDirectionSwitchState = directionSwitchState;
    // save the current switch state as the previous
    previousOnOffSwitchState = onOffSwitchState;
}

2: This one for the IR:
#include "IRremote.h"  //-----( Import needed libraries )-----
int receiver = 11; // ----- DAT pin of IR receiver to Arduino digital pin 11

/*-----( Declare objects )-----*/
IRrecv irrecv(receiver);           // create instance of 'irrecv'
decode_results results;            // create instance of 'decode_results'

void setup()    /*----( SETUP: RUNS ONCE )----*/
{
    Serial.begin(9600);  // Begin serial communication
    Serial.println("IR Receiver Raw Data + Button Decode Test");
    irrecv.enableIRIn(); // Start the receiver
}               /*--(end setup )---*/


void loop()     /*----( LOOP: RUNS CONSTANTLY )----*/
{
    if (irrecv.decode(&results)) // have we received an IR signal?
    {
        //    Serial.println(results.value);  // Uncomment to print raw decimal values
        translateIR(); // run function "translateIR"
        irrecv.resume(); // receive the next value
    }
}               /* --(end main loop )-- */

/*-----( Declare User-written Functions )-----*/
void translateIR()  // translate Makeblock remote raw values to keys
{
    switch (results.value)
    {
        case 4219133059:      Serial.println(" A ");     break;
        case 667718909:       Serial.println(" B ");     break;
        case 3478241646:      Serial.println(" C ");     break;
        case 1322193145:      Serial.println(" D ");     break;
        case 3689098103:      Serial.println(" ^ ");     break;
        // case 3478241646:      Serial.println(" E ");     break;
        case 1776008254:      Serial.println(" < ");     break;
        case 1803700378:      Serial.println(" * ");     break;
        case 3495019267:      Serial.println(" > ");     break;
        case 1943112141:      Serial.println(" 0 ");     break;

        case 3444686410:      Serial.println(" v ");     break;
        case 2806989789:      Serial.println(" F ");     break;
        case 3689098101:      Serial.println(" 1 ");     break;
        // case 3689098103:      Serial.println(" 2 ");     break;
        case 1943112142:      Serial.println(" 3 ");     break;
        case 3689098102:      Serial.println(" 4 ");     break;
        // case 3689098102:      Serial.println(" 5 ");     break;
        case 2181502997:      Serial.println(" 6 ");     break;
        case 650941290:       Serial.println(" 7 ");     break;
        case 402038415:       Serial.println(" 8 ");     break;
        case 945450753:       Serial.println(" 9 ");     break;
        default:     Serial.println(" other button   ");
    }

    delay(250);
} //END translateIR


user7727: You need a good IR Library, or tons of low-level knowledge. 
Ken Shirriff wrote the best IR library out there! Here it is.
Adafruit writes awesome tutorials too. Here's one.

user10394: You should be able to search on Google and get a library to interface with the sensor.  Then you will need some motors, a motor controller, and a library to control that.  Then you will need to stick it all together using your code.
What you need to do is:

Search for your IR library and a tutorial.
Search for a Stepper motor tutorial and library.
Then post a question when you are stuck with that.


13675: <p>Please give me a code and diagram use makeblock i.r sensor V2.1 and makeblock remote. It should be connected to a d.c motor that works with a h-bridge.It also has to be a dual motor which combines these two codes:</p>

<p>1:This one for the movement</p>

<pre><code>const int controlPin1 = 2; // connected to pin 7 on the H-bridge
const int controlPin2 = 3; // connected to pin 2 on the H-bridge
const int enablePin = 9; // connected to pin 1 on the H-bridge
const int directionSwitchPin = 4; // connected to the switch for direction
const int onOffSwitchStateSwitchPin = 5; // connected to the switch for turning the motor on and off
const int potPin = A0; // connected to the potentiometer's output

// create some variables to hold values from your inputs
int onOffSwitchState = 0; // current state of the On/Off switch
int previousOnOffSwitchState = 0; // previous position of the on/off switch
int directionSwitchState = 0; // current state of the direction switch
int previousDirectionSwitchState = 0; // previous state of the direction switch

int motorEnabled = 0; // Turns the motor on/off
int motorSpeed = 0; // speed of the motor
int motorDirection = 1; // current direction of the motor

void setup()
{
    // intialize the inputs and outputs
    pinMode(directionSwitchPin, INPUT);
    pinMode(onOffSwitchStateSwitchPin, INPUT);
    pinMode(controlPin1, OUTPUT);
    pinMode(controlPin2, OUTPUT);
    pinMode(enablePin, OUTPUT);

    // pull the enable pin LOW to start
    digitalWrite(enablePin, LOW);
}

void loop()
{
    // read the value of the on/off switch
    onOffSwitchState = digitalRead(onOffSwitchStateSwitchPin);
    delay(1);

    // read the value of the direction switch
    directionSwitchState = digitalRead(directionSwitchPin);

    // read the value of the pot and divide by 4 to get 
    // a value that can be used for PWM
    motorSpeed = analogRead(potPin) / 4;

    // if the on/off button changed state since the last loop()
    if (onOffSwitchState != previousOnOffSwitchState)
    {
        // change the value of motorEnabled if pressed
        if (onOffSwitchState == HIGH)
        {
            motorEnabled = !motorEnabled;
        }
    }

    // if the direction button changed state since the last loop()
    if (directionSwitchState != previousDirectionSwitchState)
    {
        // change the value of motorDirection if pressed 
        if (directionSwitchState == HIGH)
        {
            motorDirection = !motorDirection;
        }
    }

    // change the direction the motor spins by talking
    // to the control pins on the H-Bridge
    if (motorDirection == 1)
    {
        digitalWrite(controlPin1, HIGH);
        digitalWrite(controlPin2, LOW);
    }
    else
    {
        digitalWrite(controlPin1, LOW);
        digitalWrite(controlPin2, HIGH);
    }

    // if the motor is supposed to be on
    if (motorEnabled == 1)
    {
        // PWM the enable pin to vary the speed
        analogWrite(enablePin, motorSpeed);
    }
    else
    { // if the motor is not supposed to be on
        //turn the motor off
        analogWrite(enablePin, 0);
    }
    // save the current On/Offswitch state as the previous 
    previousDirectionSwitchState = directionSwitchState;
    // save the current switch state as the previous
    previousOnOffSwitchState = onOffSwitchState;
}
</code></pre>

<p>2: This one for the IR:</p>

<pre><code>#include "IRremote.h"  //-----( Import needed libraries )-----
int receiver = 11; // ----- DAT pin of IR receiver to Arduino digital pin 11

/*-----( Declare objects )-----*/
IRrecv irrecv(receiver);           // create instance of 'irrecv'
decode_results results;            // create instance of 'decode_results'

void setup()    /*----( SETUP: RUNS ONCE )----*/
{
    Serial.begin(9600);  // Begin serial communication
    Serial.println("IR Receiver Raw Data + Button Decode Test");
    irrecv.enableIRIn(); // Start the receiver
}               /*--(end setup )---*/


void loop()     /*----( LOOP: RUNS CONSTANTLY )----*/
{
    if (irrecv.decode(&amp;results)) // have we received an IR signal?
    {
        //    Serial.println(results.value);  // Uncomment to print raw decimal values
        translateIR(); // run function "translateIR"
        irrecv.resume(); // receive the next value
    }
}               /* --(end main loop )-- */

/*-----( Declare User-written Functions )-----*/
void translateIR()  // translate Makeblock remote raw values to keys
{
    switch (results.value)
    {
        case 4219133059:      Serial.println(" A ");     break;
        case 667718909:       Serial.println(" B ");     break;
        case 3478241646:      Serial.println(" C ");     break;
        case 1322193145:      Serial.println(" D ");     break;
        case 3689098103:      Serial.println(" ^ ");     break;
        // case 3478241646:      Serial.println(" E ");     break;
        case 1776008254:      Serial.println(" &lt; ");     break;
        case 1803700378:      Serial.println(" * ");     break;
        case 3495019267:      Serial.println(" &gt; ");     break;
        case 1943112141:      Serial.println(" 0 ");     break;

        case 3444686410:      Serial.println(" v ");     break;
        case 2806989789:      Serial.println(" F ");     break;
        case 3689098101:      Serial.println(" 1 ");     break;
        // case 3689098103:      Serial.println(" 2 ");     break;
        case 1943112142:      Serial.println(" 3 ");     break;
        case 3689098102:      Serial.println(" 4 ");     break;
        // case 3689098102:      Serial.println(" 5 ");     break;
        case 2181502997:      Serial.println(" 6 ");     break;
        case 650941290:       Serial.println(" 7 ");     break;
        case 402038415:       Serial.println(" 8 ");     break;
        case 945450753:       Serial.println(" 9 ");     break;
        default:     Serial.println(" other button   ");
    }

    delay(250);
} //END translateIR
</code></pre>
 7727: <p>You need a good IR Library, or tons of low-level knowledge. </p>

<p>Ken Shirriff wrote the best IR library out there! <a href="http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html" rel="nofollow">Here it is</a>.</p>

<p>Adafruit writes awesome tutorials too. <a href="https://learn.adafruit.com/using-an-infrared-library/hardware-needed" rel="nofollow">Here's one</a>.</p>
 10394: <p>You should be able to search on Google and get a library to interface with the sensor.  Then you will need some motors, a motor controller, and a library to control that.  Then you will need to stick it all together using your code.</p>

<p>What you need to do is:</p>

<ul>
<li>Search for your IR library and a tutorial.</li>
<li>Search for a Stepper motor tutorial and library.</li>
<li>Then post a question when you are stuck with that.</li>
</ul>
