Arduino 101 Blynk and BLE Example Panel

Arduino 101 Blynk and BLE Example Panel © GPL3+

An example of Blynk app linking the mobile to the Arduino 101 using Bluetooth Low Energy BLE.

  • 1,222 views
  • 0 comments
  • 5 respects

Components and supplies

Apps and online services

About this project

The idea was to do a panel in my mobile using Blynk app to read values from the Arduino via the BLE link, and vice versa. The following picture is of the panel layout. For more details, read the ino file; there are comments.

Code

CODEArduino
This code is a demostration of how to use Blynk BLE (BloueTooth Low Energy of the Arduino 101) to read and write values on the Mobile Blynk APP
/**************************************************************
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 *
 * This example shows how to use Arduino 101 CurieBLE
 * to connect your project to Blynk.
 *
 * Note: This requires CurieBLE library
 *   from http://librarymanager/all#CurieBLE
 *
 * NOTE: BLE support is in beta!
 *
 **************************************************************/

//#define BLYNK_USE_DIRECT_CONNECT

#define BLYNK_PRINT Serial

#include <BlynkSimpleCurieBLE.h>
#include <CurieBLE.h>

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

BLEPeripheral  blePeripheral;

 //Configuration of the widges used at the Blynk panel in the mobile
    WidgetLED led_D(V0); // Moving Forward
    WidgetLED led_R(V1); // Moving To right
    WidgetLED led_L(V2); // Moving To left
    WidgetLED led_B(V3); // Moving Backward
void setup() {
  Serial.begin(9600);
  delay(1000);
  pinMode(13,OUTPUT);
  blePeripheral.setLocalName("Blynk");
  blePeripheral.setDeviceName("Blynk");
  blePeripheral.setAppearance(384);
  Blynk.begin(blePeripheral, auth);
  blePeripheral.begin();
  digitalWrite(13, HIGH);
  

  Serial.println("Waiting for connections...");
}
/**************************************************************

 * You can receive x and y coords for joystick movement within App.

 *

 * App dashboard setup:

 *   Two Axis Joystick on V10 in MERGE output mode.

 *   MERGE mode means device will receive both x and y within 1 message

 *

 **************************************************************/
BLYNK_WRITE(V10){
    int valueX = param[0].asInt(); // Get the value from the Joystick X value
    int valueY = param[1].asInt(); // Get the value from the Joystick Y value
    Serial.print("X = ");Serial.print(valueX);Serial.print("; Y = ");Serial.println(valueY);
    Blynk.virtualWrite(V9,valueX);Blynk.virtualWrite(V4,valueY);
    digitalWrite(13, LOW);
    delay(50);
    digitalWrite(13, HIGH);
    delay(50);
    digitalWrite(13, LOW);
    delay(50);
    digitalWrite(13, HIGH);
    delay(50);
}

void loop() {
  Blynk.run();
  blePeripheral.poll();
  test();
}

void test()
{
  Blynk.syncVirtual(V10); //Requests to update this virtual pin
  led_D.setValue(255);
  delay(100);
   led_R.setValue(255);
  delay(10);
   led_B.setValue(255);
  delay(10);
   led_L.setValue(255);
  delay(10);
   led_D.setValue(0);
  delay(10);
   led_R.setValue(0);
  delay(10);
   led_B.setValue(0);
  delay(10);
   led_L.setValue(0);
  delay(10);
  for (int a=0;a<=255;a=a+25){
    Blynk.virtualWrite(V5,a);
    Blynk.virtualWrite(V6,a);
  }
}

Comments

Similar projects you might like

Arduino/Genuino 101 BLE Thermometer With TMP102 and Blynk

Project tutorial by Konstantin Dimitrov

  • 8,174 views
  • 1 comment
  • 26 respects

Intel Arduino 101 BLE Blynk Tank

Project tutorial by Johnathan Hottell

  • 10,707 views
  • 6 comments
  • 42 respects

Arduino 101 Blynk Bluetooth Tutorial

by Noah Huber-Feely

  • 9,380 views
  • 11 comments
  • 11 respects

Arduino 101 BLE RGB Lamp

Project tutorial by Gustavo Reynaga

  • 1,977 views
  • 2 comments
  • 10 respects

BLE Robot Using Blynk & Arduino

Project tutorial by Tom Moxon

  • 2,439 views
  • 0 comments
  • 13 respects
Add projectSign up / Login