Fabrication industrielle
Internet des objets industriel | Matériaux industriels | Entretien et réparation d'équipement | Programmation industrielle |
home  MfgRobots >> Fabrication industrielle >  >> Manufacturing Technology >> Processus de fabrication

Contrôler une LED par Bluetooth avec Arduino et MIT App Inventor

Matériel

Câblage HC-05 → Arduino

HC-05ArduinoNote
VCC5 VBreakout tolère 5 V
GNDGND
TXDRX (D0)Direct (3,3 V → 5 V OK)
RXDTX (D1)Via diviseur 1 kΩ / 2 kΩ vers GND

Important : Débranchez TX/RX pendant le téléversement du sketch.

Code Arduino

const int LED_PIN = 5;
char btCmd;

void setup() {
  Serial.begin(9600);     // Communication avec HC-05
  pinMode(LED_PIN, OUTPUT);
}

void loop() {
  while (Serial.available() > 0) {
    btCmd = Serial.read();
    Serial.print(btCmd);  // Echo pour debug
    Serial.println();

    if (btCmd == '1') digitalWrite(LED_PIN, HIGH);
    else if (btCmd == '0') digitalWrite(LED_PIN, LOW);
    delay(15);
  }
}

Application Android (MIT App Inventor)

  1. Créez un projet sur appinventor.mit.edu.
  2. Composants : ListPicker (connexion BT), 2 Button (ON/OFF), BluetoothClient.
  3. Blocs :
    — ListPicker.BeforePicking → éléments = adresses/noms trouvés par BluetoothClient.
    — ListPicker.AfterPicking → BluetoothClient.Connect(adresse).
    — Button_ON.Click → BluetoothClient.SendText("1").
    — Button_OFF.Click → BluetoothClient.SendText("0").
  4. Testez avec l'appli « MIT AI2 Companion » (QR code).

Astuces & pièges

Évolutions possibles

Remplacez la LED par un relais, un driver moteur, une bande LED RGB… Le principe reste identique : l'appli envoie un caractère, l'Arduino agit en conséquence.

Processus de fabrication

  1. Panneau de contrôle Arduino Nano pour Flight Simulator 2020 – Affichage LCD et CDI
  2. Panneau commutateurs et LED pour Microsoft Flight Simulator 2020 basé sur Arduino
  3. Construire une Tirelire Intelligente : Contrôler un Accepteur de Pièces avec Arduino Nano
  4. Contrôler 2 moteurs pas-à-pas avec Arduino Nano et joystick – Tutoriel Visuino
  5. Construire un robot quadrupède Arduino intelligent : guide étape par étape
  6. Appareils électroménagers à commande vocale : contrôle Bluetooth avec Google Assistant
  7. Contrôler une LED Arduino avec Cortana via Bluetooth sur Windows 10
  8. Maîtriser une matrice LED 8×8 avec Arduino Uno : Guide pas à pas
  9. Contrôle de ventilateur PWM 4 broches 25 kHz avec Arduino Uno – Construction, code et test