Week 6 Update

Lots of Project Updates! 

Shopping is (sort of) complete. I bought both types of shift registers x6, the jumper wire kit, and five switches. Why only 5? Well, I ran into an issue when trying to measure the distance between each key bar on the typewriter... There is a gear under there that puts some of the bars at an angle, and even aside from that weird gap, there is no consistent measurement for the ones that are parallel to each other. It's hard to tell in the image, but most of them are slightly different distances apart. 


I hope I'm correct in assuming that this wont be a huge issue when making a custom circuit board, but when I test on the breadboard, it is going to be pretty hard to align a switch for each one of those bars. And with the switches being over a dollar each, I didn't want to spend ~$50 before knowing that they would work out, so I decided to only order 5 so that I can get a feel for the size and placement of the switches without fully committing. I know we also talked about the possibility of relying on the metal from the bar rather than using a switch to make a connection, which I thought would be more difficult at first, but now with these wonky bars I'm starting to think it might be a good backup if the switches don't fit. To be determined I guess. 

Anyways, it looks like my digikey order will be here before our next class, so I'm excited to start working on everything. I found another maker guide page that is slightly different from the one in the youtube video. It has an example called "Read 32 Switches with 3 Arduino Pins" which seems really on-par. Here's the code: 

const byte latchPin = 9;        // to latch the inputs into the registers
const byte clockPin = 13;       // I choose the SCK pin
const byte dataPin = 12;        // I choose the MISO pin
uint32_t oldOptionSwitch = 0;   // previous state of all the inputs

const int pulseWidth = 10;      // pulse width in microseconds

void setup ()
{
  Serial.begin( 115200);
  Serial.println( "Turn on and off the switches");
  Serial.println( "Top row is switch 0 (right) to switch 7 (left)");
  Serial.println( "Second row is 8 to 15, and so on");

  pinMode( clockPin, OUTPUT);   // clock signal, idle LOW
  pinMode( latchPin, OUTPUT);   // latch (copy input into registers), idle HIGH
  digitalWrite( latchPin, HIGH);
}

void loop ()
{
  // Give a pulse to the parallel load latch of all 74HC165
  digitalWrite( latchPin, LOW);    
  delayMicroseconds( pulseWidth);
  digitalWrite( latchPin, HIGH);

  // Reading one 74HC165 at a time and combining them into a 32 bit variable
  // The last 74HC165 is at the bottom, but the switches start numbering
  // at the top. So the first byte has to be shifted into the highest place.
  uint32_t optionSwitch = 0;
  for( int i=24; i>=0; i-=8)
  {
    optionSwitch |= ((uint32_t) ReadOne165()) << i;
  }

  for( int i = 0; i<32; i++)
  {
    if( bitRead( optionSwitch, i) != bitRead( oldOptionSwitch,i))
    {
      Serial.print( "Switch ");
      if( i < 10)
        Serial.print( " ");
      Serial.print( i);
      Serial.print( " is now ");
      Serial.println( bitRead( optionSwitch, i) == 0 ? "down ↓" : "up   ↑");
    }
  }
 
  oldOptionSwitch = optionSwitch;
  delay( 25);      // slow down the sketch to avoid switch bounce
}

// The ReadOne165() function reads only 8 bits,
// because of the similar functions shiftIn() and SPI.transfer()
// which both use 8 bits.
//
// The shiftIn() can not be used here, because the clock is set idle low
// and the shiftIn() makes the clock high to read a bit.
// The 74HC165 require to read the bit first and then give a clock pulse.
//
byte ReadOne165()
{
  byte ret = 0x00;

  // The first one that is read is the highest bit (input D7 of the 74HC165).
  for( int i=7; i>=0; i--)
  {
    if( digitalRead( dataPin) == HIGH)
      bitSet( ret, i);

    digitalWrite( clockPin, HIGH);
    delayMicroseconds( pulseWidth);
    digitalWrite( clockPin, LOW);
  }

  return( ret);
}

 I think this is a great starting point if it works out.  

I also spent some time thinking about a final configuration for everything. It is going to be pretty clunky with boards under the typewriter wired to the microcontroller, computer, etc, and I want it to be a seamless experience with depositing the letters, so I thought creating a custom podium/table thing with the mail slot built in and the typewriter placed on top would alleviate the potential aesthetic issues. I could hide a hole in the top so that the typewriter still sits flat but has whatever it needs under it, and I could probably conceal most of the wiring (and stick my laptop somewhere in there) while also providing a clean mail slot that isn't just another random tabletop object. Here's a visual: 

Also, I've been looking around for sentiment analysis options, and most of what I've found works well but can only output three options: positive, negative, and neutral. I'd like to be more specific than that, so I'm not sure what to do. I don't want to think about it too much because I have a lot to make work before I get there, but it's on the back of my mind for sure. I am thinking about creating prompts that will be on each paper for people to use, such as 

  • write to someone you love
  • write to someone you hate 
  • write to someone you don't know 
  • make a confession to someone 
  • etc 
This way people have a real goal and don't just play on the typewriter so that I can pick up valuable information to be interpreted by the sentiment analysis. 



As for touch designer, I'm not exactly struggling with it, but I am just so slow. I've spent about three hours on the tutorial and am just over halfway through it. I may just make a separate post later with my results because I'm still working on it, but so far I don't really have any questions or missing pieces. Like I said, it's just taking me forever. Luckily I'm not projecting any complex visuals for my project. 



Comments

Popular posts from this blog

Week 4 Update

Update and Code Dump