Arduino
The arduino chip is use to drive the many types of applications
If we connect the radio module so we can operates the application wireless
Radio Module
These are a series of low-cost 2.4 GHz Radio modules that are all based on the Nordic Semiconductor nRF24L01+ chip.
(Details) The Nordic nRF24L01+ integrates a complete 2.4GHz RF transceiver, RF synthesizer, and baseband logic including the Enhanced ShockBurst™ hardware protocol accelerator supporting a high-speed SPI interface for the application controller. The low-power short-range (50-200 feet or so)Transceiver is available on a board with Arduino interface and built-in Antenna for less than $3! There is also a high-power version (right).nRF24L01 Modules (Left to Right)
- With built-in Antenna
- Base module with voltage regulator and bypass capacitors for stability
- With added Transmit Power Amplifier, Low Noise Receiver Preamplifier, External Antenna
Gesture control
Accelerometers can measure acceleration in 2 dimensional or 3 dimensional space. They are called 2D and 3D accelerometers respectively. Accelerometers have certain range, i.e. the maximum acceleration they can measure. It is specified in terms of g. ‘g’ is the acceleration due to gravity of earth and it is equal to 9.80665m/s2. Common accelerometers can have a range of 1.5g to 6g. It is obvious that 1.5g accelerometer is more precise than 6g. So use 1.5g where more accuracy is needed while use 6g for much more harsh experiments. Renault R26 can pick up 100km/hr is about 1.7 sec! Even this beast don’t give more acceleration that 1.6g, so a 6g sensor can be used for much harsh experiments. A high g roller coaster can give a g-force of about 3.5 to 6.3g (source Wikipedia)
One interesting fact about accelerometer is that they always measure acceleration relative to the earths gravity. That means if it is NOT at all accelerating, like being placed on table or held in hand, it will show an acceleration along the direction of earths gravitational field. And when it free falls (that means actually accelerating due to g) it will show a 0 acceleration.
This fact is used to sense tilt of device by using simple trigonometry.
To control the arduino robo using sensor , first burn the program
onst int ap1 = A5;
const int ap2 = A4;
const int ap3 = A3;
int m11=8;
int m12=9;
int m21=10;
int m22=11;
int sv1 = 0;
int ov1 = 0;
int sv2 = 0;
int ov2= 0;
int sv3 = 0;
int ov3= 0;
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
pinMode(m11,OUTPUT);
pinMode(m12,OUTPUT);
pinMode(m21,OUTPUT);
pinMode(m22,OUTPUT);
}
void loop() {
analogReference(EXTERNAL); //connect 3.3v to AREF
// read the analog in value:
sv1 = analogRead(ap1);
// map it to the range of the analog out:
ov1 = map(sv1, 0, 1023, 0, 255);
// change the analog out value:
delay(2);
//
sv2 = analogRead(ap2);
ov2 = map(sv2, 0, 1023, 0, 255);
//
delay(2);
//
sv3 = analogRead(ap3);
ov3 = map(sv3, 0, 1023, 0, 255);
// print the results to the serial monitor:
if (sv1<=405 && sv3>490)
{
digitalWrite(m11,HIGH);
digitalWrite(m12,LOW);
digitalWrite(m21,HIGH);
digitalWrite(m22,HIGH);
Serial.println("LEFT " );
}
if(sv1>=558 && sv2<500)
{
Serial.println("Right" );
digitalWrite(m11,HIGH);
digitalWrite(m12,HIGH);
digitalWrite(m21,HIGH);
digitalWrite(m22,LOW);
}
if(sv2>=570 && sv1<=490)
{
Serial.println("Forward" );
digitalWrite(m11,HIGH);
digitalWrite(m12,LOW);
digitalWrite(m21,HIGH);
digitalWrite(m22,LOW);
}
if(sv2>=430 && sv2<=490 )
{
Serial.println("Backward" );
digitalWrite(m11,LOW);
digitalWrite(m12,HIGH);
digitalWrite(m21,LOW);
digitalWrite(m22,HIGH);
}
if(sv2>=470 && sv2>=470 && sv3>=570 )
{
Serial.println("STOP" );
digitalWrite(m11,LOW);
digitalWrite(m12,LOW);
digitalWrite(m21,LOW);
digitalWrite(m22,LOW);
}
}
int r_mtr_n = 8; // assign motor pins to arduino
int r_mtr_p = 9;
int l_mtr_p = 10;
int l_mtr_n = 11;
int incomingByte = 0; // assign pin for bluetooth module
int l=13;
void setup()
{
pinMode(r_mtr_n, OUTPUT);
pinMode(l,OUTPUT);
pinMode(r_mtr_p, OUTPUT);
pinMode(l_mtr_p, OUTPUT);
pinMode(l_mtr_n, OUTPUT);
digitalWrite(r_mtr_n, LOW);
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.begin(9600);
Serial.println("start");
}
void loop()
{
if (Serial.available() > 0) {
incomingByte = Serial.read();
}
switch(incomingByte)
{
case 'S':
digitalWrite(r_mtr_n, LOW); // control for stop
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.println("Stop\n");
incomingByte='*';
break;
case 'R':
digitalWrite(r_mtr_n, HIGH); // control for right
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, HIGH);
digitalWrite(l_mtr_n, LOW);
Serial.println("right\n");
incomingByte='*';
break;
case 'L':
digitalWrite(r_mtr_n, LOW); // control for left
digitalWrite(r_mtr_p, HIGH);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, HIGH);
Serial.println("left\n");
incomingByte='*';
break;
case 'F':
digitalWrite(r_mtr_n, HIGH); // control for forward
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, HIGH);
Serial.println("forward\n");
incomingByte='*';
break;
case 'B':
digitalWrite(r_mtr_n, LOW); // control for backward
digitalWrite(r_mtr_p, HIGH);
digitalWrite(l_mtr_p, HIGH);
digitalWrite(l_mtr_n, LOW);
Serial.println("backwards\n");
incomingByte='*';
break;
case 'x':
digitalWrite(r_mtr_n, LOW); // control for stop
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.println("Stop\n");
incomingByte='*';
break;
case 'd':
digitalWrite(r_mtr_n, HIGH); // control for right
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, HIGH);
digitalWrite(l_mtr_n, LOW);
Serial.println("right\n");
incomingByte='*';
break;
case 'a':
digitalWrite(r_mtr_n, LOW); // control for left
digitalWrite(r_mtr_p, HIGH);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, HIGH);
Serial.println("left\n");
incomingByte='*';
break;
case 'w':
digitalWrite(r_mtr_n, HIGH); // control for forward
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, HIGH);
Serial.println("forward\n");
digitalWrite(l,HIGH);
incomingByte='*';
break;
case 's':
digitalWrite(r_mtr_n, LOW); // control for backward
digitalWrite(r_mtr_p, HIGH);
digitalWrite(l_mtr_p, HIGH);
digitalWrite(l_mtr_n, LOW);
Serial.println("backwards\n");
incomingByte='*';
break;
delay(5000);
}
}
To control robo using bluetooth module
Bluetooth [WikiPedia] is a wireless technology standard for exchanging data over short distances (using short-wavelength UHF radio waves in the ISM band from 2.4 to 2.485 GHz) from fixed and mobile devices, and building personal area networks (PANs). Range is approximately 10 Meters (30 feet).
These modules are based on the Cambridge Silicon Radio BC417 2.4 GHz BlueTooth Radio chip. This is a complex chip which uses an external 8 Mbit flash memory. If you like LOTS of details see the: [Data Sheet].
These low-cost Bluetooth Sub-modules work well with Arduino and other Microcomputers. IMPORTANT Definitions:
HC-05 :
(Available HERE)
Sections of the BT Board (Above):
The module has two modes of operation, Command Mode where we can send AT commands to it and Data Mode where it transmits and receives data to another bluetooth module.
The default mode is DATA Mode, and this is the default configuration, that may work fine for many applications:
Commands are sent to the module in UPPERCASE and are terminated with a CR/LF pair.
Enter these commands in order:
BlueTooth-HC05-Modules-How-To
(arduino bluetooth tutorial)Bluetooth [WikiPedia] is a wireless technology standard for exchanging data over short distances (using short-wavelength UHF radio waves in the ISM band from 2.4 to 2.485 GHz) from fixed and mobile devices, and building personal area networks (PANs). Range is approximately 10 Meters (30 feet).
These modules are based on the Cambridge Silicon Radio BC417 2.4 GHz BlueTooth Radio chip. This is a complex chip which uses an external 8 Mbit flash memory. If you like LOTS of details see the: [Data Sheet].
These low-cost Bluetooth Sub-modules work well with Arduino and other Microcomputers. IMPORTANT Definitions:
- HC-05 is a more capable module that can be set to be either Master or Slave (Available HERE)
- HC-06 is a Slave only device. (It looks physically just like the HC-05).(Note: Now HC-06 not cheaper)
- These small ( 3 cm long) modules run on 3.3V power with 3.3V signal levels, They have no pins and usually solder to a larger board. (See example below)
- The module has two modes of operation, Command Mode where we can send AT commands to it and Data Mode where it transmits and receives data to another bluetooth module.
- "Breakout" Boards that make these easy to use are available and recommended. These mount the sub-module like that shown on the right on a slightly larger board. NOTE: Sellers often label them "HC-05" or "HC-06", but they have some other model number on the reverse side. Most of these boards support operation at 5V power and interface to 5V Arduino signal levels with some technique of level shifting. A typical "breakout" board is shown below:
HC-05 :
The Keyes / YourDuino BT Board
(Available HERE)
Sections of the BT Board (Above):
- The Green HC-05 sub-module is soldered on top of the Blue BT Board
- The HC-05 module includes the Radio and Memory chips, 26 MHz crystal, antenna and RF matching network.
- The right section of the BT Board has connection pins for power and signals as well as a 5V to 3.3V Regulator, LED, and level shifting.
HC-05 PinOut (Right) :
- KEY: If brought HIGH before power is applied, forces AT Command Setup Mode. LED blinks slowly (2 seconds)
- VCC: +5 Power
- GND: System / Arduino Ground
- TXD: Transmit Serial Data from HC-05 to Arduino Serial Receive. NOTE: 3.3V HIGH level: OK for Arduino
- RXD: Receive Serial Data from Arduino Serial Transmit
- STATE: Tells if connected or not
BlueToothCommandUtility: (LINK) Arduino Sketch to send and receive Command Mode AT commands to HC-05 to change configuration.
COMMAND and DATA TRANSFER MODES:
The module has two modes of operation, Command Mode where we can send AT commands to it and Data Mode where it transmits and receives data to another bluetooth module.
The default mode is DATA Mode, and this is the default configuration, that may work fine for many applications:
- Baud Rate: 9600 bps, Data : 8 bits, Stop Bits: 1 bit, Parity : None, Handshake: None
- Passkey: 1234
- Device Name: HC-05
- Connect the KEY pin high before applying power to the module. This will put the module into command mode at 38400 baud. This is commonly used, and needed if you don't know the baud rate the module is set to. You can use the BlueToothCommandUtility (LINK) for this.
- Apply power to the module then pull the KEY pin high. This will enter command mode at the currently configured baud rate. This is useful if you want to send AT commands from a microcontroller as the KEY pin can be controlled from one of the microcontroller pins. BUT you need to know the currently configured Baud Rate.
Commands are sent to the module in UPPERCASE and are terminated with a CR/LF pair.
Command Mode Commands:
The format of commands is:- Always starts with "AT"
- Then "+" followed by <ParameterName>
- Then either:
- ? (returns current value of parameter)
- = (New Value of parameter)
- AT (AT Test command. Should respond with OK)
- AT+VERSION? (show the firmware version)
- AT+UART=9600,0,0 (Set baud rate to 9600, 1 stop bit, no parity)
Bluetooth Master Mode:
To configure the module as Bluetooth Master and to pair with another bluetooth module follow these steps. First we need to put the module into command mode as above by pulling the CMD pin high before power on. (Use the BlueToothCommandUtility (LINK) for this.)Enter these commands in order:
- AT+RMAAD Clear any paired devices
- AT+ROLE=1 Set mode to Master
- AT+RESET After changing role, reset is required
- AT+CMODE=0 Allow connection to any address (I have been told this is wrong and CMODE=1 sets "any address"
- AT+INQM=0,5,5 Inquire mode - Standard, stop after 5 devices found or after 5 seconds
- AT+PSWD=1234 Set PIN. Should be same as slave device
- AT+INIT Start Serial Port Profile (SPP) ( If Error(17) returned - ignore as profile already loaded)
- AT+INQ Start searching for devices
control the robo using android click here
int state;
int flag=0;
void stp();
void fwd();
void left();
void right();
void back();
void setup()
{
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
Serial.begin(9600);
}
void loop()
{
if(Serial.available()>0)
{
state=Serial.read();
Serial.println(state);
flag=0;
}
if (state=='1')
{
stp();
if(flag==0)
{
Serial.println("stop");
flag=1;
}
}
else if (state=='2')
{
fwd();
if(flag==0)
{
Serial.println("Forward");
flag=1;
}
}
else if (state=='3')
{
back();
if(flag==0)
{
Serial.println("Backward");
flag=1;
}
}
else if (state=='4')
{
left();
if(flag==0)
{
Serial.println("Left");
flag=1;
}
}
else if (state=='5')
{
right();
if(flag==0)
{
Serial.println("Right");
flag=1;
}
}
}
void fwd()
{
digitalWrite(7,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,LOW);
digitalWrite(8,LOW);
}
void back()
{
digitalWrite(7,LOW);
digitalWrite(5,LOW);
digitalWrite(6,HIGH);
digitalWrite(8,HIGH);
}
void left()
{
digitalWrite(7,HIGH);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(8,LOW);
}
void right()
{
digitalWrite(7,LOW);
digitalWrite(5,HIGH);
digitalWrite(6,LOW);
digitalWrite(8,LOW);
}
void stp()
{
digitalWrite(7,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(8,LOW);
}
No comments:
Post a Comment