I can solder! 7-Segment Serial Display & Nunchucky operational

I’ve been toying around with some electronics projects the last few months, but have been putting off the basic requirement of actually soldering anything.  I got a basic iron and misc tools around 6 weeks ago, and a couple of components that needed assembly (piggy backed on our robot order) but just hadn’t made the leap.  Until now.

I started with the 7-Segment Serial Display (Blue) (ordered from Solorbotics) which needed a few wires attached if I was going to do any prototyping with it.  From looking around it looked like I only needed to wire-up the Gnd and the Vcc connections (these were labelled on the circuit board).  After putting way too much solder on the first pin (and subsequently using my ‘solder sucker’ to clean it up) the next pin went smoother.  After looking at some example code it became clear I also needed to wire up the “Rx” connection as well.  Three wires total soldered up.  Just plugging it into the arduino made it display 4 zeros so that told me it was operational.  Update: you don’t actually have to solder these wires on… just bending them through the holes would have worked too.

These projects are still a bit obscure for me, so I wasn’t sure how to get started.  I read through the User Manual which was clear enough, but I figured there was code out there already.  I found this wall of text which I managed to digest down into this gist (and updated it thanks to these notes) which you can see running in the above video.

// example of using 7-Segment Serial Display
// product available from https://www.sparkfun.com/products/9765
// based on code from http://www.arunet.co.uk/tkboyd/ec/ec1led4x7ser.htm
// Note: solder wires at Gnd/Vcc & Rx, Rx goes to a digital pin on the arduino.
// Video available at http://www.youtube.com/watch?v=YVMAzYqV4kg
// Blogged @ https://chrisnolan.ca/2012/08/05/i-can-solder-7-segment-serial-display-nunchucky-operational/
#include <SoftwareSerial.h> // Arduino 1.0 included
#define SerInToArdu 2
#define SerOutFrmArdu 3 // pin it's plugged into
#define wDelay 300//no ; here. Sets how long each "message" appears
SoftwareSerial mySerialPort(SerInToArdu,SerOutFrmArdu);
// The above creates the serial channel we will use.
void setup(){
pinMode(SerOutFrmArdu,OUTPUT);
pinMode(SerInToArdu,INPUT);//Not actually needed...
mySerialPort.begin(9600);
mySerialPort.print("v"); //To reset display module
};
void loop(){
default_example();
scroll_word("4321");
scroll_word("87654321");
scroll_word("HELLo noLAn");
scroll_word("123456789");
mySerialPort.print("xxxx");//Send an "x" to turn a digit off
delay(wDelay);
delay(wDelay);
};
void default_example() {
mySerialPort.print("1234");
delay(wDelay);
mySerialPort.print("234x");
delay(wDelay);
mySerialPort.print("34xx");
delay(wDelay);
mySerialPort.print("4xxx");
delay(wDelay);
mySerialPort.print("xxxx");
delay(wDelay);
mySerialPort.print("----");
delay(wDelay);
mySerialPort.print("8888");
delay(wDelay);
mySerialPort.print("HEL0");
delay(wDelay);
mySerialPort.print("NoLA");
delay(wDelay);
mySerialPort.print("oLAn");
delay(wDelay);
mySerialPort.print("LAnx");
delay(wDelay);
mySerialPort.print("Anxx");
delay(wDelay);
mySerialPort.print("nxxx");
delay(wDelay);
};
void scroll_word(String w) {
int length = w.length();
if (length <= 4) {
mySerialPort.print(w);
delay(wDelay);
} else {
w = " " + w + " ";
for (int i=0; i<= length+4; i++) {
mySerialPort.print(w.substring(i,i+4));
delay(wDelay);
}
}
}
view raw gistfile1.ino hosted with ❤ by GitHub

While the ‘iron was still hot’ (ok, not really but it sounded good — I actually waited until my son was home so he could watch) I put together the next project, which was a NunChucky Wii Nunchuck I2C Breakout Adapter .  This adapter required some headers (male & female) to be soldered on (while the WiiChuck wouldn’t have).  For the first bit of soldering I used my little ‘helping hands’ gizmo for holding both the circuit board, and the wire going in, so my hands were free; this time around I just set it on the table with the header poking through and soldering it that way.  This resulted in a slightly lop sided connection.  For the 2nd header, I used my other ‘helping hands’ (i.e. my son) to so we could solder with 4 hands instead of 2.  I made a video of the NunChucky in action too (and combined with the 7-Segment display) if you’re curious.

The code for the Nunchucky is based on Tod Kurt’s library (which he based on Chad Phillips code) and you can see my mods to his demo in this gist to output the button presses to the display.  Aside: did you know a “1” is different than a ‘1’ in Arduino?

/*
* WiiChuckDemo --
*
* 2008 Tod E. Kurt, http://thingm.com/
*
* with code for 7-Segment Display added by Chris Nolan.ca
* based on https://gist.github.com/3268581
*
*/
#include <Wire.h>
#include "nunchuck_funcs.h"
#include <SoftwareSerial.h>
int loop_cnt=0;
byte accx,accy,zbut,cbut;
int ledPin = 13;
#define SerInToArdu 2
#define SerOutFrmArdu 3
#define wDelay 300
SoftwareSerial mySerialPort(SerInToArdu,SerOutFrmArdu);
String seven_seg;
void setup()
{
pinMode(SerOutFrmArdu,OUTPUT);
mySerialPort.begin(9600);
mySerialPort.print("v");
seven_seg = "x--x";
mySerialPort.print(seven_seg);
Serial.begin(19200);
nunchuck_setpowerpins();
nunchuck_init(); // send the initilization handshake
Serial.print("WiiChuckDemo ready\n");
}
void loop()
{
if( loop_cnt > 100 ) { // every 100 msecs get new data
loop_cnt = 0;
nunchuck_get_data();
accx = nunchuck_accelx(); // ranges from approx 70 - 182
accy = nunchuck_accely(); // ranges from approx 65 - 173
zbut = nunchuck_zbutton();
cbut = nunchuck_cbutton();
Serial.print("accx: "); Serial.print((byte)accx,DEC);
Serial.print("\taccy: "); Serial.print((byte)accy,DEC);
Serial.print("\tzbut: "); Serial.print((byte)zbut,DEC);
Serial.print("\tcbut: "); Serial.print((byte)cbut,DEC);
if (zbut == 0) {
seven_seg.setCharAt(0, '0');
} else {
seven_seg.setCharAt(0, '1');
};
if (cbut == 0) {
seven_seg.setCharAt(3, '0');
} else {
seven_seg.setCharAt(3, '1');
};
mySerialPort.print(seven_seg);
Serial.print("\t7Seg: "); Serial.println(seven_seg);
}
loop_cnt++;
delay(1);
}
view raw gistfile1.ino hosted with ❤ by GitHub

Next time, don’t put off til tomorrow what you can do today.

What will you make?

Have Something to Add?