problem of developing with arduino

조회 수: 1 (최근 30일)
Andrea Cosentinio
Andrea Cosentinio 2017년 6월 8일
댓글: Kiat Nern Yeo 2019년 6월 17일
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 !!

채택된 답변

Swaroop Mishra
Swaroop Mishra 2017년 6월 20일
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
Kiat Nern Yeo
Kiat Nern Yeo 2019년 6월 17일
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 !

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Andrea Cosentinio
Andrea Cosentinio 2017년 6월 25일
편집: Andrea Cosentinio 2017년 6월 25일
#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 !

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by