Lesson 2 Bluetooth Car

Similar documents
Lesson4 Obstacle avoidance car

J. La Favre Using Arduino with Raspberry Pi February 7, 2018

Lesson 3: Arduino. Goals

Module: Arduino as Signal Generator

Arduino Lesson 1. Blink. Created by Simon Monk

Pulse Width Modulation and

FABO ACADEMY X ELECTRONIC DESIGN

The Motor sketch. One Direction ON-OFF DC Motor

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

Computational Crafting with Arduino. Christopher Michaud Marist School ECEP Programs, Georgia Tech

Arduino DC Motor Control Tutorial L298N PWM H-Bridge

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

A servo is an electric motor that takes in a pulse width modulated signal that controls direction and speed. A servo has three leads:

For this exercise, you will need a partner, an Arduino kit (in the plastic tub), and a laptop with the Arduino programming environment.

EE-110 Introduction to Engineering & Laboratory Experience Saeid Rahimi, Ph.D. Labs Introduction to Arduino

RC-WIFI CONTROLLER USER MANUAL

Experiment 1: Robot Moves in 3ft squared makes sound and

02 Digital Input and Output

ARDUINO / GENUINO. start as professional

Experiment 4.B. Position Control. ECEN 2270 Electronics Design Laboratory 1

Training Schedule. Robotic System Design using Arduino Platform

Arduino STEAM Academy Arduino STEM Academy Art without Engineering is dreaming. Engineering without Art is calculating. - Steven K.

CURIE Academy, Summer 2014 Lab 2: Computer Engineering Software Perspective Sign-Off Sheet

4WD Mobile Platform SKU:ROB0022

Name & SID 1 : Name & SID 2:

CONSTRUCTION GUIDE Capacitor, Transistor & Motorbike. Robobox. Level VII

Community College of Allegheny County Unit 4 Page #1. Timers and PWM Motor Control

MAE106 Laboratory Exercises Lab # 1 - Laboratory tools

INTRODUCTION to MICRO-CONTROLLERS

Arduino and Servo Motor

Motors and Servos Part 2: DC Motors

Lab 5: Arduino Uno Microcontroller Innovation Fellows Program Bootcamp Prof. Steven S. Saliterman

Programming 2 Servos. Learn to connect and write code to control two servos.

1. Controlling the DC Motors

Understanding the Arduino to LabVIEW Interface

Project #6 Introductory Circuit Analysis

MOBILE ROBOT LOCALIZATION with POSITION CONTROL

HC-SR501 Passive Infrared (PIR) Motion Sensor

ABCs of Arduino. Kurt Turchan -

Basics before Migtrating to Arduino

QS PRO Set-up App Instructions Bluetooth setup

DFRduino Romeo All in one Controller V1.1(SKU:DFR0004)

Mechatronics Engineering and Automation Faculty of Engineering, Ain Shams University MCT-151, Spring 2015 Lab-4: Electric Actuators

INTRODUCTION to MICRO-CONTROLLERS

Coding with Arduino to operate the prosthetic arm

INA169 Breakout Board Hookup Guide

Application Note. Communication between arduino and IMU Software capturing the data

2D Floor-Mapping Car

MicroWave Sensor SKU: SEN0192

Sten-Bot Robot Kit Stensat Group LLC, Copyright 2013

Touch Potentiometer Hookup Guide

Monitoring Temperature using LM35 and Arduino UNO

Embedded Controls Final Project. Tom Hall EE /07/2011

Lab 5: Inverted Pendulum PID Control

Arduino Workshop 01. AD32600 Physical Computing Prof. Fabian Winkler Fall 2014

Experiment (2) DC Motor Control (Direction and Speed)

Arduino Control of Tetrix Prizm Robotics. Motors and Servos Introduction to Robotics and Engineering Marist School

2016+ QS PRO Set-up App Instructions For Bluetooth BLE (Android 4.4+)

CONSTRUCTION GUIDE Light Robot. Robobox. Level VI

INTRODUCTION to MICRO-CONTROLLERS

LESSONS Lesson 1. Microcontrollers and SBCs. The Big Idea: Lesson 1: Microcontrollers and SBCs. Background: What, precisely, is computer science?

EGG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

URM37 V3.2 Ultrasonic Sensor (SKU:SEN0001)

TWEAK THE ARDUINO LOGO

QS PRO & QS PRO 2 Set-up App Instructions For Bluetooth BLE (Android 4.4+)

Follow this and additional works at: Part of the Engineering Commons

Parts List. Robotic Arm segments ¼ inch screws Cable XBEE module or Wifi module

Lab 2: Blinkie Lab. Objectives. Materials. Theory

C++ PROGRAM FOR DRIVING OF AN AGRICOL ROBOT

Instructions for getting connected with Incus and using IHearYou

Attribution Thank you to Arduino and SparkFun for open source access to reference materials.

keyestudio keyestudio Mini Tank Robot

Rodni What will yours be?

