IRremote

From Wiki

Jump to: navigation, search

套件项目列表

Introduce:
The FreaksCar series is supported by ElECFREAKS. It is a multi_function car. We creates 7 lessons to make users to study easily. It can help us to improve our
thoughts to develop multi-function car if we study how to uwe the sensors. For example, Infrared and Ultrasonic help us to learn how to avoid obstruction and
check distance. IRremote can help us to learn how to control the car. FindLineModule can help us how to use sensors and set up the truck of car. And also the buzzer
which is in on the car can play songs if we write programs for it. At last, there is a switch in the car can be used to check collision。

  • Home
  • Part1: Ultrasonic - Ultrasonic obstacle avoidance
  • Part2: IRremote - IR remote control
  • Part3: Light Tracking - Light track and follow
  • Part4: Line Following - Black line track
  • Part5: Buzzer - Use car's buzzer singing
  • Part6: Speed - Encoder control car's speed
  • Part7: App Control - Smartphone app control it by Bluetooth

</div>


中文指导请点这里

Part2 IRremote

Summary:
There is a infrared receive module at the head of FreaksCar. There are many logical electric in it to judge special infrared signal. The remote control can encode
signals of buttons to transmite because there is a encoding electric in it. The infrared receive module can decode infrared signals when it receive them
and the FreaksCar can judge signals belong to whicn buttons. InfraredControl.gif
Introduction:

FreaksCarV14 IRremoteModule01.jpg
Schemetic:

FreaksCarV14 IRremoteSchematic.jpg
  PIN Connection:

Infrared Receive Module----D17
Left Motor Direction-------D5
Left Motor Speed-----------D10
Right Motor Direction------D6
Right Motor Speed----------D11


Hardware:

FreaksCarV14 IRremoteHardware.jpg

Connection:

FreaksCarV14 Connection.jpg

Arduino Code

Please download the zip to get Library:

FreaksCar.zip


/*************************************************
  Copyright (C), 2016-2020, Elecfeaks Tech. Co., Ltd.
  File name:      InfraredControl.ino
  Author:         Dragon
  Version:        V1.1
  Date:           2016-3-10
  Description:    FreaksCar Infrare Control test
  Others:          
  History:         
    1. Date:  
      Author: 
      Modification:
    2. ...
  WebSite:www.elecfreaks.com
*************************************************/
#include <IRremote.h>
#include <IRremoteInt.h>
#include <SerialComunicator.h>
#include <FreaksCar.h>
FreaksCar Car;		
 
 
void setup()
{
 
}
 
void loop()
{
    switch(Car.Car_InfraredControl())
    {
        case 'F':
			Car.Car_Forward(100);
        break;
 
        case 'L':
			Car.Car_TurnLeft(0,100);
        break;
 
        case 'R':
			Car.Car_TurnRight(100,0);
        break;
 
		case 'D':
			Car.Car_Back(100);
        break;
 
		case 'S':
			Car.Car_Stop();
		break;
    }                     
}



Explain of Car_IfnraredControl(): The function has no parameter. It returns value which is char. It's function is to decode infrared siganls and return it through the char value. But users must to pay
attention to it because there is a while(1) cycle in the function. Users use the function can get values of remote control buttons directly but if the module didn't
receive any signal, the function would not break out the while(1) cycle so users must think about their logic of their sentences of programs to avoid this
phenomenon.

Result:
FreaksCarV14 IRremoteResult.jpg
Theory:
ELEFREAKS created a library of FreaksCar. It include a function, Car_InfraredControl(). There is a while cycle in it. When the module receive infrared signals, it returns value
of remote control button. If users use it and the module didn't receive any signals, programs will stay in the while cycle until it receive a signal.
The map of returning value and buttons.
Buttons----------------------Values
1、“↑”----------------------'F'(char) 2、“↓”----------------------'D'(char) 3、“←”----------------------'L'(char) 4、“→”----------------------'R'(char) 5、“OK”----------------------'S'(char) 6、“Power”-------------------'P'(char) 7、“Menu”--------------------'M'(char) 8、“+”-----------------------'+'(char) 9、“-”-----------------------'-'(char) 10、“Return”-----------------'B'(char) 11、“0”-----------------------0 (int) 12、“1”-----------------------1 (int) 13、“2”-----------------------2 (int) 14、“3”-----------------------3 (int) 15、“4”-----------------------4 (int) 16、“5”-----------------------5 (int) 17、“6”-----------------------6 (int) 18、“7”-----------------------7 (int) 19、“8”-----------------------8 (int) 20、“9”-----------------------9 (int)
Personal tools
Namespaces
Variants
Actions
Navigation
Support
Toolbox