Posts Tagged ‘#Bluetooth’

Task:

For this task we are demand to explore with arduino components, the aim of this is to understand how electronic components work and how to code (programming).

Process:

Everytime you are about to explore new techniques and new proyects, remember to use references, it’s ok to guide yourself, in this case i look for references on www.instructables.com and also look for some videos on Youtube to understand a little bit of arduino coding.

PLUG IN STUFF

Materials:

  • Arduino Nano/ UNO
  • HM-10 Bluetooth
  • 17 jumper wires
  • Brea Board
  • 5 Mini Vibromotors

Step 1:

Plug your arduino and Bluetooth in the middle of the board , try to place them in the same line, so they have a place where these components remain steady.

*we recomend after this step you proceed with coding*

Step 2

Using a simple code you can be able to program your arduino board, with this you can have control of the in puts (information given by bluetooth) and of the out puts (vibro/motors).

Open arduino interface and write the code:

#include <Servo.h>                

int izqA = 5;

int izqB = 6;

int derA = 9;

int derB = 10;

int vel = 255;            // Speed of the motors (0-255)

int estado = ‘f’;         // start stop

void setup()  {

 Serial.begin(9600);    // starts comunication with bluetooth

 pinMode(derA, OUTPUT);

 pinMode(derB, OUTPUT);

 pinMode(izqA, OUTPUT);

 pinMode(izqB, OUTPUT);

}

void loop()  {

 if(Serial.available()>0){        // bluetooth storage

   estado = Serial.read();

 }

 if(estado==’a’){           // Front

   analogWrite(derB, vel);     

   analogWrite(izqB, 0);

   analogWrite(derA, 0);  

   analogWrite(izqA, 0);       

 }

 if(estado==’b’){          // Left

   analogWrite(derB, 0);     

   analogWrite(izqB, 0);

   analogWrite(derA, 0);  

   analogWrite(izqA, vel);      

 }

 if(estado==’c’){         // Stop

   analogWrite(derB, vel);     

   analogWrite(izqB, vel);

   analogWrite(derA, vel);    

   analogWrite(izqA, vel);

 }

 if(estado==’d’){          // Right

   analogWrite(derB, 0);     

   analogWrite(izqB, 0);

   analogWrite(izqA, 0);

   analogWrite(derA, vel);  

 }

 if(estado==’e’){          // Back

   analogWrite(derA, 0);    

   analogWrite(izqA, 0);

   analogWrite(derB, 0);  

   analogWrite(izqB, vel);      

 }

 if(estado==’f’){          // OFF

   analogWrite(derA, 0);    

   analogWrite(izqA, 0);

   analogWrite(derB, 0);  

   analogWrite(izqB, 0);      

 }

}

Step 3

After coding and compiling the program, we can start to assemble all our components, this part iis really simple:

  • select 5 pins on you arduino board (pin 5, pin, 6, pin7…) plug one wire to each of these pins
  • connect each wire (pin wires) to the positve part of the micro motors (red cable)
  • Connect different wires to the negative part of the vibro motors (blue cable) and connect them to the negative channel of the bread board.
  • Connect bluetooth to arduino, this step is kind of tricky, specially because you need to connect Bluetooth after you progam, if not you are not going to be able to compile the program. Bluetooth has four components, VCC, GND, TXD, RXD. Connections are really simple, VCC goes to 5v (arduino board), GND goes to GND, TXD goes to RXD (Arduino B.) and finally RXD goes to TXD (Arduino B).


Step 4

Download any bluetooth controler from the play store or if you want you can make your own.

Step 5

Plug in arduino to a source of power and enjoy sending vbrations.

Class : Technology

Software : Arduino IDE

Equipment : Arduino UNO Board, HC-05 Bluetooth Module, Breadboard, Jumper Wires, Fan

Challenges :
  • Making proper connections from Arduino to the components.
  • Understanding the Rx and Tx connections from Bluetooth Module to Arduino.
  • Programming the code.


Approach:

To advance with our projects here in Shukhov Lab, it was necessary for us to learn how to operate and program the Arduino boards and perform basic activities. In this project I was trying to work with an Arduino and bluetooth module setup for controlling a DC Motor (A fan in this case) using a smartphone.

  Process: First it is required to assemble all components together and make the connections.

 

I have initially connected the bluetooth module to the breadboard and made necessary connections to the arduino board using male-male jumper cables.

 

The connection for the bluetooth module are as follows:

BLUETOOTH    –           ARDUINO

Txd  –  Rx

Rxd  –  Tx

Gnd  –  Gnd

Vcc  –  3.3V

 

Next I connected the DC powered fan to the arduino and connected it with GND for the negative terminal and PIN-8 for the positive terminal.

I chose pin 8 here because I have activated it in the code using the statement (int ledpin = 8;)

The connections to the arduino board are shown on the image below:



Finally we upload the developed code to the arduino board.

*NOTE:
  • It is very important to disconnect the Rx and Tx cables from the bluetooth module before uploading the code or it might display an error.
  • Always disconnect the arduino power source before making any wiring changes to avoid short circuit.
  The code which I used can be found below:

char val;

int ledpin = 8;

void setup() {

pinMode(ledpin, OUTPUT);

Serial.begin(9600);

}

void loop() {

if( Serial.available() )

{

val = Serial.read();

}

if( val == ‘H’ )

{

digitalWrite(ledpin, HIGH);

} else {

digitalWrite(ledpin, LOW);

}

delay(100);

}



  I have also downloaded an application on my phone, from which I can send signal to the Bluetooth module.

It is necessary to download this app or a similar app. You can download one from the link below:

https://apkpure.com/arduino-bluetooth-controller/com.giumig.apps.bluetoothserialmonitor/download?from=details  

After uploading the code, I disconnected the power from arduino board connected back the Rx and Tx cables and plugged back the power source into the arduino (it can be from your notebook’s USB or via 5V power adaptor)

Next I opened my bluetooth settings in my phone and paired the device with bluetooth module HC-05.

*NOTE: 
  •  In case of password prompt, use – 1234
  •  Typing H on the bluetooth app activates signal and typing anything else switches it off.


Then open the app (arduino bluetooth controller) and select the device (HC-05) from the list of paired devices and connect with the switch or terminal modes as shown below. In my case I have used the Switch mode and set the parameters for ON button as “H” and OFF button as “X”. Otherwise you can manually use the Terminal mode.



The fan rotates on sending the signal “H” (ON) and switches off on sending signal “X” (OFF) successfully.

It is demonstrated in the video below:

   

address: 20 Myasnitskaya ulitsa
(metro stations ‘Lubyanka’ and ‘Kitay-Gorod’)
Moscow 101000 Russia

phone: +7(495)772-95-90 *15026

email: city@hse.ru