I have a pocket watch b
I try to write a arduino program for thePocket watch b
I modified the bs2 sample to rebuild thearduino program
But the modified program could not work
Bs2 sample Code:
input 10'communication FROM Pocket Watch B
output 11'communication TO Pocket Watch B
input 12 'ALARMmonitoring pin
'Declare variables
ss var byte 'seconds
mm var byte 'minutes
hh var byte 'hours
dd var byte 'days
mo var byte 'months
yl var byte 'years low
yh var byte 'years high
HIGH 11 'ensure no spurious start bit
PAUSE 1000
SetTimeCommand: 'setto 6:30:00AM, June 3, 1997
SEROUT11,84,[$55,$00,$00,$1E,$06,$03,$06,$61]
ReadTimeCommand: 'seewhat time it is presently
SEROUT11,188,[$55,$02]
SERIN10,188,5000,[ss,mm,hh,dd,mo,yl]
DEBUG "Time: ",dec2 hh,":",dec2 mm,":",dec2 ss," ",dec2mo,"/",dec2 dd,"/19",dec2 yl, cr
Arduino program
#include<SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
//Declarevariables
int ss; //seconds
int mm; //minutes
int hh; //hours
int dd; //days
int mo; //months
int yl; //yearslow
int yh; //yearshigh
void setup()
{
Serial.begin(9600);
pinMode(10,INPUT);
pinMode(11,OUTPUT);
pinMode(12,INPUT);
}
void loop()
{
digitalWrite(11,HIGH);
delay(1000);
mySerial.print(95,HEX);
mySerial.print(00,HEX);
mySerial.print(00,HEX);
mySerial.print(30,HEX);
mySerial.print(06,HEX);
mySerial.print(03,HEX);
mySerial.print(06,HEX);
mySerial.print(97,HEX);
// delay(1000);
mySerial.print(95,HEX);
mySerial.print(02,HEX);
if (mySerial.available()>0)
{
ss=mySerial.read();
mm=mySerial.read();
hh=mySerial.read();
dd=mySerial.read();
mo=mySerial.read();
yl=mySerial.read();
}
Serial.print(hh);
Serial.print(mm);
Serial.print(ss);
Serial.print(yl);
Serial.print(mo);
Serial.print(dy);
}