Skip to main content

Bluetooth Bot





  • Aim: To control a bot using Bluetooth.
  • Code:
#define F_CPU 8000000UL
#define BAUD RATE 9600
#include<avr/io.h>
#include<util/delay.h>

void usart_init();
void usart_transmit(char x);
char usart_recieve();


void usart_init(){
UBRRH=0;
UBRRL=51; // or 0x33
UCSRB=0x18;
UCSRC=0x86;
}

void usart_transmit(char x){
while((UCSRA&0x20)==0);
UDR=x; //data gets stored in UDR

}

char usart_recieve(){
while((UCSRA&0x80)==0);//Till it gets overflow
return UDR;
}



int main()
{

DDRC=0xFF;
PORTC=0xff;
_delay_ms(1000);
PORTC=0x00;
usart_init();
_delay_ms(2);
char a[10];
int i=0;
while(1)
{
if(usart_recieve()=='b'){
if(usart_recieve()=='a'){
if(usart_recieve()=='c'){
if(usart_recieve()=='k'){
if(usart_recieve()=='$'){
PORTC=0b00000101;
_delay_ms(100);

}}}}}


if(usart_recieve()=='r'){
if(usart_recieve()=='i'){
if(usart_recieve()=='g'){
if(usart_recieve()=='h'){
if(usart_recieve()=='t'){
if(usart_recieve()=='$'){
PORTC=0b00001000;
_delay_ms(100);
}}}}}}

if(usart_recieve()=='f'){
if(usart_recieve()=='o'){
if(usart_recieve()=='r'){
if(usart_recieve()=='w'){
if(usart_recieve()=='a'){
if(usart_recieve()=='r'){
if(usart_recieve()=='d'){
if(usart_recieve()=='$'){
PORTC=0b00001010;
_delay_ms(100);

}}}}}}}}



if(usart_recieve()=='l'){
if(usart_recieve()=='e'){
if(usart_recieve()=='f'){
if(usart_recieve()=='t'){
if(usart_recieve()=='$'){
PORTC=0b00000010;
_delay_ms(100);
}}}}}

if(usart_recieve()=='s'){
if(usart_recieve()=='t'){
if(usart_recieve()=='o'){
if(usart_recieve()=='p'){
if(usart_recieve()=='$'){
PORTC=0b00000000;

_delay_ms(100);
}}}}}


//else {
//PORTC=0b00001010;
//_delay_ms(1000);
}}

  • Hardware information: 
PortC = Motor
  • Bluetooth Module
Bluetooth Module





  •  Additional Information
1) Can be controlled using voice, control keys and any other way which could transmit the code word.
2)Needs an app or software to interface bluetooth device with micro controller.
  • Conclusion: 
Bluetooth controlled bot has been created using C programming in Avr studio software and simulation of the same in proteus software.

Comments

Popular posts from this blog

Python Ping Pong Game

Game: Ping Pong Libraries used: 1) pygame  2) Math 3) Random Version: Python 3.7 Python Code: -------------------------------------------------------------------------------------------------------------------------- import pygame import math import random pygame.init() dis=pygame.display.set_mode((600,400)) gameover=False white=(255,255,255) black=(0,0,0) red=(255,0,0) blue=(0,0,255) col=(0,255,0) x1=575 y1=200 dx1=0 dy1=0 x2=25 y2=185 dx2=1 dy2=0 c=0 t=0 font_style = pygame.font.SysFont(None, 50) def message(msg,color):     mesg = font_style.render(msg, True, color)     dis.blit(mesg, [300, 200]) font_style1 = pygame.font.SysFont(None, 30)    def show(msg,color):     mesg = font_style1.render(msg, True, color)     dis.blit(mesg, [300, 10])    clock=pygame.time.Clock() while not gameover:     for event in pygame.event.get():       ...

Kaprekar's Constant Verification

Kaprekar's Constant Kaprekar's Constant (6174) is a constant when a four digit number is taken and its digits are arraged in assending and desending order and then are subtracted. One Condition: Atleast one digit should be different. Enter a Four Digit Number: Enter

LED Matrix

Aim: To display a character or letter on a 8x8 LED matrix. Code: #define F_CPU 8000000UL #include<avr/io.h> #include<util/delay.h> int main(){ DDRC=0xFF; DDRD=0xFF; DDRB=0x00; while(1){ if(PINB==0x01){ PORTC=0x08; PORTD=0xEF; _delay_ms(100); PORTC=0x1C; PORTD=0xC7; _delay_ms(100); PORTC=0x3E; PORTD=0x83; _delay_ms(100); PORTC=0x7F; PORTD=0x01; _delay_ms(100); PORTC=0xFF; PORTD=0x00; _delay_ms(100); PORTC=0x7F; PORTD=0x01; _delay_ms(100); PORTC=0x3E; PORTD=0x83; _delay_ms(100); PORTC=0x1C; PORTD=0xC7; _delay_ms(100); PORTC=0x08; PORTD=0xEF; _delay_ms(100); } else if(PINB==0x02){ PORTC=0x02; PORTD=0xF0; _delay_ms(1); PORTC=0x04; PORTD=0xEF; _delay_ms(1); PORTC=0x08; PORTD=0xDF; _delay_ms(1); PORTC=0x10; PORTD=0xBF; _delay_ms(1); PORTC=0x20; PORTD=0xDF; _delay_ms(1); PORTC=0x40; PORTD=0xEF; _delay_ms(1); PORTC=0x80; PORTD=0xF0; _delay_ms(1); }}} Proteus Simulation: LED matrix simulatio...