We combined the gyro sensor and the Bluetooth sensor. Two Bluetooth sensors are needed because two Arduinos need to communicate with each other.
Also, one of the Bluetooth sensors must be a master and one slave. The HC-06 Bluetooth sensor is recommended because it can be set as the master and slave.
Required Library- Wire
- SoftwareSerial
Place the master of the Bluetooth sensor on the breadboard having a gyro sensor.
The color of the RGB LED changes according to the gyro value, and the color of the RGB LED on the other side via the Bluetooth communication is also changed.
Depending on the gyro value, the two RGB LED colors change normally.
Code Explanation- Measure Gyro Values - Refer to the above site
- Bluetooth Communication
SoftwareSerial name(RX, TX);
Declares the RX pins and TX pins for use with the name and Bluetooth communications.
Example:
SoftwareSerial btSerial(7, 8);
Set the name to btSerial, Bluetooth TX = Arduino D7 pins (RX), Bluetooth RX = Arduino D8 pins (TX).
btSerial.begin(9600);
Set serial communication speed for Bluetooth.
Bluetooth Master
btSerial.write('A');
Transmits letter A.
Bluetooth Slave
byte data;
Declares a variable called data.
data = btSerial.read();
Saves the read character to the data.
Comments
Please log in or sign up to comment.