I am trying to setup a joystick on the blynk app and as I move it have it show the position numbers, for now, on the serial monitor window. My code is below. I have the joystick outputting on V0 and V1 virtual pins. I get the red light on the HC-06 bluetooth module to go solid red and the app says it is online (i had paired to it earlier). So I think that side is good. It is just getting the data (position numbers) to show up in the program (com window).
My code is from the BLynk example code page with a few tweaks. I am running Blynk on a new Galaxy S8plus Android phone. Keyestudio HC-06 bluetooth module and Mega 2560 board.
Any thoughts on what I have done wrong?
Thanks
Scott
PS: I noticed in the BLynk app that there is a BLE and a Bluetooth setup. I get bluetooth to work (it connects from what I can see), but what has me perplexed is that the first library that gets added is a SerialBLE.h library. Does it work for both bluetoooth types?
I have also read many posts on the HC-06 and some talked about putting a voltage divider on the Rx pin to drop the voltage from 5v to 3.3v. I tried it both ways.
#include <BlynkSimpleSerialBLE.h>
#include <SoftwareSerial.h>
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "f43f6528c23340838ed7379fa2587f29";
SoftwareSerial SerialBLE(10, 11); // RX, TX
//SoftwareSerial SerialBLE(19, 18); // RX, TX //tried this as a alternative
BLYNK_WRITE(V1) {
int x = param[0].asInt();
int y = param[1].asInt();
// Do something with x and y
Serial.print("X = ");
Serial.print(x);
Serial.print("; Y = ");
Serial.println(y);
}
void setup()
{
// Debug console
Serial.begin(9600);
SerialBLE.begin(9600);
Blynk.begin(SerialBLE, auth);
Serial.println("Waiting for connections...");
}
void loop()
{
Blynk.run();
Serial.println(V1);
}