Greetings everyone,
I recently bought a Seeed Bluetooth Shield V2 for a school project.
I've to make a digital clock that incorporates the Arduino. The Arduino is being used to generate a clock pulse for the bcd counters (so i can change the time from a distance trough a terminal on my phone). For some reason my code doesn't seem to work. I'm not so experienced, but i would like to learn more about what's wrong with my code .
In total there needs to be 2 outputs, 1 for changing the hours and 1 for changing the minutes.
Trough clicking "1" in the terminal the Arduino has to give a short pulse for the hours side, clicking "2" for the minutes side. On the terminal i want to see this change( "println" )
Also when i try to change the bluetooth name. It'll always stay as "HMsoft".
#include <SoftwareSerial.h>
#define RxD 7
#define TxD 6
#define Uur 2
#define Min 3
#define DEBUG_ENABLED 1
SoftwareSerial blueToothSerial(RxD, TxD);
void setup()
{
Serial.begin(9600);
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
pinMode(Uur, OUTPUT);
pinMode(Min, OUTPUT);
setupBlueToothConnection();
}
char terminalRead;
void loop()
{
while (1) //loop forever
{
if (blueToothSerial.available())
{
terminalRead = blueToothSerial.read();
Serial.print(terminalRead);
}
if (terminalRead == '1')
{
digitalWrite(Uur, HIGH);
delay(20);
digitalWrite(Uur, LOW);
Serial.println("Hour Forward");
}
if (terminalRead == '2')
{
digitalWrite(Min, HIGH);
delay(20);
digitalWrite(Min, LOW);
Serial.println("Minute Forward");
}
}
}
void setupBlueToothConnection()
{
blueToothSerial.begin(9600);
blueToothSerial.print("AT");
delay(400);
blueToothSerial.print("AT+DEFAULT"); // Restore all setup value to factory setup
delay(2000);
blueToothSerial.print("AT+NAMESeeedBTSlave"); // set the bluetooth name as "SeeedBTSlave" ,the length of bluetooth name must less than 12 characters.
delay(400);
blueToothSerial.print("AT+PIN0000"); // set the pair code to connect
delay(400);
blueToothSerial.print("AT+AUTH1"); //
delay(400);
blueToothSerial.flush();
}
Clockpulses.ino (1.52 KB)