Setup Download the Arduino library (link) for Processing and the Lab 12 sketches (link).

BMW E6x/E9x Android Touch Screen Radio Installation Instructions

Lesson 13. The Big Idea: Lesson 13: Infrared Transmitters

Objectives: Learn what an Arduino is and what it can do Learn what an LED is and how to use it Be able to wire and program an LED to blink

Real Time Implementation of Power Electronics System

BLE 4.0 Module ZBModule User Manual 1 / 15

ARDUINO / GENUINO. start as professional. short course in a book. faculty of engineering technology

LED + Servo 2 devices, 1 Arduino

PWM CONTROL USING ARDUINO. Learn to Control DC Motor Speed and LED Brightness

Getting started with the SparkFun Inventor's Kit for Google's Science Journal App

Arduino Advanced Projects

Arduino An Introduction

Electronics Design Laboratory Lecture #6. ECEN2270 Electronics Design Laboratory

Unit 24: Controlling Systems Using IT

Community College of Allegheny County Unit 7 Page #1. Analog to Digital

Roborodentia Robot: Tektronix. Sean Yap Advisor: John Seng California Polytechnic State University, San Luis Obispo June 8th, 2016

Disclaimer. Arduino Hands-On 2 CS5968 / ART4455 9/1/10. ! Many of these slides are mine. ! But, some are stolen from various places on the web

TETRIX PULSE Workshop Guide

EVDP610 IXDP610 Digital PWM Controller IC Evaluation Board

CONSTRUCTION GUIDE Robotic Arm. Robobox. Level II

ISSN: [Singh* et al., 6(6): June, 2017] Impact Factor: 4.116

DESIGNED BY THE BLACK TANK USER MANUAL

Megamark Arduino Library Documentation

Application Note AN 102: Arduino I2C Interface to K 30 Sensor

Learning Objectives. References 10/26/11. Using servos with an Arduino. EAS 199A Fall 2011

DC Motors. come in all shapes and sizes. You probably have 3-4 on you right now. the two motors in the kit

Arduino Microcontroller Processing for Everyone!: Third Edition / Steven F. Barrett

Transcription:

Lesson 2 Bluetooth Car Points of this section It is very important and so cool to control your car wirelessly in a certain space when we learn the Arduino, so in the lesson, we will teach you how to control a car by Bluetooth. Learning Parts: Learn how to use the Bluetooth module and the Bluetooth APP Learn how to control the vehicle via Bluetooth Write programs to implement this function Preparations: A vehicle (equipped with battery) A USB cable A Bluetooth module An IPhone or tablet 1

Ⅰ. Bluetooth module The description of Bluetooth module: 1. Adopt mainstream Bluetooth chip of TI, protocol standard of BluetoothV4.0 2. Analog working voltage of serial port is 3.3V 3. Users can set baud rate1200, 2400, 4800, 9600, 19200, 38400, 57600,115200 4. Dimension of key module is 28mm x 15 mm x2.35mm 5. Working electric current: 40MA 6. Dormancy electric current: less than1ma 7. Being used for GPS navigation system, hydroelectric gas reading system, industrial field mining control system 8. Can be connected to Bluetooth laptop, computer with Bluetooth adapter, PDA, etc. This is the schematic diagram of Bluetooth module connected to UNO controller board: In the experiment we will connect it to UNO board via expansion board V5. 2

Ⅱ. Bluetooth APP For Android system, copy the APK file to the Android products and install it. Below, take the Apple mobile phone or tablet for example: Search ELEGOO BLE Tool in Apple Store. Install the APP and then run it on your phone. 3

It will show as blow and advise you to turn on Bluetooth function when you run it. 4

Click Connection. 5

Then you phone will search Bluetooth equipment nearby. Click Bluetooth name,when the connection is successful, the screen will be displayed Device Connected The app interface will be shown as the left one below, then we can slide the screen to the left side by our finger and we can get the key pattern as the right one below: 6

7

8

Finally, we set the definition of each button, we will take goforward for example, please see below, and the rest key-values are set in the same manner. 9

Ⅲ. Testing Testing program is as below: int LED=13;//Define 13 pin of LED volatile int state = LOW;//The initial state of function is defined as a low level char getstr; //Defines function that receives Bluetooth character void setup() pinmode(led, OUTPUT); Serial.begin(9600); /*Control LED sub function*/ void statechange() state =!state; digitalwrite(led, state); void loop() getstr=serial.read();//bluetooth serial port receives data in function if(getstr=='a') statechange(); Open the file : \bluetooth_blink\bluetooth_blink.ino 10

Upload the program to the UNO board, disconnect it from the computer, and then switch on the car s power supply. (TIPS: The Bluetooth module should be pulled out when you upload the program, or it will be failed to upload the program.) Open APP After connecting the phone to the car through Bluetooth, we set data as below: After set-up, press this button. You will find that light on the UNO board changes with the switch. 11

