Tuesday, April 7, 2015

20140626 Some more websites to check out on BCD, Binary, the DS1307 Clock, and the DF Robot LCD shield

20140626 Some more websites to check out on BCD, Binary,  the DS1307 Clock, and the DF Robot LCD shield
Just a few sites that have useful information, mostly I didn’t use these sites to build the sketches so I didn’t included them with the documents below, but they site have some good info, and a couple of neat projects.
Arduino Powered Binary Clock:
I went a different way with building my clock, but the information he has on BCD is still really good. (Step 2)  

LCD KeyPad Shield for Arduino (DF Robot LCD shield):
This is the wiki entry for the LCD shield, and while it’s a different revision number, if you look close it’s really the same shield we have, they did add a few more VCC/VDD and Grounds, and added headers to the open holes on ours, The PIN OUT of the board is the same, and the information contained in the wiki is good for our boards.

DS1307-RealTime Clock Brick:
General information about the DS1307, it’s not the same board that we have, and I didn’t really use the information from this site to make my sketches, but the info seems right, and it is using the same library I used.
AdaFruits Information on the DS1307 Realtime Clock:
Same as above more information about the DS1307, I didn’t use this, but Ada Fruit is usually pretty good about the tutorials. This is a different breakout board then what we have, but it is closer. And uses the same library.

At one point I needed to separator the “tens digit from the ones digit” wasn't sure how to go about doing that, and came across this:
after I read it, the rest was easy.

Some really good information about the BCD Thumbwheel switches, I was going to do a whole document just for these, but what I could say, would just be a repeat of what is on this site, so it gets to be here, but there is some great information on how to use these:
I did however modify the code - as I added a 2nd thumbwheel (for the 10s digit) and a +/- (2 digit binary switch), He also had the code setupt to use a  LCD display, which I removed and just decided to use the serial terminal for demo reasons. Here’s my modified code, everything else on the site was very helpful.

#define q1 8
#define q2 9
#define q4 10
#define q8 11
#define b1 2
#define b2 3
#define d1 4 //10th 8
#define d2 5 //10th 4
#define d3 6 //10th 2
#define d4 7 //10th 1

void setup()
{
Serial.begin(9600);
pinMode(q1, INPUT); // thumbwheel '1'
pinMode(q2, INPUT); // thumbwheel '2'
pinMode(q4, INPUT); // thumbwheel '4'
pinMode(q8, INPUT); // thumbwheel '8'
pinMode(b1, INPUT);
pinMode(b2, INPUT);
pinMode(d1, INPUT);
pinMode(d2, INPUT);
pinMode(d3, INPUT);
pinMode(d4, INPUT);
}


int readSwitch()
{
int total=0;
if (digitalRead(q1)==HIGH) { total+=1; }
if (digitalRead(q2)==HIGH) { total+=2; }
if (digitalRead(q4)==HIGH) { total+=4; }
if (digitalRead(q8)==HIGH) { total+=8; }
return total;
}

int readSwitch10()
{
int total=0;
if (digitalRead(d4)==HIGH) { total+=1; }
if (digitalRead(d3)==HIGH) { total+=2; }
if (digitalRead(d2)==HIGH) { total+=4; }
if (digitalRead(d1)==HIGH) { total+=8; }
return total;
}


int readPlus()
{
   int total = 0;
   if (digitalRead(b1)==HIGH) {total = 1;}
   if (digitalRead(b2)==HIGH) {total = 0;}
   return total;
}

void loop()
{
if (readPlus() == 1) {Serial.print("-");} else {Serial.print("+");}
Serial.print(readSwitch10());
Serial.println(readSwitch()); // sends switch value to serial monitor box

}

No comments:

Post a Comment