i'm a Arduino newbie working on a school project
I'm working with Arduino Uno and a HC-05 Bluetooth module. Trying to test out the Bluetooth communication both receiving and sending. The set up seems to be right, but when confirming the data received from Serial.read() with a serial monitor (I use putty), it is showing some weird symbol. Please help me.
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
Serial.println("Hello.");
Serial.println();
delay(5000); //delay 5 secs
}
// the loop routine runs over and over again forever:
void loop() {
// read the inputs on analog pin 0 and pin 1:
int sensorValue1 = analogRead(A0);
int sensorValue2 = analogRead(A1);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage1 = sensorValue1 * (5.0 / 1023.0);
float voltage2 = sensorValue2 * (5.0 / 1023.0);
// print out the value from analog pin 0:
Serial.print("Sensor Voltage 1 = "); Serial.println(voltage1);
Serial.println();
delay(500);
if( Serial.available() ) // if data is available to read
{
// variable to receive data from the serial port
char key;
key = Serial.read();
delay(10);
// print out the character received from the serial port
Serial.print("Command Received: ");
Serial.println(key);
// print out the converted voltage value from analog pin 1
Serial.print("Sensor Voltage 2 = "); Serial.println(voltage2);
Serial.println();
if( key == 'o' ) // if 'o' was received, print message
{
Serial.println("Hello again");
Serial.println();
}
}
}