Question: Using Arduino and CH-05 Bluetooth module, modify the code to add a C switch statement. When buttons 1-9 are pressed on a cell phone app,

Using Arduino and CH-05 Bluetooth module, modify the code to add a C switch statement. When buttons 1-9 are pressed on a cell phone app, the switch statement should decode the message (i.e. b1?, b2?, etc.) and print a more complex message to the Serial Monitor (i.e. Button 1 pressed, Button 2 pressed, etc.).

The code:

#include

const byte rxPin = 0; const byte txPin = 1; SoftwareSerial BTSerial(rxPin, txPin);

void setup() { pinMode(rxPin, INPUT); pinMode(txPin, OUTPUT); Serial.begin(38400); // Usually 9600 for BT mode, although it is sometimes 38400: BTSerial.begin(9600); }

void loop() { if(BTSerial.available()) { Serial.print("Rx Byte "); Serial.print((char)BTSerial.read()); } if(Serial.available()) { BTSerial.print((char)Serial.read()); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!