Configuring the Accelerometer widget

The Accelerometer widget only works with virtual pins. The widget takes readings from the built-in accelerometer in your smartphone and sends them as an array to the Raspberry Pi. This mode is known as merge mode. You can access the elements of the received array to get the accelerometer readings for three axes:

BLYNK_WRITE(V1) {

//acceleration force applied to axis x

int x = param[0].asFloat();

//acceleration force applied to axis y

int y = param[1].asFloat();

//acceleration force applied to axis y

int z = param[2].asFloat();

}

These steps will show you how to configure the Accelerometer widget with virtual pin V1:

  1. In the canvas view, tap the Accelerometer widget. You will get the Accelerometer Settings page.
  2. Under OUTPUT, tap PIN. In the Select pin list, scroll down and choose Virtual, followed by V1, and tap OK.

 

  1. Under WRITE INTERVAL, from the drop-down list, choose 100 ms (Figure 6.3):
Figure 6.3: Selecting a write interval for the virtual pin
  1. After you have done all the configuration, tap the back arrow on the toolbar to go to the canvas. Now, your Accelerometer widget should look like this (Figure 6.4):
Figure 6.4: Accelerometer widget after configuration
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.26.246