Progress Bar

Skip to main content

Jaycar
...

Coding Shield Project

Coding Shield Project

Difficulty
TEST & TOOLS

Summary

The Coding Shield Project is inspired by the ThinkerShield, which has been developed by the Museum of Applied Arts and Sciences as a tool for teaching coding. The ThinkerShield is even used in a unit of work for Year 7 and 8 students called ‘Crack the Code’. However you might use it, the Coding Shield is a board that allows students to learn software coding without having to worry about the hardware.

Being a project, there’s still some construction needed, but it’s a project that an older sibling or relative can build for a younger person, or would even make a great assignment for an electrotechnology class, with the finished Coding Shields available to a coding class.

The Coding Shield gives you six LED’s, a piezo transducer, a pushbutton, an LDR and a potentiometer all wired into an Arduino Prototyping Shield. The Coding Shield can then be pushed onto an Arduino main board and used for coding without having to worry about wiring things up.

Materials Required

1Duinotech UNO r3 Main BoardXC4410
1Duinotech Arduino Compatible Prototyping ShieldXC4482
7Green 3mm LED 40mcd Round DiffusedZD0120
14.2kHz Audio TransducerAB3440
11.4mm SPST Micro Tactile SwitchSP0601
1Large Light Dependent Resistor (LDR)RD3485
110k Ohm Linear (B) Single Gang 9mm PotentiometerRP8510
1470 Ohm 0.5 Watt Metal Film Resistors - Pack of 8RR0564
11k Ohm 0.5 Watt Metal Film Resistors - Pack of 8RR0572
110k Ohm 0.5 Watt Metal Film Resistors - Pack of 8RR0596

To help guide you in assembling the Coding Shield, it helps to know what everything will connect to. Here is an overview:

Pin

Component

Notes

D3

Piezo Transducer

Negative terminal to GND

D7

Switch

D7 is held low by a 10K Ohm resistor to ground, and connected to 5V when switch is pressed.

D8

LED

Cathode to GND via 470 Ohm resistor.

D9

LED

Cathode to GND via 470 Ohm resistor.

D10

LED

Cathode to GND via 470 Ohm resistor.

D11

LED

Cathode to GND via 470 Ohm resistor.

D12

LED

Cathode to GND via 470 Ohm resistor.

D13

LED

Cathode to GND via 470 Ohm resistor.

A4

LDR

LDR sits between 5V and A4 creating a voltage divider with a 1 kOhm resistor between A4 and GND.

A5

Potentiometer

Set up as a voltage divider between 5V and GND with wiper connected to A5.

5V

Power LED

Cathode to GND via 470 Ohm resistor.

The above guide is also useful for when you are writing sketches as well, as you know what pins correspond to what functions on the board.

To help build some of the ‘links’ on the Coding Shield, we use the legs of the components, so be careful not to cut the legs except where noted. It’s possible to solder them on afterwards, but it’s usually easier to not cut them.

Start by getting out the LED’s, and solder onto the Prototyping Shield as shown, making sure that the cathodes (short leg with flat on body) is furthest from the digital pin side (facing the bottom of the board). The power LED at bottom left has the cathode to the left. The leftmost top LED is in the top left hole.

Solder the legs in place, then bend the anodes (closest to the top) over and solder them to D8-D13, then trim.

Take six of the 470 Ohm resistors, and bend one leg by 180 degrees:

Take six of the 470 Ohm resistors, and bend one leg by 180 degrees

Then insert them in the holes directly below the top LED’s, and solder in place. Take a seventh resistor, and wire it between the power LED and GND as shown. Both legs can be trimmed on the power LED resistor.

Before trimming the other resistors, bend and join the leg closest to the LED, and then bend and join the other legs until they form a continuous wire that connects to GND.

The next components to install are the Tactile Switch, LDR and 1k Ohm resistor. As for the others, solder in place, but do not trim the legs right away.

The first thing to do on the other side is to run the bottom-most leg of the LDR to the IOREF pin, and the topmost leg to A4. For the resistor, run one leg to the GND bus made up of the LED legs, and connect the other leg to the LDR leg that goes to A4. This means that we have a voltage divider between IOREF and GND feeding its output into A4.

