As computing becomes more ubiquitous in our objects, designers need to be more aware of how to design meaningful interactions into electronically enhanced objects. At the University of Washington, a class of junior Interaction Design majors is exploring this question. These pages chronicle their efforts.

Friday, May 25, 2012

Shelby and Bridget, Progress Report

Just a quick progress report on our project, that involves tattletale-ing on line cutters via Twitter.

We've been playing with the code a bit more, as well as making a little progress with setting up the hardware. Thanks to the good folks at Metrix Create:Space, we realized that the way we had decided to set up our hardware was a little ridiculous. We were going to use a LED driver to make a 7-segment display, but Richard of MC:_ informed us that 7-segment drivers exist and do the work for you! Awesome! We will be using SN7447s, and we are in the process of figuring out how to wire everything.

We simplified, then modified our code to be able to count the number of tweets that are received, once the appropriate processing sketch is running. The LED in pin 13 blinks the number of tweets received; e.g., for 5 tweets received, it blinks 5 times. Here is the Arduino code for counting the number of tweets (used in conjunction with the processing sketch in the last post we made):

 void listenToSerial()
{
  int serialMsg = 0;
  if (Serial.available())
  {
    serialMsg = Serial.read();
    if (serialMsg == 1)
    {
      tweetCount++;
      for (int g=0; g<tweetCount; g++)
      {
      digitalWrite (LED13, HIGH); //LED in pin 13 blinks the number of tweets received
      delay (500);
      digitalWrite (LED13, LOW);
      delay (500);
      }
    }
  }
  else
  {
      digitalWrite (LED13, HIGH); //in the normal state (no tweets received),
                                                        // LED in pin 13 stays lighted
      delay (3000);
  }
}

Our next step (code-wise) will be to figure out how to use this code with the SN7447 drivers to create numbers. Once we have it wired, I think it will be a matter of setting the correct Arduino pins HIGH or LOW. From what we understand from the SN7447 datasheet found here, there are 4 inputs (A, B, C, and D, or specifically on the SN7447: pins 7, 1, 2, and 6), for which we use binary code to control the a-g outputs of the 7-segment display. We'll try out a few more things and keep you posted on our progress!


EDIT:
Got it to work!

We used the setup from this schematic diagram, and connected everything appropriately. We then used a slight variation on the code from this post, to test whether the setup was working properly.  Took a few tries (tweaks in the code, changes in the wiring) to get the numbers to count up correctly. We then combined the code shown above with the code from the forum post to link the counting code with the twitter-interactive code. It took a while to figure it all out, but in the end, the code is actually pretty simple:

int seven_seg_digits[10][4] = {  { 0,0,0,0 },  // = 0
                                 { 0,0,0,1 },  // = 1
                                 { 0,0,1,0 },  // = 2
                                 { 0,0,1,1 },  // = 3
                                 { 0,1,0,0 },  // = 4
                                 { 0,1,0,1 },  // = 5
                                 { 0,1,1,0 },  // = 6
                                 { 0,1,1,1 },  // = 7
                                 { 1,0,0,0 },  // = 8
                                 { 1,0,0,1 }   // = 9
                               };
int tweetCount = 0;

void setup()
{
  Serial.begin(9600);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
}

void loop()
{
  listenToSerial();
}

void listenToSerial()
{
  int serialMsg = 0;
  if (Serial.available())
  {
    serialMsg = Serial.read();
    if (serialMsg == 1)
    {
      Display();
    }
  }
}

void Display()
{
  tweetCount++;
  int ones = 0;
  int tens = 0;
  ones = tweetCount % 10;
  tens = tweetCount / 10;
  int pinOnes = 6;
  for (int disp1 = 0; disp1 < 4; disp1++)
  {
    digitalWrite(pinOnes, seven_seg_digits[ones][disp1]);
    ++ pinOnes;
  }
  int pinTens = 10;
  for (int disp10 = 0; disp10 < 4; disp10++)
  {
    digitalWrite(pinTens, seven_seg_digits[tens][disp10]);
    ++ pinTens;
  }
}


Here's a photo of the setup:

Here's a photo of it working! It is displaying the number '11', for 11 tweets received while the processing sketch was running. It doesn't yet look like it, because the output pins of the 7447 are oriented as f-g-a-b-c-d-e, and the segments are set up in this configuration. Therefore, the b and c segments of both the tens and ones (place value) are lit up to represent the number 11.



With the code working, mainly all that's left to do is to make the actual LED number display board by soldering bunch of of LEDs and resistors together (in the groupings of the a-g segments).

No comments:

Post a Comment