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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started