Azzera filtri
Azzera filtri

problem of developing with arduino

1 visualizzazione (ultimi 30 giorni)
Hi everybody, my name is andrea and I'm trying to create a small home automation project. I would like to command LEDs via my android smartphone via arduino one, a hc-05 bluetooth module and the use of matlab (it would be better simulink). Using an application I would like to be able to connect to the bluetooth module and to control my LEDs. I managed to do the skecth with the arduino software, but with matlab I'm having some problems. I absolutely have to develop the program on matlab, on the request of my teacher who will be present at the exam !!!! Help me guys !!

Risposta accettata

Swaroop Mishra
Swaroop Mishra il 20 Giu 2017
There is a Simulink example for the use case.
Bluetooth support is not there currently in the support packages for Arduino and Android.
If you want to do it only using MATLAB, you will need an Android app running on the Android phone. From there you can send data to MATLAB via TCP/UDP. In MATLAB, listen to the TCP/UDP messages from the Android. Based on the message received on the phone, send the command to the Arduino.
  1 Commento
Kiat Nern Yeo
Kiat Nern Yeo il 17 Giu 2019
Hello. Does this work on a private and secured network, but without any connection to the internet ? Meaning both devices, the android and arduino, are connected to the same router, but the router is not connected to the internet.
Looking forward to your reply !!
Best regards !

Accedi per commentare.

Più risposte (1)

Andrea Cosentinio
Andrea Cosentinio il 25 Giu 2017
Modificato: Andrea Cosentinio il 25 Giu 2017
#include <SoftwareSerial.h>
#define bluetooth Serial
SoftwareSerial mySerial(0, 1);
int tempPin = 0;
#include <Servo.h>
Servo Servo1;
void setup() { pinMode (tempPin, INPUT); pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); Servo1.attach (7); Servo1.write (0); //Serve ad inizializzare il servo a 0°
bluetooth.begin(9600);
mySerial.begin(9600);
delay(1000);
}
void loop() {
{
char dato= bluetooth.read();
switch(dato)
{
case 'A':
{
digitalWrite(2, HIGH);
break;
}
case 'a':
{
digitalWrite(2, LOW);
break;
}
case 'B':
{
digitalWrite(3, HIGH);
break;
}
case 'b':
{
digitalWrite(3, LOW);
break;
}
case 'C':
{
digitalWrite(4, HIGH);
break;
}
case 'c':
{
digitalWrite(4, LOW);
break;
}
case 'D':
{
digitalWrite(5, HIGH);
break;
}
case 'd':
{
digitalWrite(5, LOW);
break;
}
case 'E':
{
digitalWrite(6, HIGH);
break;
}
case 'e':
{
digitalWrite(6, LOW);
break;
}
case 'F':
{
Servo1.write (0);
delay (10);
Servo1.write (180);
delay (10);
break;
}
case 'f':{
Servo1.write (0);
break;
}
}
}
}
i found this sketch on internet and at first it was without servomotor. It was added by me after some days. Could you help me ? i have to explain the sketch at the exam and i don't know the correct meaning of all the commands, so if i can bring the simulink project instead the arduino one it would be great !

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by