From 424e7f2bfc61065af9a9e974398ca9d64ee0efba Mon Sep 17 00:00:00 2001 From: 13035516 <13035516@student.uts.edu.au> Date: Sun, 29 Dec 2019 13:55:10 -0800 Subject: [PATCH] vibration motor func to be tested --- Configuration.h | 3 ++- SerialCommunication.cpp | 5 +++-- multisensoryarduino.ino | 8 +++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Configuration.h b/Configuration.h index bef61ee..3db189f 100644 --- a/Configuration.h +++ b/Configuration.h @@ -16,7 +16,8 @@ /* Serial Options */ #define BAUDRATE 115200 #define PING '1' -#define MOTORPING '2' +#define MOTORPING_ON '2' +#define MOTORPING_OFF '3' /* =================================== */ /* Pin layout */ diff --git a/SerialCommunication.cpp b/SerialCommunication.cpp index fc1d2fa..103a6ba 100644 --- a/SerialCommunication.cpp +++ b/SerialCommunication.cpp @@ -36,10 +36,11 @@ void SerialCommunication::Read_Update_Request() { update_request = false; } - if (serial_in == MOTORPING) { + if (serial_in == MOTORPING_ON) { motor_flag = true; - } else if (serial_in != MOTORPING) { + } else if (serial_in == MOTORPING_OFF) { motor_flag = false; + } } } diff --git a/multisensoryarduino.ino b/multisensoryarduino.ino index 51fe9d7..4bfa803 100644 --- a/multisensoryarduino.ino +++ b/multisensoryarduino.ino @@ -55,12 +55,18 @@ void loop() { if(DSwitch[1].Get_Val()) { digitalWrite(NSLEEP_PIN, HIGH); } else { - digitalwrite(NSLEEP_PIN, LOW); + digitalWrite(NSLEEP_PIN, LOW); } if (motor_flag) { VibeMotor.Drive_Motor(); vibration_output = VibeMotor.Get_Amplitude(); + Serial.println("driving motor"); + } else { + VibeMotor.Set_Amplitude(0); + VibeMotor.Drive_Motor(); + vibration_output = VibeMotor.Get_Amplitude(); + Serial.println("stopping motor"); } for (int j = 0 ; j < 3; j++) { -- GitLab