Loading
Loading
IoT Lab content is currently available in Arabic only. We're working on an English version.
عرض بالعربية →How to connect your phone to Arduino via Classic Bluetooth to control a robot.
Connect Bluetooth TX to Arduino RX, and Bluetooth RX to Arduino TX. Note: RX on HC-05 operates at 3.3V so it's recommended to use a voltage divider (two resistors) for the signal from Arduino (5V).
char incomingByte;
void setup() {
Serial.begin(9600); // يفترض توصيل البلوتوث بدبابيس 0 و 1
pinMode(13, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
incomingByte = Serial.read();
if(incomingByte == '1') digitalWrite(13, HIGH);
if(incomingByte == '0') digitalWrite(13, LOW);
}
}Trying to upload new code to Arduino while Bluetooth is still connected to pins 0 and 1 (RX/TX). Arduino uses these pins to receive code from the computer and the upload will fail.