How to program for a shield?

Hello, once again fellow Arduino people. I have an Arduino Duemilanove, and I have written / explored some sketches for the device, and I feel I have a basic understanding of how things work, but recently I acquired a Kegboard shield. Now this shield is open source, and the source code for the Arduino which utilizes this shield can be found here -> GitHub - Kegbot/kegboard: Kegbot's Arduino Kegerator controller, a flexible multi-function board. Firmware, schematics, Python library. Flow sensing, DS1820 temperature sensing, relay control, ID-12 RFID, and buzzer support. Now the problem lies, with the fact that I am planning on using different hardware from which this shield was intended for, but that doesn't mean that it can't be used, I am just curious if there are any good sources for writing sketches for shields. For example I know there is a simple sketch that blinks one of the LEDs on the Arduino. This shield has several LEDs and I wouldn't mind making them blink, and gradually implementing more code. And before you ask, yes I have looked the source code for the Kegboard on github, and I understand some of it, but not all of it. Basically I would just like to make one of the LEDs light up on the shield, and work my way up from there. If anyone here thinks they could help let me know.

All a shield really does is bring out the Arduino pins to connect to whatever hardware is on it. So if you can work out what pin the LED is connected to, then it should be easy to make it blink.

There seem to be four versions of the kegboard hardware:

kegboard-coaster
kegboard-coaster-alt
kegboard-mega
kegboard-mini

Which version do you have?

I looked at the schematic for the "kegboard-coaster" and the only LED it had was the power LED. The only active component was a OneWire temperature sensor.

johnwasser:
There seem to be four versions of the kegboard hardware:

kegboard-coaster
kegboard-coaster-alt
kegboard-mega
kegboard-mini

Which version do you have?

I looked at the schematic for the "kegboard-coaster" and the only LED it had was the power LED. The only active component was a OneWire temperature sensor.

well I know the kegboard-coaster is the ethernet adapter that connects the flow sensor to the Arduino, so I know that's not it. It looks like this,

The kegboard shield looks like this,

BTW, where did you find the mention of the kegboard-coaster on the github page?

ipatch:
BTW, where did you find the mention of the kegboard-coaster on the github page?

Under "hw" (hardware).

So I found the schematic for the shield I have, it is the kegboard-mini, and the schematic can be found here -> https://github.com/Kegbot/kegboard/blob/master/hw/kegboard-mini/kegboard-mini-board.pdf?raw=true

Now after reading / looking at the schematic I am assuming I would apply a high voltage to the LED to see it light up, but no dice so far. Am I looking at this thing the wrong way?

My Arduino sketch looks like the following,

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
  
  This example code is in the public domain.
*/

// pin D2 - should be connected to the flow_A LED

// give it a name

int led = 2;

// the setup routine runs once when you press reset:

void setup() {
  //initialize the digital pin as an output.
  pinMode(led, OUTPUT);
}

// the loop routine run over and over again forever:

void loop() {
  digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for one second
  digitalWrite(led, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}

ipatch:
So I found the schematic for the shield I have, it is the kegboard-mini, and the schematic can be found here -> https://github.com/Kegbot/kegboard/blob/master/hw/kegboard-mini/kegboard-mini-board.pdf?raw=true

That's not the schematic. That's a couple layers of the board layout showing component outlines. That schematic shows how the components are wired together:

The schematic shows Arduino Pin 2 (D2) going to "FLOW-A" which has a 2.2K pull-up resistor an is then connected to pin 6 of the two RJ connectors. To control the FLOW_A LED you have to use Pin 4 (D4) instead.

johnwasser:

ipatch:
So I found the schematic for the shield I have, it is the kegboard-mini, and the schematic can be found here -> https://github.com/Kegbot/kegboard/blob/master/hw/kegboard-mini/kegboard-mini-board.pdf?raw=true

That's not the schematic. That's a couple layers of the board layout showing component outlines. That schematic shows how the components are wired together:

kegboard/kegboard-mini-schematic.pdf at master · Kegbot/kegboard · GitHub

The schematic shows Arduino Pin 2 (D2) going to "FLOW-A" which has a 2.2K pull-up resistor an is then connected to pin 6 of the two RJ connectors. To control the FLOW_A LED you have to use Pin 4 (D4) instead.

WOW MAN, how did you figure out it was D4? I now have a blinking piece of circuitry :smiley:

Also you wouldn't know what I would need to do (sketchwise) open / close Relay A would you?

The schematic shows "RELAY_A" connected to Arduino pin A0.

const int RELAY_A = A0;
void setup() {pinMode(RELAY_A, OUTPUT);}
void loop() {
    digitalWrite(RELAY_A, HIGH); // Turn on Relay A
    delay(1000);
    digitalWrite(RELAY_A, LOW); // Turn off Relay A
    delay(1000);
}

ipatch:
WOW MAN, how did you figure out it was D4? I now have a blinking piece of circuitry :smiley:

I'm not going to show you how to figure out D4 - instead, I'll answer how to figure out how Relay A is connected first...

ipatch:
Also you wouldn't know what I would need to do (sketchwise) open / close Relay A would you?

You really need to learn how to read schematics if you hope to be able to get anywhere in the future. So - let's start here:

First - look at the schematic for Relay A - it's at the top of the page, toward the right (sector F5 on the schematic). Let's look at that circuit a bit: There are a couple of 5 volt power inputs (at the top), and a couple of lines grounded (at the bottom) - this is actually a pretty standard layout for a schematic; where power "enters" from the top, and "exits" at the bottom. There's a few resistors (R1, R5, and R6), an LED, a diode, a relay, and a transistor (Q1). I won't go into what they all do, but you can see that the line marked "RELAY A", connected to R5, leads to Q1 (an NPN transistor), which - when the line goes high, will turn on the relay.

So what is the line marked "RELAY A"? Well - look for it on the schematic! All that is, is a label, meaning that somewhere else on the schematic there is a part (or multiple parts, perhaps) marked "RELAY A" - and they are all connected. This is done to make the schematic easier to read, generally. You see it a lot in large and complex schematics; this schematic isn't overly complex (compared to some I've seen, that is) - but even so, it is nice that the designer has laid it out this way; it's much easier on the eyes, and quicker to see how things are hooked up.

So - if you look around, where else do you find the label "RELAY A"?

Well - I only see it at one spot - and that is connected to an Arduino pin, via the shield connectors. Where is this shown on the schematic? Well - in the upper left-hand corner (sector A5). In this case, the designer has chosen to represent the shield as an IC (which is why it has a designation of U2 - in schematics, parts have labels and names, and typically you'll see resistors as R# - like R1, R2, Rn, etc - and diodes start with D; transistors start with Q, jumpers are sometimes marked with "J", test points as "TP", and integrated circuits "U" - just keep that in mind); the only reason the designer likely did this is because in most schematic layout software, there isn't anything like a "shield" diagram. The designer could have easily used something like a header part - but since this was a shield that already has headers, that might've made things more confusing...

So - anyhow - you know where the shield is represented - so what about "RELAY A"? Well - there it is! Right at the top-left - which is connected to A0 of the Arduino! Simple, once you know how to read a schematic!

So - now can you figure out D4? Can you trace it back to the LED? What about the other LEDs? Or the other relays? Or the other parts?

Good luck - hope this helps you understand!