I am working on a simple project where a Joystick on the Blynk app on my phone sends it's values to the Arduino and then gets printed on my LCD screen. For the most part, things are working. The app and the Arduino are connected, and the LCD screen does print data. However, the data isn't accurate and doesn't represent the joystick's movements whatsoever. Below is the Arduino Code, Terminal code, and some screenshots from the app.
Arduino Code
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(2, 3);
#define BLYNK_PRINT SwSerial
#include <BlynkSimpleSerial.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 8, 9, 7);
char auth[] = "64ff1d6e5ff646a5aff28f52de11c914";
int x = 6;
int y = 5;
unsigned long xvalue;
unsigned long yvalue;
void setup() {
SwSerial.begin(9600);
Blynk.begin(auth);
Serial.begin(9600);
lcd.begin(16, 2);
lcd.clear();
pinMode(x, INPUT);
pinMode(y, INPUT);
}
void loop() {
Blynk.run();
int xvalue = analogRead(x);
int yvalue = analogRead(y);
lcd.setCursor(0, 0);
lcd.print("X:");
lcd.print(xvalue);
lcd.setCursor(0, 1);
lcd.print("Y:");
lcd.print(yvalue);
delay(100);
}
Terminal code:
cd ./Documents/Arduino/libraries/Blynk/scripts
bash ./blynk-ser.sh
Below are some photos of the interface from my phone.
I have no idea about Blynk, but making people download and unzip files to see your photos will not get you as much help as properly posting the photos. See here posting photos
groundfungus:
I have no idea about Blynk, but making people download and unzip files to see your photos will not get you as much help as properly posting the photos. See here posting photos
I don't have an option on the app to connect the Joystick to analog pins.
The joystick on the phone app is sending some data to the Arduino. You need to figure out what it is sending.
Then what is?
Presumably, something in the Blynk instance is connecting the joystick to digital pins 5 and 6. I have no idea how a library that you didn't post a link to is working.
PaulS:
The joystick on the phone app is sending some data to the Arduino. You need to figure out what it is sending.
Presumably, something in the Blynk instance is connecting the joystick to digital pins 5 and 6. I have no idea how a library that you didn't post a link to is working.
Here is an example code for the Joystick, however that code is optimized for the Ethernet Shield, and I don't have that. I modified it to this but still no luck:
In this recent code, nothing is printed on the LCD screen.
I may found a lead though. In the Joystick settings I can only select PWM pins, and the data range is from 0-255. Does that spark any ideas on how to read it and then display it?
PaulS:
We've already agreed that that does does not make sense.
I'm not sure what should call BLYNK_WRITE(), or what the heck V1 means. But, it would appear that it is not being called.
You should be asking these questions on the Blynk forum.
I did, not a response in 6 hours... Selective hearing I guess.
V1 stands for virtual 1 which is a 'pin' in the app. But that makes no sense because I'm connecting this to PWM pins on the arduino... sigh, I guess I'll just wait for an answer on the other forum.