blynkkk / blynk-sketch-generator

This repository is for generating Blynk sketches.
https://examples.blynk.cc
MIT License
25 stars 25 forks source link

SerialBLE.begin(9600) not declare??? #98

Closed wani00 closed 1 year ago

wani00 commented 3 years ago

why my coding cannot compile because of [ SerialBLE.begin(9600) ] not declare??? i use this coding, but cannot compile:

define BLYNK_PRINT Serial

include

SoftwareSerial SwSerial(10, 11); // RX, TX

include

// You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "G7_TJoL9xY2yPkyYEbUVqAqHRvVfYZ34"; int fsrPin = 2; // the FSR and cap are connected to pin2 int fsrReading; // the digital reading

// Attach virtual serial terminal to Virtual Pin V1 WidgetTerminal terminal(V1);

// You can send commands from Terminal to your hardware. Just use // the same Virtual Pin as your Terminal Widget BLYNK_WRITE(V1) {

// if you type "Marco" into Terminal Widget - it will respond: "Polo:" if (String("Marco") == param.asStr()) { terminal.println("You said: 'Marco'") ; terminal.println("I said: 'Polo'") ; } else {

// Send it back
terminal.print("You said:");
terminal.write(param.getBuffer(), param.getLength());
terminal.println();

}

// Ensure everything is sent terminal.flush(); }

void setup() { // Debug console Serial.begin(9600);

SerialBLE.begin(9600); Blynk.begin(SerialBLE, auth);

Serial.println("Waiting for connections...");

// Clear the terminal content terminal.clear();

// This will print Blynk Software version to the Terminal Widget when // your hardware gets connected to Blynk Server terminal.println(F("Blynk v" BLYNK_VERSION ": Device started")); terminal.println(F("-------------")); terminal.println(F("Type 'Marco' and get a reply, or type")); terminal.println(F("anything else and get it printed back.")); terminal.flush(); }

void loop() { fsrReading = RCtime(fsrPin);

if (fsrReading == 30000) { // if we got 30000 that means we 'timed out' Serial.println("Nothing connected!"); } else { Serial.print("RCtime reading = "); Serial.println(fsrReading); // the raw analog reading

// Do a little processing to keep the LED blinking
fsrReading /= 10;
// The more you press, the faster it blinks!
digitalWrite(ledPin, HIGH);
delay(fsrReading);
digitalWrite(ledPin, LOW);
delay(fsrReading);

} delay(100); }

// Uses a digital pin to measure a resistor (like an FSR or photocell!) // We do this by having the resistor feed current into a capacitor and // counting how long it takes to get to Vcc/2 (for most arduinos, thats 2.5V) int RCtime(int RCpin) { int reading = 0; // start with 0

// set the pin to an output and pull to LOW (ground) pinMode(RCpin, OUTPUT); digitalWrite(RCpin, LOW);

// Now set the pin to an input and... pinMode(RCpin, INPUT); while (digitalRead(RCpin) == LOW) { // count how long it takes to rise up to HIGH reading++; // increment to keep track of time

if (reading == 30000) {
  // if we got this far, the resistance is so high
  // its likely that nothing is connected! 
  break;           // leave the loop
}

} // OK either we maxed out at 30000 or hopefully got a reading, return the count

return reading; Blynk.run(); }

Mo535hemmed commented 3 years ago

I have same problem [ SerialBLE.begin(9600) ] not declare i take this example from blynk https://examples.blynk.cc/?board=Arduino%20Uno&shield=HC05%20or%20HC06&example=Widgets%2FLCD%2FLCD_SimpleModePushing

define BLYNK_PRINT Serial

include

SoftwareSerial SwSerial(10, 11); // RX, TX

include

// You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "YourAuthToken";

BlynkTimer timer;

void sendSeconds() { Blynk.virtualWrite(V0, millis() / 1000); }

void sendMillis() { Blynk.virtualWrite(V1, millis()); }

void setup() { // Debug console Serial.begin(9600);

SerialBLE.begin(9600); Blynk.begin(SerialBLE, auth);

Serial.println("Waiting for connections...");

// Setup a function to be called every second timer.setInterval(1000L, sendSeconds); // Setup a function to be called every second timer.setInterval(1000L, sendMillis); }

void loop() { Blynk.run(); timer.run(); }

GeorgeMpouk commented 2 years ago

SoftwareSerial SerialBLE(10, 11); // RX, TX This is the solution for serialBLE not declared, its from another reported issue here https://github.com/blynkkk/blynk-sketch-generator/issues/95#issuecomment-648577276

vshymanskyy commented 1 year ago

BLE is currently not supported in Blynk 2.0