I run an Arduino Pro Mini on ATMega328 3.3V 8MHz, that transmits analog data to App Inventor, and I am unable to transmit data over Bluetooth at 8MHz frequency. When the Pro Mini runs at 16MHz, it does not have this issue.
What is the issue running at a slower frequency, and how can I make Bluetooth run on 8MHz frequency on Pro Mini?
The Arduino code is down below:
#include <SoftwareSerial.h>
#include <Wire.h>
SoftwareSerial BT(10, 11);
byte value;
unsigned long pmillis_bt = 0;
void setup() {
Serial.begin(9600);
BT.begin(9600);
}
///////////////////main///////////////////
void loop () {
if (millis() - pmillis_bt >= 100) { //this function replaces the delay function
byte Data[3];
byte cmmd[20];
int insize;
char str[256];
int i = analogRead(A0); //the value to be read and sent via bluetooth
value = BT.read();
Data[0] = 'a';
Data[1] = i / 256;
Data[2] = i % 256;
sprintf(str, "%d", i, Data[0], Data[1], Data[2]);
Serial.println(str);
if (value == 49) {
for (int j = 0; j < 3; j++)
BT.write(Data[j]);
value = 0;
}
pmillis_bt = millis();
}
}