The final build of my work with HC-05 involves using AVR ATmega32 microcontroller which is a powerful micro controller. The Controller is programmed in AVR GCC.
For HC-05 (or any other serial communication system), the USART needs to be set on the ATmega32 through programming.
Here is a snippet of code being used for UART in my build:
The Primary task of responding to various commands is done by a switch statement which is way easier to modify and work on instead of IF-ELSE statements.Since Each character has a unique ASCII Code, we have a lot of commands which can be given to the micro controller.For example ,there are 26 lower case + 26 upper case + 10 digits + about 32 symbols which equal about 94 unique commands.
Snippet of code for Switch:
The character 'ch' is set to receive value from registers whenever the receive interrupt is triggered by the HC-05.The ISR (Interrupt Service Routine) is defined as follows:
Simulation of code is done in Proteus 8.4 using all the peripherals included. Input here is given from a virtual terminal however HC-05 would have served the same objective.
A video accompanying the simulation conveys that the code works fine and can be implemented into the hardware.Here's the vid :
Used:
Proteus 8.4
Atmel Studio 7.0
For HC-05 (or any other serial communication system), the USART needs to be set on the ATmega32 through programming.
Here is a snippet of code being used for UART in my build:
Setting up UART |
The Primary task of responding to various commands is done by a switch statement which is way easier to modify and work on instead of IF-ELSE statements.Since Each character has a unique ASCII Code, we have a lot of commands which can be given to the micro controller.For example ,there are 26 lower case + 26 upper case + 10 digits + about 32 symbols which equal about 94 unique commands.
Snippet of code for Switch:
Decision Task by Switch Statement |
The character 'ch' is set to receive value from registers whenever the receive interrupt is triggered by the HC-05.The ISR (Interrupt Service Routine) is defined as follows:
Interrupt Service Routine |
Simulation of code is done in Proteus 8.4 using all the peripherals included. Input here is given from a virtual terminal however HC-05 would have served the same objective.
Simulation in Proteus |
A video accompanying the simulation conveys that the code works fine and can be implemented into the hardware.Here's the vid :
Used:
Proteus 8.4
Atmel Studio 7.0