Adapt code to use with BlueTooth HC-05 module

Hello everyone...

[color=#202124]This piece of code belongs to the code 
to control a balancing robot. In this case, it is written to be 
controlled with a nunchuck. My idea is to adapt it for a 
BlueTooth module. Could you tell me how to modify it? 
Thank you very much[/color]
//Main program loop
void loop(){
  if(Serial.available()){                                                   //If there is serial data available
    received_byte =;                                          //Load the received serial data in the received_byte variable
    receive_counter = 0;                                                    //Reset the receive_counter variable
  if(receive_counter <= 25)receive_counter ++;                              //The received byte will be valid for 25 program loops (100 milliseconds)
  else received_byte = 0x00;                                                //After 100 milliseconds the received byte is deleted
  //Load the battery voltage to the battery_voltage variable.
  //85 is the voltage compensation for the diode.
  //Resistor voltage divider => (3.3k + 3.3k)/2.2k = 2.5
  //12.5V equals ~5V @ Analog 0.
  //12.5V equals 1023 analogRead(0).
  //1250 / 1023 = 1.222.
  //The variable battery_voltage holds 1050 if the battery voltage is 10.5V.
  //battery_voltage = (analogRead(0) * 1.222) + 85;
  //if(battery_voltage < 1050 && battery_voltage > 800){                      //If batteryvoltage is below 10.5V and higher than 8.0V
  //  digitalWrite(13, HIGH);                                                 //Turn on the led if battery voltage is to low
  // low_bat = 1;                                                            //Set the low_bat variable to 1
 // }

Balancing_robot.ino (24.7 KB)

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.