Question: #include / / Left Side Wheels const int motor 1 pin 1 = 2 ; const int motor 1 pin 2 = 3 ; /
#include
Left Side Wheels
const int motorpin;
const int motorpin;
RightSide Wheels
const int motorpin;
const int motorpin;
SuperSonic Sensor
const int trigPin ;
const int echoPin ;
const char deviceServiceUuid abcdef;
const char deviceServiceCharacteristicUuid abcdef;
int brake ;
intt previousCondition ;
long duration ;
int distance ;
void setup
put your setup code here, to run once:
Serial.begin;
while Serial;
if BLE.begin
Serial.printlnFailed to initialize BLE!";
while ;
TODO Setup gyro pins to INPUT
Setting motor pins for output
Serial.printlnInitializing motor pins";
pinModemotorpin OUTPUT;
pinModemotorpin OUTPUT;
pinModemotorpin OUTPUT;
pinModemotorpin OUTPUT;
Setting SSS pins for OUTPUTINPUT
pinModetrigPin OUTPUT;
pinModeechoPin INPUT;
void loop
Serial.printlnUNO Wheelchair is scanning...";
BLEDevice peripheral;
BLE.scanForUuiddeviceServiceUuid;
whileperipheral BLE.available
Uncomment if needed for debugging
Serial.printlnScanning;
delay;
BLE.stopScan;
Serial.printPeripheral found: ;
Serial.printlnperipherallocalName;
if peripheral.connect
Serial.printlnFailed to connect to Peripheral...";
return; IF THIS CAUSES PROBLEMS, USE while; instead
Serial.printlnConnected to Peripheral!";
if peripheral.discoverAttributes
Serial.printlnFailed to discover Attributes...";
peripheral.disconnect;
return;
Serial.printlnAttributes Discovered!";
BLECharacteristic conditionCharacteristic peripheral.characteristicdeviceServiceCharacteristicUuid;
if conditionCharacteristic && conditionCharacteristicproperties & BLENotify
Serial.printlnSubscribing to Condition Characteristic...";
conditionCharacteristic.subscribe;
else
Serial.printlnCondition Characteristic not found or not notifiable.";
return;
Prints the distance on the Serial Monitor
Serial.printDistance: ;
Serial.printlndistance;
Clears the trigPin
digitalWritetrigPin LOW;
delayMicroseconds;
Sets the trigPin on HIGH state for micro seconds
digitalWritetrigPin HIGH;
delayMicroseconds;
digitalWritetrigPin LOW;
Reads the echoPin, returns the sound wave travel time in microseconds
duration pulseInechoPin HIGH;
Calculating the distance
distance duration ;
while peripheralconnected
if conditionCharacteristic.valueUpdated
continue;
Getting value from Bluetooth
intt condition ;
if conditionCharacteristic.readValuecondition
Serial.printlnFailed to read condition value.";
continue;
Serial.printCondition received: ;
Serial.printlncondition;
if previousCondition
previousCondition condition;
else if previousCondition previousCondition && condition
previousCondition ;
else if previousCondition previousCondition && condition
previousCondition ;
if distance
brake ;
else if distance
brake ;
Check what to do with the value of brake
switch brake
case : CLOSE
analogWrite;
analogWrite;
break;
default:
analogWrite;
analogWrite;
break;
How can we fix the ultrasonic component so it can brake when theres an object
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