Using an offcut of resistor leg (as we have below) or a piece of wire, link one corner of the tactile switch to pin D7, and the opposite corner to the wire connecting to IOREF.

The potentiometer is next, bend the legs downwards so that they protrude below its body.

Then mount the potentiometer on the board, making sure that the legs are to the left. We’re going to connect the bottom-most pin to the IOREF wire, so try to line this up if possible. You can also take one of the 10kOhm resistor, and connect it between D7 and GND above the LED’s. This ensures that the input of D7 is held low and doesn’t float.

On the reverse of the board, solder the bottom-most pin to IOREF, then run a wire from the middle pin to A5, and from the top pin to GND (we used a resistor leg for this).

The last solder step is the piezo transducer, which has its red lead connected to D3, and its black lead connected to GND. The leads are quite long, so you might like to trim them before soldering. We used super glue to affix the transducer into the position seen below, but you might want to leave this until you’ve tested the board.

To start testing, connect the Coding Shield to an Uno (it should work with any other Arduino compatible board too), and connect the Uno to power. The power LED should light up and the leftmost D13 LED will flicker and go off. Apart from that, you won’t see much. We’ve developed a test sketch that will test all the features of the shield.

You can either copy and paste the code from the end of this document, or find it in the attached resource file. Like any other sketch, the correct board is selected from the Tools menu, the serial port is selected, and then the sketch is uploaded. To check the output, open the Serial Monitor at 115200 baud.

The sketch uses some defines to give the pins friendly names- this is not necessary, but can make it easier to write the sketch. The code cycles through the six LED’s and then sounds a tone, and at the same time displays the input statuses on the Serial Monitor. If the LED’s flash out of order, or something else doesn’t seem to respond to input as it should, then you might have a wiring error. The easiest way to trace is to following the wiring of the individual component that doesn’t seem to be doing the right thing.

There are some great project guides and even some sample code available on the MAAS website, check out the ‘FREE DOWNLOADS AND RESOURCES’ section of this page: maas.museum/learn/thinkershield

#define LED1 (13)
#define LED2 (12)
#define LED3 (11)
#define LED4 (10)
#define LED5 (9)
#define LED6 (8)
#define BUZZER (3)
#define BUTTON (7)
#define LDR (A4)
#define POT (A5)

void setup() {
  Serial.begin(115200);
  pinMode(LED1,OUTPUT);
  pinMode(LED2,OUTPUT);
  pinMode(LED3,OUTPUT);
  pinMode(LED4,OUTPUT);
  pinMode(LED5,OUTPUT);
  pinMode(LED6,OUTPUT);
  pinMode(BUZZER,OUTPUT);
}

void loop() {
  for(int i=0;i<7;i++){
    digitalWrite(LED1,LOW);
    digitalWrite(LED2,LOW);
    digitalWrite(LED3,LOW);
    digitalWrite(LED4,LOW);
    digitalWrite(LED5,LOW);
    digitalWrite(LED6,LOW);
    switch(i){
      case 0:digitalWrite(LED1,HIGH);break;
      case 1:digitalWrite(LED2,HIGH);break;
      case 2:digitalWrite(LED3,HIGH);break;
      case 3:digitalWrite(LED4,HIGH);break;
      case 4:digitalWrite(LED5,HIGH);break;
      case 5:digitalWrite(LED6,HIGH);break;
      case 6:tone(BUZZER,500,100);break;
    }
    Serial.print("TEST:");
    Serial.print(i);    
    Serial.print(" LDR:");
    Serial.print(analogRead(LDR));
    Serial.print(" POT:");
    Serial.print(analogRead(POT));
    Serial.print(" BUTTON:");
    Serial.println(digitalRead(BUTTON));
    delay(500);
  }
}

Similar projects you may be interested in

TEST & TOOLS
How to extend HDMI signals to a different room
Difficulty

Installing and Setting Up the XC0440 Weather Station
TEST & TOOLS
Installing and Setting Up The XC0440 Weather Station
Difficulty

TEST & TOOLS
Lithium Battery USB Charger - Powering your Arduino Project
Difficulty

TEST & TOOLS
Personal Weather Station
Difficulty