import QtQuick 1.1 import com.nokia.meego 1.0 import QtMobility.connectivity 1.2 import QtMobility.sensors 1.2 Page { // You can put the physical address of the Bluetooth module connected to Arduino here. property string btAddress: "00:06:66:05:01:db" // property string btAddress: "00:06:66:05:01:9f" // property string btAddress: "00:06:66:02:d4:cd" tools: commonTools Label { id: macAddress anchors.left: parent.left anchors.leftMargin: 32 anchors.verticalCenter: parent.verticalCenter text: btAddress platformStyle: LabelStyle { fontFamily: "Nokia Pure" fontPixelSize: 32 } } Switch { id: blueSwitch anchors.left: parent.left anchors.leftMargin: 380 anchors.verticalCenter: parent.verticalCenter checked: false onCheckedChanged: { console.log("switch: " + checked) if (blueSwitch.checked == false) { blueSocket.connected = false //connect to bluetooth } else { blueSocket.connected = true //connect to bluetooth } } } BluetoothSocket { id: blueSocket connected: false service: blueService // This is defined in BluetoothService element onErrorChanged: { blueSwitch.checked = false console.log("Error: " + blueSocket.error) //Errors are printed in Application Output underneeth. } onDataAvailable: blueSocket.sendStringData(stringData) // This signal is called when Bluetooth receive new data onConnectedChanged: { blueSwitch.checked = connected console.log("Connection: " + connected) } } BluetoothService { id: blueService deviceAddress: btAddress //This is MAC address of your bluetooth module connected to Arduino serviceUuid: "00001101-0000-1000-8000-00805F9B34FB" //famous UUID for serial port serviceProtocol: "rfcomm" //rfcomm emulates RS-232 serial ports. It uses 9600 baudrate, none parity, 8 bits, 1 stop bit } RotationSensor { id: rotationSensor active: true } Timer { // property real previousAngle: -1 interval: 500; running: true; repeat: true onTriggered: { if (blueSocket.connected == true) { var angle = rotationSensor.reading.y + 90 // if (previousAngle >= 0) angle = angle - previousAngle blueSocket.sendStringData(String.fromCharCode(angle)) // previousAngle = angle console.log("y: " + angle) } } } }