The code Serial.begin(9600); The purpose of this block of code is to set the baud rate of the UNO control board as 9600 and open the serial port. In this way, they can communicate with each other, because the original baud rate of the Bluetooth module is 9600. getstr=serial.read();//the Bluetooth serial port to receive the data in the function if(getstr=='a') statechange(); This function is executed repeatedly within the circulating function. It will first read data from the serial port and then check the data. If it meets the condition, it will execute the corresponding sub-function. For example, if it reads the letter A from the serial port, it will execute the sub-function responsible for switching on/off the LED light. 12

Ⅳ. Make a Bluetooth Car When the car turns left or right, it s not necessary to set the speed too fast. On the contrary, we need to control the speed of car. But how to control? The answer is PWM. PWM is the abbreviation of Pulse Width Modulation, is called pulse modulation in short, is an effective technology to control analog circuit with digital output of microprocessor, car is used to change speed of motor by altering duty cycle of a square wave. In other words, connect and break circuit between two sides of motor constantly, is switch of holding motor work, motor will not be off when power is off because of the fast speed. So we can control speed of car if we control specific value of power on time and power off time. The speed of car will be max when circuit is holding still. The speed of car will be minimum if circuit is holding off. The speed of car will be median in half time. PWM is a technology to get analog quantity through digital method. A square wave is formed by digital control, square wave signal only have two state of on and off (That is high-low of digital pins).simulate voltage changing from 0 to 5V by controlling specific value of duration on and off time. Occupied time of on (That is high level in academy) is called pulse width, so PWM is also called pulse width modulation. Let s learn about PWM through five square waves below. Green vertical line above represent a period of square wave. The value written into every analogwrite(value) corresponds to the percentage, the percentage is also called Duty Cycle, refer to the percentage gotten from specific value between duration high level and low level time in a period. In figure, from top to bottom, the first square wave, duty cycle is 0%, corresponding value is 0. Output circuit current is minimum, motor hold still. The longer duration time is, the bigger circuit current motor gets, the faster the speed is. So, the final one s duty cycle is 100%, corresponding value is 255, motor 13

rotates in full speed. 50% is medium hyponastic rotate speed, 25% is relatively slower, even can t start (The circuit current is relatively big to start motor because of static friction). PWM is mostly used to adjust light of LED and rotate speed of motor, wheel speed controlled by motor is easily be controlled. The advantage of PWM can be more reflected when you play with some Arduino cars. analogwrite(pin,value); analogwrite() is used to write analog value of 0 to 255 for PWM ports. What you need to note is that, analogwrite() is only used to digital pins with function of PWM. Pins with function of PWM in UNO are only digital pins of 3,5,6,9,10,11. Our car s speed is controlled by connecting pin5 and pin10 of ENA and ENB. The program below, have set a digital function int ABS=135; The speed is controlled in below program, so you can control the speed on your own. analogwrite(ena,abs); analogwrite(enb,abs); After learning the basic knowledge, we will upload the program as below to the car, open the file bluetooth_car\ bluetooth_car.ino. int LED=13; volatile int state = LOW; char getstr; int in1=6; int in2=7; int in3=8; int in4=9; int ENA=5; int ENB=11; int ABS=135; void _mforward() digitalwrite(ena,high); 14

digitalwrite(enb,high); digitalwrite(in1,low); digitalwrite(in2,high); digitalwrite(in3,low); digitalwrite(in4,high); Serial.println("go forward!"); void _mback() digitalwrite(ena,high); digitalwrite(enb,high); digitalwrite(in1,high); digitalwrite(in2,low); digitalwrite(in3,high); digitalwrite(in4,low); Serial.println("go back!"); void _mleft() analogwrite(ena,abs); analogwrite(enb,abs); digitalwrite(in1,low); digitalwrite(in2,high); digitalwrite(in3,high); digitalwrite(in4,low); Serial.println("go left!"); void _mright() analogwrite(ena,abs); analogwrite(enb,abs); digitalwrite(in1,high); digitalwrite(in2,low); 15

digitalwrite(in3,low); digitalwrite(in4,high); Serial.println("go right!"); void _mstop() digitalwrite(ena,low); digitalwrite(enb,low); Serial.println("Stop!"); void statechange() state =!state; digitalwrite(led, state); void setup() pinmode(led, OUTPUT); Serial.begin(9600); pinmode(in1,output); pinmode(in2,output); pinmode(in3,output); pinmode(in4,output); pinmode(ena,output); pinmode(enb,output); _mstop(); void loop() getstr=serial.read(); if(getstr=='f') _mforward(); 16

else if(getstr=='b') _mback(); delay(200); else if(getstr=='l') _mleft(); delay(200); else if(getstr=='r') _mright(); delay(200); else if(getstr=='s') _mstop(); else if(getstr=='a') statechange(); Upload the program to the UNO control board, switch on the power supply of the vehicle and put it on the ground. Open the mobile APP, and set up parameters as follows. 17

18

19

20

21

22

Voila, now we can control the car by Bluetooth and play with it. 23