Arduino program for the pocket watch b
alexhsiaochung
Posts: 4
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
}
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
[COLOR=#000000][FONT=Times New Roman]input 10'communication FROM Pocket Watch B[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]output 11'communication TO Pocket Watch B[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]input 12 'ALARMmonitoring pin[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]'Declare variables[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]ss var byte 'seconds[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]mm var byte 'minutes[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]hh var byte 'hours[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]dd var byte 'days[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]mo var byte 'months[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]yl var byte 'years low[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]yh var byte 'years high[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]HIGH 11 'ensure no spurious start bit[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]PAUSE 1000[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]SetTimeCommand: 'setto 6:30:00AM, June 3, 1997[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]SEROUT11,84,[$55,$00,$00,$1E,$06,$03,$06,$61][/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]ReadTimeCommand: 'seewhat time it is presently[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]SEROUT11,188,[$55,$02][/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]SERIN10,188,5000,[ss,mm,hh,dd,mo,yl][/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]DEBUG "Time: ",dec2 hh,":",dec2 mm,":",dec2 ss," ",dec2mo,"/",dec2 dd,"/19",dec2 yl, cr[/FONT][/COLOR] [U][I][B][COLOR=#000000][FONT=Times New Roman]Arduino program[/FONT][/COLOR][/B][/I][/U] [COLOR=#000000][FONT=Times New Roman]#include<SoftwareSerial.h>[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] SoftwareSerial mySerial(10, 11); // RX, TX[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]//Declarevariables[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]int ss; //seconds[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]int mm; //minutes[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]int hh; //hours[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]int dd; //days[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]int mo; //months[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]int yl; //yearslow[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]int yh; //yearshigh[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]void setup()[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] {[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] Serial.begin(9600);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] pinMode(10,INPUT);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] pinMode(11,OUTPUT);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] pinMode(12,INPUT);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] }[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]void loop()[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] {[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] digitalWrite(11,HIGH);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] delay(1000);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] mySerial.print(95,HEX);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] mySerial.print(00,HEX);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] mySerial.print(00,HEX);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] mySerial.print(30,HEX);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] mySerial.print(06,HEX);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] mySerial.print(03,HEX);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] mySerial.print(06,HEX);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] mySerial.print(97,HEX);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] // delay(1000);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] mySerial.print(95,HEX);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] mySerial.print(02,HEX);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] if (mySerial.available()>0)[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] {[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] ss=mySerial.read();[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] mm=mySerial.read();[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] hh=mySerial.read();[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] dd=mySerial.read();[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] mo=mySerial.read();[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] yl=mySerial.read();[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] }[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] Serial.print(hh);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] Serial.print(mm);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] Serial.print(ss);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman]Serial.print(yl);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] Serial.print(mo);[/FONT][/COLOR] [COLOR=#000000][FONT=Times New Roman] Serial.print(dy);[/FONT][/COLOR]
}
Comments
Part of your problem may be that the values that you're transmitting to the Pocket Watch B are not the same as the values given in the Stamp program. $55 for example is 85 when written in decimal and that's what is sent to the Pocket Watch B by the Stamp program. I think that mySerial.print($55,HEX) sends the two characters "5" and "5". Study carefully the description of the SEROUT statement for the Stamp and the .print statement for the Arduino.
$ is PBASIC notation for a HEX number.
In Arduino/C a hex number has a different notation - 0x
So, the equivalents for those noted above are: 0x55, 0x00, 0x00, 0x1e, 0x06, 0x03, 0x06, 0x61