App Control

From Wiki

Jump to: navigation, search

Project

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

中文指导请点这里

Part8 Bluetooth Control

Summary:
The theoryof bluetooth control is that install a app into users' mobilephone. This app can use bluetooth to connect with bluetooth module of FreaksCar. When it
successfully, app will send data to FreaksCar continuedly. Data is coordinate of button of direction. When users' move this buton, it's coordinate will be
changed so it send data of coordinate will be changed too. FreaksCar can decode data in its chip and judge the button of app is moved to which direction. So
FreaksCar can judge which direction to move. The button which is at the right of app is interruption button. In this program, this interruption is make its Bluetooth.gif


buzzer to tweet

Introduction:

FreaksCarV14 BluetoothModule01.jpg
Schematic:

FreaksCarV14 BluetoothSchematic01.jpg

Arduino Program

Please download the zip to get Library:

FreaksCar.zip


/*************************************************
  Copyright (C), 2016-2020, Elecfeaks Tech. Co., Ltd.
  File name:      Bluetooth_Control.ino
  Author:         Dragon
  Version:        V1.1
  Date:           2016-3-10
  Description:    App control FreaksCar
  Others:          
  History:         
    1. Date:  
      Author: 
      Modification:
    2. ...
*************************************************/
#include <IRremote.h>
#include <IRremoteInt.h>
#include <SerialComunicator.h>
#include <FreaksCar.h>
FreaksCar Car;		
 
float P=125.00;
float R=125.00;
float Throttle = 125.0;
float Yaw = 125.0;
 
void setup()
{
#if defined(MEGA32U4)
    Serial1.begin(115200);
#endif

#if defined(UNO)
    Serial.begin(115200);
#endif
}
 
void loop()
{
#if defined(UNO)
    while(Serial.available())
    {
        uint8_t c = Serial.read();
        Car.recievedData(&c, 1);
        P=(float)Car.getPitch();
        R = (float)Car.getYaw();
    }
#endif
#if defined(MEGA32U4)
    while(Serial1.available())
    {
        uint8_t c = Serial1.read();
        Car.recievedData(&c, 1);
        P=(float)Car.getPitch();
        R = (float)Car.getYaw();
    }
#endif
    if(P<125.00)//back
    {
        if(R<125.00)
        {
	    Car.Car_TurnLeft(0,100);
        }
        else
        {
            if(R>125)
            {
		Car.Car_TurnRight(100,0);
            }
            else
            {
		Car.Car_Back(100);
            }
        }
    }
    else
    {
        if(P>125)//forward
        {
            if(R<125)
            {
	        Car.Car_TurnLeft(0,100);
            }
            else
            {
                if(R>125)
                {
		    Car.Car_TurnRight(100,0);
                }else{
		    Car.Car_Forward(100);
                }
            }
        }
        else {
	    Car.Car_Stop();
        }
    } 
 
}
Result:

Run the APP. If it doesn’t connected with bluetooth module,If the app connect with bluetooth module successfully you will heard a connected sound, we can move the button of positon to control the FreaksCar. Now enjoy it. BLECenter controller3.png
Personal tools
Namespaces
Variants
Actions
Navigation
Support
Toolbox