E15B Laboratory 1
Some Soldering and Some Software

In this lab you will be putting together a PCB (printed circuit board). "Solder" is pronounced "sodder".

Add function that randomly lights RGB LED, and have circuit determine which ones are lit

Some Soldering: Put together your PCB.

Start by turning on the soldering iron and waiting for it to warm up. Be very careful, as the tip gets near 700 °F (370 °C). To solder effectively, the tip of the iron should be shiny, if it is dull (like the image below --- I mean that the tip of the soldering iron is dull, not the content of the image), dip the tip in activator (i.e., tip cleaner), and then clean by repeatedly dipping in brass "sponge." The soldering process is much more difficult with a dirty tip. You may have to repeat the cleaning process a couple times during the course of the construction of your board..

 

Get a blank PCB and three 1kΩ resistors (the stripes on the resistors should read, in order, brown-black-red-gold).

Insert the resistors at the location labelled R3, R4 and R5. Insert from the "component" side (the side with the writing - the writing is called the "silk screen"), and spread the leads out on the other side to keep the resistors from falling out.

Solder all six leads. If you have never soldered before, read up on circuit construction techniques, and ask Ed Jaoudi or me to demonstrate for you. If you have soldered, make sure to give others in the group a chance to learn. After the leads are soldered, use diagonal cutters to trim them close to the board.

After the three 1kΩ resistors are connected, solder in two 10kΩ potentiometers at the locations labeled R1 and R2.

**Important** - the RGB (Red Green Blue) LED (Light Emitting Diode) in this step needs to be inserted with a particular orientation of it will not work, and it is very hard to remove. So... get the orientation right (talk to me if you are unclear). Insert the RGB LED (note the polarity on this element (labeled L1) - the plastic body of the LED has a flat part on one side that lines up with the flat side on the silk screen pattern on the board - this flat side can be seen in the image above, at the top of the LED). This is the trickiest part to solder because of the small spacing between the pins, so if somebody in your group has soldering experience, you might want to leave it to him/her).

You should also solder the 3-pin headers (see below). These are a little tricky because you can't bend the leads. Instead, insert the component and hold it in with a finger on one of the end pins. Turn the board over and solder the pin on the opposite end. Try to ensure that the pins are perpendicular to the board as the solder cools (about 10 seconds). Then solder the other pins. You can also hold the component to the board with tape if you are uncomfortable with soldering so close to your fingers.

Solder the power connector. It should look like the images below. It takes a little longer to heat up this component because of its (relatively) large size.

      

The soldering is complete, you just need to attach your processor board. Attach 12 screws to the board with nuts, as shown below. Leave the nuts just a little loose because the screws may need to move a small amount to align with the holes in your processor board.

        

Fit the screws through the board (you can use the location of the USB port for orientation).

IMPORTANT: Use a screw driver to tighten each of the screws as you keep the nut, which is now between the two boards, from spinning by gently squeezing the boards together. If you don't do this, you are likely to get a bad electrical connection between the two boards.

The last step is to add 12 nuts on top of the processor board and gently tighten them with a nut driver.

When you are done and you look at the side of the board you should see (from bottom to top):

 

Note: there are two levels of nuts, so the green pcb and the circuit playground don't physically touch each other.

Now add rubber feet to the bottom.

Tada!

If you are interested, the schematic for the circuit you just created is here.

Some Software.

Installing the software

The first time you use the Circuit Playground you need to install some software.

Start the Arduino IDE (Integrated Development Environment) program. Connect the Circuit Playground to a USB port on the computer.

In the Arduino IDE, under the File → Preferences… Additional Boards Manager URLs should be:
https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
Click OK, then restart Arduino IDE

Go to Tools→Board...→Boards manager, search for adafruit when "Adafruit AVR Boards" appears, click on it and click "Install" (v 1.4.9). Go to the Tools→Board menu and "Adafruit Circuit Playground" should be at the bottom of the list

Go to Sketch→Include Library menu then "Manage Library..." then search for "circuit"
Click on "Adafruit Circuit Playground" then click "Install" (v 1.6.2)
Restart Arduino IDE

Some Software: Let's write some code.

Start the Arduino IDE and set the board to "Adafruit Circuit Playground."

Now set the serial port to whichever port lists the Circuit Playground. In the image below, it is COM4, yours may well be different.

 

Blinky

If you have taken a programming course before, you have probably encountered the "Hello, world," program that does nothing but display the text "Hello, world." It is a trivial test that makes sure everything is working properly. The equivalent for an embedded processor is to blink an LED

The line with "#define" simply defines a constant; you can think of it of an editor searching for "myLED" and replacing it with "13". Any text that follows "//" is considered a comment and is there to clarify the code for human readers. Comments are ignored by the processor.

Code for blinky.ino. All you really need to know is that the code within braces {} after setup() runs once. The code after loop() runs repeatedly (i.e., in a loop).

Now, change

#define myLED 13

to

#define myLED 10

Rerun the code and see what happens. Repeat with the pin number set to 9. Once more (this time with feeling) with the pin number set to 1.

Fill in the tablein the section "To turn in".

More lights

Run the code for spectrum.ino. Add comments that demonstrate that you understand the code. In particular, add a block comment at the top that shows the sequence describing which lights are on and off at each step. The comments should be at a level that anybody in the class could look at it and understand it.

"Hello, world."

The Arduino is also capable of doing the "Hello, world." program. Run the program hello.ino. You will have to open the serial monitor to see the text displayed; you can do this by going to Tools→Serial Monitor. Make sure the baud rate (lower right corner) is set to 9600.

Simple Sensing

So far we have only used the Arduino for output, but it can also be used with sensors. The simplest one is a pushbutton (there are pushbuttons on pin 4 and pin 19; they are labeled on the board). Run the code switchSense.ino. switchSense.ino. Look at the resulting code on the serial monitor.

Make sure you understand how it works.

Now remove the "/*" and "*/" around the block quote (so the program includes the lines that were previously commented out).

Colors

Now adapt the code from spectrum.ino so that it not only sets the LED's on and off but also senses and displays the states of the three LED's (on or off) and also prints what the resulting color should be (RGB colors - check the first "basic colors" on the "RGB Color Table"). All three states, and the color, should be displayed on a single line.

To turn in:

Turn in to moodle as a single pdf. Any program code should be printed in a monospace font. The three sections should be in order and clearly labeled.

Blinky:

Fill in the table below and include it with your report.

What does pin 10 control?  
What does pin 1 control?  
What does pin 9 control?  
What does the "delay()" function do?  

 

Spectrum:

Add comments that demonstrate that you understand the code. In particular, add a block comment at the top that shows the sequence describing which lights are on and off at each step. The comments should be at a level that anybody in the class could look at it and understand it.

Colors:

Include well commented code. Also cut and paste 8 lines from the serial monitor (i.e., displaying each of the 8 colors) into your report.