The code works as-is when connected to an Espruino with an HC-05 module attached.
// This program sends data via Bluetooth
#include <SoftwareSerial.h> // Import the Arduino serial library
SoftwareSerial mySerial(0, 1); // RX, TX
// Declare variables
int A0val;
// Setup code here, runs once
void setup() {
// Initialize serial communications at 9600 bps
mySerial.begin(9600);
mySerial.println("Bluetooth On...");
pinMode(A0, INPUT);
}
// Main code, loops forever
void loop() {
// Constantly output analog values
A0val = analogRead(A0);
mySerial.println(A0val);
// Wait 2 milliseconds before the next loop
delay(2);
}
int pinA[ ] = { analogRead(A0), analogRead(A1), analogRead(A2), analogRead(A3) };
Serial.println(pinA[0,1,2,3]);
String jsonStr = "[" + String(pinA[0]) + "," + String(pinA[1]) + "," + String(pinA[2]) + "," + String(pinA[3]) + "]"; //a chance of working
Serial.println(jsonStr);
String jsonStr = "[";
jsonStr += String(pinA[0] + ",");
jsonStr += String(pinA[1] + ",");
jsonStr += String(pinA[2] + ",");
jsonStr += String(pinA[3] + "]");
String data = String(analogRead(A0))+","+String(analogRead(A1))+","+String(analogRead(A2))+","+String(analogRead(A3)); // Removed [ ] brackets
mySerial.println(data);
function bt_OnReceive(data) {
A = data.split(",");
console.log(A[0]);
}