-
-
Notifications
You must be signed in to change notification settings - Fork 4
2019_09_12_ToDoToday
Éloi Strée edited this page Sep 11, 2019
·
13 revisions
Arduino: Free All
Android Micro Controller for Android
https://youtu.be/Iyd4gX0AR54?list=PLFAQMlaJo92K0k4YKAiYOLfknGS2fe_w-
/*
* Bluetooth HC-06 (SLAVE) control from your Android phone RSB May 2016
*/
#include "Arduino.h"
#include <SoftwareSerial.h>
// Instantiate our BT object. First value is RX pin, second value TX pin
// NOTE: do NOT connect the RX directly to the Arduino unless you are using a
// 3.3v board. In all other cases connect pin 4 to a 1K2 / 2K2 resistor divider
/*
* ---- pin 6-----> |----1K2----| to HC06 RX |----2K2----| -----> GND
*
* See my video at www.youtube.com/c/RalphBacon for more details.
*/
SoftwareSerial BTserial(4, 6); // RX , TX
// Our output indicator (could drive an opto-isolated relay)
byte LEDpin = 8;
// -----------------------------------------------------------------------------------
// SET UP SET UP SET UP SET UP SET UP SET UP SET UP SET UP SET UP
// -----------------------------------------------------------------------------------
void setup() {
// LED output pin
pinMode(LEDpin, OUTPUT);
// Serial Windows stuff
Serial.begin(9600);
Serial.println("Set up complete");
// Set baud rate of HC-06 that you set up using the FTDI USB-to-Serial module
BTserial.begin(9600);
}
// -----------------------------------------------------------------------------------
// MAIN LOOP MAIN LOOP MAIN LOOP MAIN LOOP MAIN LOOP MAIN LOOP
// -----------------------------------------------------------------------------------
void loop() {
// If the HC-06 has some data (single char) for us, get it
if (BTserial.available() > 0) {
// Get the char
char data = (char) BTserial.read();
// Depending on value turn LED ON or OFF (or error message)
switch (data) {
case '1':
Serial.println("ON");
digitalWrite(LEDpin, HIGH);
BTserial.write("ON");
break;
case '0':
Serial.println("OFF");
digitalWrite(LEDpin, LOW);
BTserial.write("OFF");
break;
default:
Serial.print("NOT RECOGNISED: ");
Serial.println(data);
BTserial.print("Error!");
}
}
}// How to set the resistance ? Y>

Hey Mon Ami !
Example:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using TechTweaking.Bluetooth;
public class BasicDemo : MonoBehaviour {
private BluetoothDevice device;
public Text statusText;
// Use this for initialization
void Awake () {
BluetoothAdapter.enableBluetooth();//Force Enabling Bluetooth
device = new BluetoothDevice();
device.Name = "HC-06";
//device.MacAddress = "XX:XX:XX:XX:XX:XX";
}
public void Connect() {
statusText.text = "Status : ...";
device.connect();
}
public void Disconnect() {
device.close();
}
public void SendOn()
{
if (device != null)
{
device.send(System.Text.Encoding.ASCII.GetBytes("1\n"));
}
}
public void SendOff()
{
if (device != null)
{
device.send(System.Text.Encoding.ASCII.GetBytes("0\n"));
}
}
/* Please note that this way of reading is only used in this demo. All other demos use Coroutines(Unity offers many tutorials on Coroutines).
* Just to make things simple
*/
void Update() {
if (device.IsReading) {
byte [] msg = device.read ();
if (msg != null ) {
string content = System.Text.ASCIIEncoding.ASCII.GetString (msg);
statusText.text = "MSG : " + content;
}
}
}
}| Info | Good | Middle | Bad |
|---|---|---|---|
| AA/AAA | 1.35+ | 1.2-1.3 | 1-1.2 |
| 9V | 9 | 7.2 | 5.4 |
| 12V | 10 | 9.6 | 7.2 |
| Use 150 Ohm resitor to check the battery | |||
| Death =60% Weak 80% |
(Reminder: Don't use versioning control, Git or alternative, is a professional fault.
And you need to be crazy or stupid to not use it... With all my respect ;) )
Feel free to support my work. A donation is always welcome to enlight my day.【ツ】
https://tipeee.com/eloilab
- Oculus Light
Step in VR by praticing
Réalité Virtuelle
Base de Unity
Painting Jam
- TechnoBel 2018: Specialization VR
- TechnoBel 2017: Quick Introduction to VR
- Technifutur 2018: Unity Developer
- Technifutur 2018: Basic of Unity For Artists
- Technifutur 2019: Virtual Reality Introduciton
What am I working on ?

