Welcome to iSmartMailBoxHD.com, the best iSmartMailboxHD.com!
aaronvose.net--pgiblock.net





Day 7   (08/16/2014):

Muhahahah!!!

Day 6   (06/15/2014):

I did take another test image with a peice of paper in the mailbox just to see how a letter may look when inside. Even with the mailbox door open in a well-lit room, there isn't enough light for a good exposure; internal lighting will be needed.



So, I made a 4x4 LED array with some nice bright 3mm white LEDs. You can see the array powered on (and off) in the images below.







Day 5   (01/26/2014):

I decided that the super-huge (physical size, not KiB) EEPROM just wasn't worth the trouble. So, I redesigned a much cleaner PCB version to use only the DAC and LM386 audio amp. Circuit diagram and some renderings are included below.









Day 4.5   (01/19/2014):

I did a little more on the audio front. While I did get one of the DACs connected before, this version has a parallel EEPROM as well to store the sample data. I like the design, because the EEPROM is optional and can be bypassed to use the DAC directly. Though, this EEPROM is so small (only 8k * 8-bit samples) that I may just go back to the original design with only the DAC and LM386 audio amp. Either way, this was my first attempt at a PCB layout (KiCad seems nice); with just a little more work, this is the sort of thing you can mail off to have PCBs made:





Day 4   (01/12/2014):

First of all, I added the super low-tech physical flag stops, consisting of two bolts and two nuts. They are "highlighted" in the image for visibility:



Next, I at least have the example code up and running with the TTL camera connected. Things are out of focus, which should be easy to fix with a small lense adjustment. It takes a while to read the image and write it to the SD card. I think a lot of that time is transfer over the serial interface at a default of 9600 baud, which I think I can turn up.



Finally, I mounted the camera at the back of the mailbox with some epoxy:





Day 3   (01/05/2014):

I decided to take a step away from the camera and look into doing audio. At first I was thinking about doing audio straight out of the Arduino with the PWM outputs. However, as I had an MX7224KN 8-bit DAC sitting around doing nothing, I decided this would probably be a better (sounding) choice. Here are some websites that provide information about the 7224KN and how to use PWMs, DACs, timers, and ports with the Arduino:

http://www.alldatasheet.com/datasheet-pdf/pdf/73928/MAXIM/MX7224KN.html
https://www.sparkfun.com/tutorials/160
http://playground.arduino.cc/Code/PCMAudio
http://www.instructables.com/id/Arduino-Timer-Interrupts/step2/Structuring-Timer-Interrupts/
http://www.arduino.cc/en/Reference/PortManipulation
https://spreadsheets.google.com/pub?key=rtHw_R6eVL140KS9_G8GPkA&gid=0

I did get the DAC mounted on a prototyping board, which is a lot cleaner than the breadboard mess I started with. Have I ever mentioned that epoxy is nice? Cat5 is even nicer!





Here is some starting code for playing a "hello" sound through the DAC. This is the very first version I actually had play anything, so it's a total mess right now:

#include "wavedata.h"

// DAC register control pins
int pin_reset = A8;
int pin_ldac  = A9;
int pin_wr    = A10;
int pin_cs    = A11;

// DAC data input pins
int pin_db0   = A0;
int pin_db1   = A1;
int pin_db2   = A2;
int pin_db3   = A3;
int pin_db4   = A4;
int pin_db5   = A5;
int pin_db6   = A6;
int pin_db7   = A7;


// This is the amount of data to be fetched from the SD card for each read.
#define BUFFERSIZE 256

// Two cycling buffers which contain the WAV data.
unsigned char buffer1[BUFFERSIZE], buffer2[BUFFERSIZE];

// Wave header is 44 bytes:
unsigned char header[44];

// Holds the current voltage value  to be sent to the DAC
volatile unsigned char note             = 0;	

// Keeps track of which buffer is currently being used
char                   play_buffer      = 0; 

// Flag used by 'Loop' code to tell the Interrupt that new data is ready in the buffer.
char                   new_buffer_ready = 0;

// Keeps track of the number of bytes read from the current buffer.
volatile unsigned int  byte_count       = 0; 

// Flag used by Interrupt to tell 'Loop' code that a buffer is empty and needs to be refilled.
volatile char          need_new_data    = 0; 


void setup() {                
  // All pins to the DAC are output from the arduino
  pinMode(pin_reset, OUTPUT);
  pinMode(pin_ldac,  OUTPUT);  
  pinMode(pin_wr,    OUTPUT);
  pinMode(pin_cs,    OUTPUT); 
  pinMode(pin_db0,   OUTPUT);
  pinMode(pin_db1,   OUTPUT);  
  pinMode(pin_db2,   OUTPUT);
  pinMode(pin_db3,   OUTPUT); 
  pinMode(pin_db4,   OUTPUT);
  pinMode(pin_db5,   OUTPUT);  
  pinMode(pin_db6,   OUTPUT);
  pinMode(pin_db7,   OUTPUT); 
  
  // Start with the output and registers latched at zero
  digitalWrite(pin_reset, LOW);
  digitalWrite(pin_ldac,  HIGH);
  digitalWrite(pin_wr,    HIGH);
  digitalWrite(pin_cs,    HIGH);
  digitalWrite(pin_reset, HIGH);
}

int flg = 0;
int wfd = 0;
int wait = 0;

// This timer interrupt will run every 45uS. 
// A 45uS period equals a frequency of 22.222kHz. 
// This is frequency of the WAV files that will be played
ISR(TIMER1_COMPA_vect){
  
  cli();  // Disable interrupts
  
  flg += 1;
  if( flg > 1 ) {
    flg = 0;
    sei();
    return;
  }
  
  if( wait ) {
    wait--;
    sei();
    return;
  }
  
  if(wfd) {
     if( new_buffer_ready == 1 ) {
      // If new data is available, reassign the play buffer.
      if( play_buffer == 0 ) play_buffer = 1;
      else                   play_buffer = 0;
      wfd = 0;
    } else {
      // If no new data is available then wait for it!
      wfd = 1;
      sei();
      return;
    }
  }
  
  // Check to see if we've read all of the data in the current buffer
  if( byte_count == BUFFERSIZE ) {
    need_new_data = 1;	// Set a flag to tell the 'loop' code to refill the current buffer.
    byte_count = 0;	// Reset the count
    
    // Check to see if new data exists in the alternate buffer
    if( new_buffer_ready == 1 ) {
      // If new data is available, reassign the play buffer.
      if( play_buffer == 0 ) play_buffer = 1;
      else                   play_buffer = 0;
    } else {
      // If no new data is available then wait for it!
      wfd = 1;
      sei();
      return;
    }
  }
  
  // Find out which buffer is being used, and get data from it.
  if( play_buffer == 0 ) note = buffer1[byte_count];
  else                   note = buffer2[byte_count];
  
  // Increase the byte_count since we've taken the current data.
  byte_count += 1;
  
  
  // Let input in and latch in input register
  digitalWrite(pin_cs,   LOW);
  digitalWrite(pin_wr,   LOW);
  PORTF = note;
  digitalWrite(pin_wr,   HIGH);
  digitalWrite(pin_cs,   HIGH);
  
  // Allow DAC register to read from input register
  digitalWrite(pin_ldac, LOW);
  digitalWrite(pin_wr,   LOW);
  digitalWrite(pin_wr,   HIGH);
  digitalWrite(pin_ldac, HIGH);
  
  /*
  // Let input register into DAC register
  digitalWrite(pin_ldac, LOW);
  digitalWrite(pin_wr,   LOW);
  digitalWrite(pin_wr,   HIGH);

  // Let inputs into the input register
  digitalWrite(pin_ldac, HIGH);
  digitalWrite(pin_wr,   LOW);
  digitalWrite(pin_cs,   LOW);
  PORTF = note;
  digitalWrite(pin_wr,   HIGH);
  digitalWrite(pin_cs,   HIGH);	
  */
  	
  sei(); // Re-enable interrupts
}  

int bu_read(unsigned char *d, int c)
{
  if( bu_length-bu_offset < c ) {
    c = bu_length-bu_offset;
  }

  if( c < 1 ) {
    return -1; 
  }
  
  memcpy(d, bu_data+bu_offset, c);
  bu_offset += c;
  return c;
}

void loop() 
{
  int bytes_read = 0;
  
  // Init Timer 1; Used for 45uS Interrupt
  TCCR1A = 0;	    // Set Timer to normal mode
  TCCR1B = 0x0A;    // Set Timer clock to 2 MHz. Clear timer on compare
  TIMSK1 = 0x02;    // Enable Timer 1 Compare A Interrupt;
  OCR1AH = 0X00;    // Count to 90 before triggering an interrupt. Counting to 90 with a 2MHz clock makes
  OCR1AL = 0x5A;    // the interrupt trigger at 22.222kHz
  
  // Set the initial play buffer, and grab the initial data from the SD card.
  play_buffer = 0;
  bu_offset = 0;
  bytes_read  = bu_read(buffer1, BUFFERSIZE);
  bytes_read  = bu_read(buffer2, BUFFERSIZE);
 
  // Enable interrupts to start the wav playback.
  sei();
  
  while(1) {
   if(need_new_data == 1) {
      need_new_data = 0;
      // play_buffer indicates which buffer is now empty
      if(play_buffer == 0) {
        bytes_read = bu_read(buffer1, BUFFERSIZE);
      } else {
        bytes_read = bu_read(buffer2, BUFFERSIZE);
      }
      // new_buffer_ready flag tells the ISR that the buffer has been filled.
      new_buffer_ready = 1;
			
      // If file_read returns 0 or -1 file is over. Find the next file!
      if(bytes_read <= 0) {
        cli();	// Disable interrupts to stop playback.
        wait = 11111;
        play_buffer = 0;
        bu_offset = 0;
        bytes_read  = bu_read(buffer1, BUFFERSIZE);
        bytes_read  = bu_read(buffer2, BUFFERSIZE);
        sei();	// Start playing the wav
      }
    } 
    
  }
  
}


The 'wavedata.h' file that has the samples that are played follows, as well as a plot with gnuplot for what this sound should look like:



int bu_offset=0;

#define bu_length (sizeof(bu_data))

const unsigned char bu_data[]=
{
127, 127, 128, 128, 127, 128, 127, 128, 128, 128, 128, 128, 129, 128, 129, 128, 128, 
128, 127, 128, 129, 128, 128, 128, 128, 128, 128, 127, 128, 128, 129, 128, 128, 128, 128, 128, 128, 
128, 128, 128, 128, 128, 127, 128, 128, 127, 128, 128, 128, 128, 128, 129, 128, 128, 128, 128, 128, 
129, 128, 128, 128, 128, 128, 128, 129, 128, 129, 128, 128, 128, 129, 128, 128, 127, 128, 128, 128, 
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 128, 128, 128, 128, 129, 128, 128, 128, 
128, 129, 128, 128, 128, 129, 128, 128, 128, 128, 128, 127, 128, 128, 128, 128, 128, 128, 128, 128, 
127, 128, 128, 128, 129, 128, 128, 128, 128, 128, 128, 129, 128, 128, 128, 128, 128, 128, 128, 128, 
128, 128, 127, 127, 127, 128, 127, 128, 128, 128, 128, 129, 128, 128, 127, 128, 128, 128, 128, 129, 
128, 128, 127, 128, 128, 129, 128, 129, 127, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 
128, 127, 128, 128, 128, 129, 128, 127, 128, 128, 127, 129, 128, 128, 127, 128, 127, 127, 128, 128, 
128, 127, 128, 128, 127, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 128, 128, 128, 128, 
128, 128, 129, 127, 128, 128, 128, 128, 128, 127, 128, 128, 128, 127, 129, 128, 129, 128, 127, 128, 
129, 127, 127, 129, 128, 128, 128, 127, 128, 127, 129, 128, 128, 128, 128, 128, 127, 128, 129, 127, 
128, 128, 128, 128, 127, 129, 129, 128, 128, 127, 127, 128, 128, 128, 128, 129, 129, 128, 128, 128, 
129, 128, 127, 126, 127, 128, 128, 129, 128, 129, 129, 128, 128, 128, 129, 129, 129, 128, 126, 128, 
128, 128, 127, 128, 128, 129, 129, 128, 129, 128, 128, 128, 128, 128, 128, 128, 127, 128, 128, 129, 
128, 128, 127, 128, 129, 129, 128, 128, 127, 128, 127, 127, 127, 128, 129, 128, 127, 128, 129, 129, 
129, 128, 127, 127, 128, 128, 128, 127, 128, 128, 129, 128, 127, 128, 128, 128, 129, 129, 128, 128, 
128, 127, 126, 129, 128, 127, 128, 128, 129, 128, 127, 129, 128, 128, 128, 128, 127, 129, 128, 126, 
127, 127, 128, 128, 128, 127, 127, 130, 129, 127, 129, 129, 128, 127, 129, 129, 128, 127, 126, 127, 
128, 128, 130, 130, 130, 126, 125, 128, 128, 127, 127, 129, 128, 128, 128, 128, 129, 127, 127, 129, 
128, 128, 128, 129, 129, 129, 129, 128, 127, 128, 128, 126, 125, 128, 130, 128, 125, 131, 132, 126, 
125, 130, 130, 127, 127, 127, 130, 129, 127, 129, 130, 129, 130, 127, 129, 129, 126, 129, 130, 129, 
128, 130, 132, 126, 126, 130, 128, 127, 127, 131, 128, 129, 132, 129, 126, 130, 129, 128, 127, 127, 
129, 127, 127, 130, 129, 127, 128, 130, 132, 127, 125, 129, 128, 128, 127, 130, 131, 125, 128, 129, 
128, 126, 127, 131, 128, 130, 132, 127, 126, 130, 129, 128, 127, 127, 131, 127, 127, 132, 128, 128, 
129, 129, 129, 129, 130, 129, 127, 126, 127, 127, 126, 128, 126, 127, 130, 127, 127, 130, 127, 127, 
127, 127, 126, 128, 126, 126, 128, 127, 131, 130, 128, 130, 129, 128, 127, 127, 126, 127, 127, 126, 
128, 128, 128, 128, 129, 128, 128, 127, 127, 127, 127, 125, 127, 128, 128, 127, 125, 127, 128, 126, 
129, 130, 129, 128, 128, 128, 129, 127, 127, 129, 127, 127, 129, 129, 129, 127, 127, 129, 127, 126, 
131, 132, 130, 128, 125, 128, 128, 128, 128, 126, 130, 133, 128, 123, 128, 128, 127, 129, 127, 133, 
130, 128, 129, 129, 127, 127, 127, 126, 129, 130, 128, 131, 129, 130, 130, 128, 131, 125, 130, 131, 
126, 129, 126, 125, 127, 127, 127, 130, 129, 129, 129, 128, 126, 128, 129, 127, 128, 129, 131, 127, 
128, 131, 129, 124, 129, 130, 128, 130, 128, 125, 129, 131, 130, 123, 125, 135, 129, 123, 129, 133, 
127, 123, 128, 129, 131, 126, 128, 131, 128, 129, 128, 129, 128, 127, 128, 126, 128, 127, 126, 128, 
129, 132, 126, 126, 131, 127, 126, 126, 130, 131, 124, 125, 131, 126, 123, 127, 130, 129, 129, 127, 
128, 127, 125, 127, 126, 128, 126, 127, 129, 128, 127, 128, 127, 127, 130, 127, 129, 134, 128, 126, 
125, 122, 125, 129, 131, 130, 125, 127, 135, 128, 124, 129, 129, 126, 126, 128, 127, 128, 127, 127, 
129, 128, 125, 128, 128, 128, 127, 127, 129, 129, 127, 124, 131, 135, 127, 124, 129, 134, 131, 125, 
128, 132, 129, 127, 126, 125, 126, 128, 127, 128, 131, 127, 129, 130, 126, 130, 126, 128, 130, 128, 
127, 129, 131, 133, 129, 125, 129, 125, 127, 128, 127, 133, 126, 126, 133, 131, 130, 129, 123, 126, 
130, 125, 128, 130, 127, 128, 127, 129, 127, 126, 132, 129, 130, 127, 127, 129, 128, 128, 127, 132, 
129, 127, 123, 125, 126, 127, 128, 130, 129, 129, 128, 127, 131, 126, 125, 129, 129, 127, 129, 130, 
126, 128, 131, 123, 132, 134, 126, 130, 128, 131, 129, 126, 125, 129, 130, 129, 125, 124, 128, 131, 
128, 126, 127, 128, 126, 124, 127, 126, 129, 128, 126, 126, 126, 124, 126, 127, 127, 126, 127, 128, 
125, 127, 129, 130, 128, 131, 130, 131, 135, 129, 126, 128, 131, 130, 128, 126, 128, 135, 129, 125, 
124, 125, 130, 126, 125, 126, 123, 122, 123, 121, 125, 125, 127, 132, 129, 126, 125, 129, 124, 125, 
130, 134, 140, 133, 138, 141, 136, 136, 133, 134, 142, 139, 136, 133, 128, 129, 124, 121, 122, 118, 
119, 118, 119, 116, 118, 115, 113, 113, 110, 118, 119, 121, 126, 125, 125, 128, 132, 140, 141, 147, 
160, 171, 173, 158, 148, 143, 142, 140, 136, 132, 125, 120, 112, 110, 103, 106, 102, 104, 106, 102, 
105, 98, 103, 102, 98, 101, 110, 115, 125, 134, 137, 141, 149, 159, 192, 196, 173, 174, 164, 167, 
167, 155, 147, 143, 120, 108, 98, 91, 93, 99, 105, 106, 108, 99, 93, 93, 94, 93, 89, 95, 
109, 127, 133, 133, 132, 136, 147, 165, 188, 194, 178, 190, 201, 179, 180, 151, 156, 117, 105, 91, 
69, 93, 77, 110, 107, 116, 117, 102, 104, 92, 94, 81, 77, 99, 103, 129, 126, 127, 128, 127, 
145, 160, 192, 207, 190, 202, 198, 180, 177, 154, 148, 105, 98, 82, 78, 91, 92, 108, 111, 114, 
115, 108, 108, 90, 80, 79, 81, 105, 109, 118, 123, 124, 123, 123, 137, 161, 185, 217, 200, 193, 
206, 193, 180, 163, 147, 109, 101, 81, 79, 85, 93, 110, 115, 115, 111, 110, 110, 87, 76, 76, 
84, 107, 109, 120, 123, 124, 123, 124, 142, 165, 192, 219, 195, 198, 205, 191, 178, 162, 141, 107, 
97, 79, 82, 86, 96, 109, 115, 118, 114, 104, 101, 95, 91, 67, 74, 99, 111, 132, 116, 125, 
119, 133, 144, 152, 174, 202, 209, 209, 218, 205, 187, 168, 147, 110, 91, 73, 69, 77, 91, 112, 
122, 128, 122, 111, 101, 77, 79, 73, 94, 87, 87, 125, 123, 141, 116, 119, 137, 147, 177, 178, 
202, 205, 206, 226, 199, 183, 160, 129, 105, 80, 68, 67, 80, 100, 118, 126, 124, 115, 109, 98, 
85, 68, 63, 81, 102, 115, 122, 118, 130, 129, 132, 137, 144, 171, 195, 219, 212, 213, 216, 195, 
182, 155, 113, 82, 58, 62, 72, 88, 99, 112, 126, 127, 127, 107, 93, 71, 67, 77, 87, 107, 
114, 127, 128, 129, 136, 132, 146, 159, 186, 210, 215, 222, 228, 212, 194, 165, 113, 82, 49, 47, 
54, 73, 93, 112, 131, 131, 136, 117, 105, 88, 60, 63, 70, 97, 123, 130, 135, 128, 133, 137, 
147, 163, 172, 203, 221, 226, 236, 221, 198, 173, 119, 85, 50, 38, 46, 61, 88, 109, 135, 137, 
145, 128, 113, 96, 66, 63, 61, 82, 111, 124, 140, 132, 137, 142, 145, 160, 171, 201, 218, 226, 
241, 231, 212, 178, 117, 77, 37, 29, 35, 54, 80, 104, 129, 141, 152, 141, 124, 104, 76, 70, 
60, 61, 94, 107, 136, 139, 138, 147, 146, 164, 173, 193, 214, 226, 251, 248, 226, 181, 110, 68, 
27, 23, 29, 48, 73, 99, 130, 149, 164, 152, 133, 106, 80, 72, 58, 71, 77, 100, 126, 131, 
152, 142, 155, 161, 171, 197, 210, 228, 242, 243, 234, 187, 122, 67, 24, 20, 25, 48, 70, 97, 
122, 145, 160, 156, 139, 108, 85, 79, 71, 74, 83, 89, 117, 123, 147, 152, 153, 162, 166, 191, 
208, 229, 248, 243, 231, 191, 129, 79, 28, 17, 19, 41, 66, 91, 117, 134, 154, 149, 148, 122, 
96, 84, 70, 87, 89, 98, 110, 110, 137, 141, 158, 163, 167, 187, 203, 231, 240, 243, 228, 200, 
149, 94, 46, 18, 15, 34, 55, 83, 106, 125, 150, 151, 152, 131, 102, 90, 71, 84, 90, 93, 
111, 107, 134, 140, 155, 164, 163, 185, 199, 227, 241, 244, 231, 207, 156, 101, 53, 20, 19, 29, 
53, 77, 100, 116, 137, 145, 148, 139, 116, 104, 88, 94, 98, 96, 100, 97, 114, 133, 149, 163, 
165, 181, 199, 222, 241, 245, 237, 215, 169, 116, 64, 24, 14, 20, 42, 64, 87, 104, 124, 135, 
146, 144, 129, 120, 104, 108, 105, 102, 100, 93, 106, 118, 141, 155, 165, 181, 193, 218, 233, 245, 
243, 225, 180, 123, 71, 36, 25, 29, 41, 55, 68, 84, 104, 122, 139, 142, 136, 125, 114, 120, 
120, 119, 112, 99, 103, 111, 131, 144, 154, 167, 180, 205, 224, 240, 240, 227, 192, 144, 100, 59, 
42, 37, 42, 53, 61, 71, 85, 100, 117, 127, 130, 132, 126, 130, 131, 130, 127, 115, 112, 112, 
122, 134, 144, 159, 171, 190, 205, 224, 233, 231, 207, 165, 122, 84, 61, 49, 50, 54, 55, 56, 
69, 83, 102, 119, 125, 129, 126, 131, 137, 139, 138, 124, 116, 115, 122, 137, 144, 153, 159, 174, 
191, 211, 226, 228, 214, 178, 142, 102, 76, 63, 58, 57, 58, 58, 64, 73, 90, 108, 117, 125, 
124, 128, 136, 139, 141, 137, 125, 114, 125, 127, 132, 153, 153, 169, 188, 201, 219, 226, 222, 198, 
167, 128, 95, 77, 62, 60, 53, 47, 48, 52, 68, 89, 104, 120, 124, 130, 136, 142, 146, 140, 
135, 125, 126, 131, 135, 143, 146, 158, 173, 189, 210, 222, 233, 212, 184, 149, 108, 90, 71, 64, 
56, 47, 41, 44, 55, 76, 95, 112, 123, 127, 134, 140, 147, 142, 138, 129, 125, 129, 133, 140, 
145, 152, 167, 181, 203, 218, 229, 226, 195, 166, 123, 96, 80, 68, 63, 49, 40, 38, 41, 60, 
78, 96, 112, 119, 133, 138, 146, 150, 146, 143, 135, 135, 134, 134, 143, 147, 162, 174, 192, 211, 
222, 233, 209, 185, 142, 109, 92, 75, 73, 59, 47, 38, 31, 45, 59, 81, 98, 105, 121, 125, 
144, 152, 155, 157, 143, 146, 139, 142, 145, 146, 159, 164, 183, 200, 216, 230, 212, 194, 154, 127, 
108, 90, 87, 67, 56, 38, 30, 35, 45, 65, 80, 90, 107, 114, 137, 148, 159, 166, 158, 159, 
150, 151, 149, 152, 158, 162, 174, 187, 201, 219, 214, 205, 176, 143, 121, 98, 93, 77, 66, 49, 
34, 31, 32, 46, 61, 75, 93, 105, 126, 141, 156, 168, 165, 168, 155, 156, 152, 155, 160, 163, 
171, 179, 193, 210, 212, 204, 182, 148, 127, 102, 97, 84, 72, 56, 36, 31, 27, 40, 55, 69, 
87, 97, 116, 132, 146, 163, 163, 170, 159, 159, 155, 154, 159, 162, 171, 177, 190, 204, 214, 205, 
192, 160, 136, 111, 99, 92, 78, 67, 46, 35, 29, 32, 49, 58, 79, 91, 105, 126, 136, 158, 
160, 168, 164, 160, 161, 155, 163, 163, 172, 176, 187, 195, 209, 207, 199, 177, 147, 127, 102, 97, 
82, 72, 55, 38, 31, 26, 42, 53, 69, 87, 97, 120, 131, 152, 161, 164, 169, 159, 163, 154, 
161, 162, 168, 175, 183, 193, 204, 210, 201, 187, 156, 136, 110, 100, 88, 74, 63, 41, 35, 28, 
35, 49, 60, 80, 90, 109, 124, 137, 157, 161, 171, 167, 163, 162, 156, 163, 163, 172, 177, 188, 
199, 211, 210, 200, 177, 150, 130, 106, 100, 84, 73, 55, 36, 32, 25, 38, 48, 63, 83, 93, 
117, 130, 145, 162, 162, 172, 163, 165, 163, 160, 168, 165, 176, 182, 191, 205, 208, 203, 189, 160, 
139, 112, 102, 90, 74, 65, 41, 36, 26, 31, 45, 53, 73, 85, 100, 123, 135, 158, 161, 167, 
168, 161, 164, 157, 165, 165, 171, 179, 185, 198, 206, 207, 198, 179, 151, 131, 109, 100, 86, 72, 
56, 37, 32, 24, 34, 45, 57, 77, 91, 110, 127, 142, 157, 163, 167, 170, 165, 167, 162, 165, 
168, 173, 183, 189, 199, 208, 202, 193, 168, 145, 125, 101, 95, 75, 68, 50, 36, 35, 27, 43, 
50, 66, 85, 97, 119, 132, 148, 162, 163, 171, 165, 166, 163, 161, 169, 169, 180, 187, 195, 208, 
207, 201, 187, 157, 140, 113, 101, 89, 71, 62, 41, 36, 29, 33, 45, 52, 71, 87, 105, 125, 
139, 155, 163, 166, 172, 166, 166, 164, 163, 171, 172, 183, 190, 197, 208, 202, 198, 177, 149, 130, 
105, 98, 79, 68, 54, 36, 35, 27, 38, 46, 59, 78, 92, 113, 132, 145, 160, 164, 169, 170, 
164, 166, 162, 167, 170, 175, 186, 191, 201, 208, 201, 193, 164, 144, 120, 100, 93, 71, 64, 46, 
35, 32, 28, 40, 49, 64, 83, 97, 120, 134, 150, 163, 165, 173, 168, 166, 164, 162, 167, 170, 
179, 187, 193, 202, 206, 197, 186, 158, 138, 114, 97, 89, 70, 63, 42, 34, 29, 30, 42, 53, 
71, 88, 102, 124, 136, 151, 163, 165, 170, 164, 165, 160, 161, 167, 171, 181, 189, 196, 209, 209, 
200, 184, 153, 130, 105, 93, 83, 69, 58, 42, 35, 31, 34, 43, 57, 77, 95, 111, 126, 139, 
151, 162, 155, 159, 164, 160, 161, 164, 169, 181, 192, 207, 219, 226, 231, 209, 181, 137, 96, 70, 
47, 41, 38, 35, 37, 42, 56, 73, 84, 101, 110, 124, 131, 136, 141, 141, 142, 142, 137, 137, 
135, 144, 160, 175, 195, 209, 224, 238, 241, 242, 214, 169, 120, 63, 37, 16, 17, 30, 37, 53, 
67, 89, 112, 120, 129, 121, 115, 112, 101, 117, 117, 130, 134, 129, 136, 131, 150, 172, 194, 220, 
228, 245, 241, 230, 220, 180, 136, 84, 39, 20, 18, 31, 60, 75, 96, 108, 114, 119, 106, 101, 
94, 90, 93, 95, 102, 116, 124, 140, 144, 148, 150, 162, 188, 204, 217, 217, 221, 218, 215, 207, 
177, 126, 77, 38, 29, 35, 51, 74, 82, 101, 106, 117, 109, 97, 94, 88, 91, 95, 99, 113, 
122, 136, 144, 147, 150, 156, 181, 200, 215, 216, 218, 217, 214, 210, 191, 148, 98, 57, 34, 41, 
53, 71, 83, 87, 98, 103, 107, 94, 78, 70, 79, 88, 105, 122, 131, 145, 143, 146, 143, 145, 
159, 178, 199, 209, 213, 218, 214, 215, 210, 193, 150, 98, 62, 31, 39, 47, 63, 81, 85, 103, 
112, 107, 97, 72, 71, 72, 88, 123, 135, 155, 143, 136, 131, 124, 146, 159, 186, 207, 216, 232, 
223, 219, 204, 186, 171, 125, 91, 55, 34, 46, 50, 74, 86, 96, 113, 111, 102, 86, 65, 76, 
81, 104, 123, 116, 143, 133, 147, 143, 134, 154, 165, 202, 217, 219, 225, 211, 212, 212, 192, 162, 
96, 63, 36, 40, 62, 71, 86, 86, 95, 114, 109, 96, 73, 61, 80, 79, 118, 128, 139, 146, 
129, 140, 132, 147, 166, 181, 211, 211, 220, 220, 203, 207, 187, 176, 134, 92, 68, 42, 56, 65, 
77, 92, 91, 103, 105, 98, 88, 68, 72, 87, 92, 123, 128, 134, 138, 130, 139, 136, 155, 176, 
195, 217, 211, 211, 207, 200, 202, 192, 171, 121, 75, 56, 40, 61, 73, 85, 96, 95, 106, 102, 
93, 81, 65, 78, 87, 99, 128, 127, 138, 134, 132, 139, 136, 162, 179, 202, 216, 209, 211, 203, 
199, 200, 190, 163, 110, 67, 47, 41, 64, 80, 93, 98, 100, 109, 102, 87, 69, 60, 77, 94, 
113, 128, 112, 131, 133, 145, 152, 140, 159, 172, 205, 221, 215, 211, 196, 197, 202, 186, 150, 91, 
55, 44, 55, 75, 87, 94, 96, 105, 114, 105, 84, 60, 56, 71, 96, 126, 132, 141, 132, 131, 
136, 138, 153, 168, 192, 210, 213, 218, 210, 203, 195, 185, 168, 117, 84, 54, 45, 59, 76, 96, 
104, 104, 109, 101, 91, 74, 63, 75, 88, 105, 119, 129, 134, 138, 136, 137, 138, 152, 177, 198, 
210, 210, 214, 214, 211, 201, 183, 138, 84, 58, 43, 56, 78, 87, 99, 105, 107, 117, 103, 82, 
64, 50, 82, 93, 116, 135, 125, 141, 133, 135, 141, 138, 169, 191, 215, 226, 216, 217, 201, 192, 
185, 157, 108, 71, 46, 43, 69, 88, 108, 114, 108, 104, 102, 84, 76, 64, 68, 84, 90, 124, 
134, 143, 143, 129, 129, 134, 160, 193, 210, 216, 211, 208, 213, 206, 201, 169, 108, 65, 38, 40, 
70, 95, 112, 114, 108, 106, 109, 95, 83, 64, 57, 86, 106, 136, 120, 115, 117, 125, 155, 154, 
162, 167, 189, 217, 224, 221, 210, 192, 199, 178, 134, 89, 40, 35, 53, 86, 114, 118, 117, 106, 
104, 104, 86, 78, 54, 70, 94, 120, 135, 111, 120, 115, 142, 157, 157, 165, 174, 203, 222, 224, 
219, 201, 194, 191, 156, 113, 68, 37, 40, 62, 96, 119, 127, 121, 108, 103, 88, 80, 64, 60, 
73, 90, 120, 140, 146, 141, 129, 123, 134, 157, 185, 212, 219, 217, 215, 212, 204, 193, 164, 108, 
73, 40, 41, 61, 87, 116, 125, 129, 117, 109, 99, 76, 69, 54, 74, 91, 108, 136, 125, 141, 
131, 134, 141, 144, 170, 197, 217, 226, 220, 216, 206, 188, 173, 111, 74, 38, 32, 59, 82, 125, 
135, 141, 131, 108, 106, 75, 68, 53, 51, 83, 92, 139, 148, 147, 144, 121, 128, 141, 167, 203, 
217, 225, 221, 214, 211, 190, 168, 110, 70, 38, 34, 60, 84, 122, 138, 143, 135, 113, 102, 81, 
65, 57, 51, 74, 97, 130, 143, 148, 134, 128, 127, 139, 164, 196, 218, 224, 225, 221, 206, 194, 
161, 96, 69, 29, 40, 62, 87, 127, 135, 147, 141, 120, 114, 84, 66, 53, 41, 71, 94, 134, 
157, 153, 139, 127, 121, 143, 164, 195, 218, 220, 230, 224, 210, 198, 154, 90, 59, 21, 39, 62, 
90, 133, 139, 156, 143, 119, 111, 78, 68, 53, 50, 78, 94, 129, 134, 143, 142, 136, 140, 148, 
164, 194, 217, 230, 232, 225, 203, 187, 137, 82, 61, 24, 51, 64, 92, 131, 137, 154, 145, 120, 
114, 81, 68, 57, 47, 76, 90, 127, 134, 143, 143, 136, 139, 147, 161, 191, 214, 230, 232, 228, 
205, 189, 145, 83, 63, 24, 47, 64, 90, 130, 138, 155, 149, 124, 118, 86, 69, 55, 45, 68, 
86, 128, 148, 155, 143, 130, 125, 144, 168, 201, 223, 226, 227, 217, 200, 186, 139, 83, 54, 23, 
44, 64, 92, 129, 138, 155, 150, 129, 121, 92, 72, 61, 40, 71, 97, 118, 145, 129, 137, 137, 
137, 162, 162, 187, 211, 216, 233, 216, 199, 184, 122, 83, 52, 29, 55, 67, 101, 131, 141, 162, 
150, 134, 118, 86, 67, 52, 49, 70, 96, 128, 145, 148, 138, 134, 132, 147, 169, 189, 212, 219, 
225, 216, 198, 176, 113, 71, 44, 25, 58, 72, 109, 136, 146, 165, 151, 134, 117, 85, 68, 50, 
51, 73, 102, 135, 143, 145, 134, 132, 137, 153, 175, 198, 213, 225, 218, 207, 186, 164, 111, 66, 
42, 31, 61, 78, 115, 137, 153, 162, 151, 133, 109, 92, 74, 56, 53, 62, 98, 136, 162, 160, 
139, 123, 124, 150, 181, 208, 220, 221, 215, 205, 188, 162, 95, 56, 28, 26, 63, 85, 122, 147, 
159, 169, 151, 129, 108, 84, 70, 56, 50, 71, 106, 131, 159, 144, 140, 132, 134, 161, 176, 205, 
220, 221, 220, 199, 183, 145, 80, 51, 19, 32, 66, 93, 131, 150, 164, 171, 148, 129, 103, 83, 
71, 49, 51, 65, 106, 149, 171, 163, 137, 120, 126, 155, 190, 214, 224, 223, 215, 197, 179, 120, 
62, 28, 6, 41, 70, 107, 142, 157, 174, 169, 148, 127, 95, 83, 59, 42, 51, 73, 129, 167, 
176, 154, 120, 111, 135, 171, 205, 217, 217, 212, 206, 195, 170, 108, 53, 18, 11, 50, 81, 120, 
146, 158, 171, 163, 143, 125, 95, 85, 60, 48, 56, 82, 135, 169, 172, 149, 118, 114, 139, 171, 
203, 210, 211, 205, 200, 189, 162, 101, 54, 20, 22, 57, 87, 126, 150, 163, 173, 160, 139, 118, 
90, 87, 62, 55, 62, 97, 137, 168, 169, 141, 125, 121, 148, 175, 196, 207, 209, 207, 195, 179, 
151, 82, 51, 19, 28, 67, 95, 135, 157, 167, 175, 155, 135, 109, 90, 81, 63, 61, 69, 101, 
138, 170, 161, 147, 124, 128, 157, 181, 203, 206, 202, 198, 187, 177, 139, 76, 44, 15, 38, 72, 
104, 140, 155, 167, 168, 146, 132, 107, 95, 84, 58, 56, 60, 103, 157, 183, 178, 142, 113, 121, 
146, 186, 205, 210, 203, 195, 182, 172, 132, 72, 40, 13, 39, 74, 109, 148, 160, 173, 168, 141, 
127, 94, 91, 75, 56, 63, 68, 123, 159, 175, 167, 133, 122, 135, 157, 186, 192, 199, 198, 194, 
186, 173, 132, 74, 40, 13, 38, 70, 107, 147, 161, 175, 165, 144, 125, 97, 85, 77, 60, 57, 
74, 108, 163, 183, 174, 143, 110, 125, 152, 193, 214, 208, 198, 184, 173, 173, 132, 81, 43, 6, 
35, 63, 110, 154, 164, 184, 164, 140, 117, 84, 84, 64, 62, 75, 89, 139, 167, 174, 156, 121, 
114, 132, 163, 201, 205, 208, 195, 188, 180, 171, 136, 79, 46, 13, 39, 68, 110, 151, 161, 172, 
156, 132, 114, 91, 88, 75, 70, 71, 73, 117, 150, 174, 176, 141, 124, 122, 145, 190, 205, 220, 
207, 194, 185, 177, 152, 93, 55, 7, 19, 48, 95, 145, 165, 178, 158, 130, 105, 81, 85, 81, 
81, 86, 80, 109, 135, 156, 162, 139, 132, 134, 158, 195, 204, 212, 199, 189, 181, 175, 163, 111, 
71, 21, 14, 38, 80, 136, 165, 180, 163, 130, 103, 80, 83, 80, 82, 86, 82, 113, 137, 157, 
162, 138, 132, 134, 160, 197, 204, 213, 198, 188, 180, 175, 159, 106, 66, 19, 18, 46, 88, 139, 
160, 171, 152, 126, 107, 83, 86, 76, 70, 84, 91, 131, 151, 159, 156, 125, 130, 135, 159, 191, 
194, 208, 199, 198, 191, 178, 165, 108, 72, 28, 18, 46, 77, 131, 150, 164, 150, 124, 110, 87, 
90, 83, 89, 95, 97, 109, 117, 137, 146, 152, 152, 148, 158, 173, 189, 204, 203, 199, 191, 181, 
177, 135, 94, 45, 15, 29, 58, 112, 144, 163, 153, 127, 106, 86, 89, 86, 86, 91, 86, 106, 
129, 144, 160, 144, 137, 135, 145, 179, 192, 204, 202, 190, 189, 178, 180, 163, 116, 77, 31, 26, 
45, 84, 128, 148, 153, 129, 113, 88, 84, 81, 84, 96, 103, 122, 136, 144, 142, 130, 126, 129, 
144, 173, 189, 203, 202, 194, 187, 178, 176, 173, 144, 107, 64, 30, 33, 56, 99, 134, 150, 138, 
118, 94, 81, 80, 80, 94, 104, 118, 129, 135, 133, 132, 129, 133, 144, 161, 181, 193, 198, 198, 
191, 181, 171, 167, 163, 135, 103, 65, 37, 44, 67, 105, 132, 137, 124, 104, 83, 77, 83, 95, 
112, 119, 121, 127, 122, 128, 132, 135, 147, 151, 170, 179, 190, 198, 194, 191, 179, 169, 166, 156, 
129, 97, 59, 38, 49, 75, 114, 135, 131, 115, 90, 77, 80, 89, 106, 117, 119, 125, 125, 125, 
133, 132, 143, 149, 161, 179, 185, 197, 196, 194, 186, 173, 167, 163, 140, 112, 77, 45, 46, 60, 
93, 122, 128, 121, 99, 79, 77, 82, 100, 115, 115, 122, 122, 126, 140, 137, 144, 142, 148, 170, 
179, 198, 197, 193, 185, 173, 168, 166, 163, 139, 106, 70, 45, 46, 68, 99, 121, 123, 106, 85, 
76, 76, 96, 112, 122, 123, 116, 123, 126, 139, 142, 142, 147, 152, 171, 187, 196, 198, 192, 182, 
172, 166, 163, 153, 129, 100, 73, 57, 61, 77, 98, 108, 105, 95, 85, 82, 94, 105, 113, 118, 
112, 117, 123, 135, 146, 141, 144, 144, 156, 174, 187, 196, 194, 188, 178, 171, 168, 162, 146, 117, 
87, 64, 60, 73, 92, 107, 108, 96, 83, 75, 82, 94, 106, 116, 115, 116, 121, 127, 138, 142, 
145, 148, 151, 164, 174, 182, 187, 184, 181, 175, 172, 171, 160, 149, 120, 91, 74, 61, 75, 83, 
95, 98, 89, 87, 85, 93, 101, 109, 112, 113, 118, 126, 138, 140, 142, 138, 139, 151, 165, 179, 
186, 188, 186, 184, 173, 173, 167, 157, 142, 110, 87, 63, 62, 76, 86, 102, 96, 91, 86, 85, 
95, 103, 112, 111, 117, 121, 132, 141, 141, 141, 137, 145, 157, 172, 183, 189, 188, 187, 180, 173, 
172, 161, 155, 129, 102, 80, 58, 67, 76, 93, 105, 97, 93, 84, 85, 92, 100, 109, 118, 123, 
129, 134, 135, 138, 136, 142, 151, 163, 178, 182, 187, 183, 183, 178, 173, 171, 159, 149, 124, 99, 
77, 61, 63, 75, 93, 102, 103, 98, 91, 91, 89, 99, 103, 114, 124, 135, 144, 139, 139, 134, 
139, 152, 165, 180, 183, 185, 184, 179, 172, 167, 163, 155, 145, 122, 100, 82, 72, 78, 83, 93, 
94, 90, 89, 88, 91, 99, 106, 112, 120, 125, 131, 134, 135, 139, 141, 147, 153, 161, 171, 176, 
182, 183, 181, 174, 166, 158, 154, 145, 130, 108, 82, 66, 61, 71, 86, 96, 100, 96, 93, 92, 
98, 106, 114, 124, 125, 127, 128, 129, 136, 142, 153, 161, 168, 173, 174, 180, 184, 187, 185, 176, 
163, 146, 122, 99, 81, 70, 72, 79, 90, 97, 96, 92, 89, 85, 93, 104, 112, 120, 121, 125, 
124, 129, 137, 141, 151, 156, 163, 167, 169, 176, 178, 182, 185, 179, 171, 160, 142, 123, 103, 86, 
74, 73, 77, 87, 94, 97, 98, 95, 94, 96, 103, 110, 118, 125, 129, 134, 137, 137, 141, 146, 
157, 167, 174, 180, 180, 181, 184, 185, 178, 168, 145, 118, 97, 82, 79, 81, 83, 88, 90, 91, 
94, 95, 96, 98, 101, 107, 112, 120, 126, 130, 135, 136, 138, 140, 148, 159, 168, 175, 179, 180, 
182, 186, 184, 177, 165, 140, 115, 91, 76, 72, 75, 86, 94, 99, 97, 93, 87, 89, 94, 109, 
119, 125, 129, 123, 124, 123, 129, 140, 150, 162, 167, 170, 174, 177, 187, 191, 196, 186, 169, 141, 
110, 90, 73, 75, 77, 87, 94, 96, 99, 92, 94, 94, 103, 112, 118, 122, 121, 123, 123, 129, 
138, 149, 164, 174, 179, 183, 187, 194, 195, 180, 145, 101, 67, 54, 66, 85, 102, 105, 98, 93, 
90, 99, 106, 118, 122, 122, 123, 122, 127, 133, 143, 156, 167, 174, 179, 184, 190, 195, 197, 183, 
156, 116, 75, 54, 50, 71, 94, 107, 110, 100, 90, 94, 99, 117, 122, 125, 125, 118, 124, 131, 
144, 162, 172, 183, 185, 185, 191, 194, 197, 180, 150, 102, 63, 43, 49, 75, 99, 113, 112, 100, 
93, 98, 107, 121, 128, 126, 123, 120, 123, 134, 150, 167, 179, 187, 190, 191, 198, 201, 196, 171, 
121, 72, 32, 28, 50, 82, 112, 118, 113, 101, 94, 101, 111, 125, 129, 126, 123, 119, 125, 135, 
151, 169, 178, 188, 190, 192, 199, 202, 193, 164, 111, 61, 27, 28, 55, 89, 117, 123, 117, 104, 
101, 103, 114, 123, 126, 127, 121, 125, 129, 140, 156, 165, 180, 187, 194, 202, 202, 198, 172, 129, 
79, 38, 26, 44, 78, 110, 128, 128, 117, 108, 107, 107, 119, 123, 126, 126, 121, 127, 130, 143, 
159, 170, 186, 195, 201, 204, 200, 185, 147, 98, 48, 21, 24, 54, 93, 123, 135, 131, 124, 114, 
115, 113, 120, 117, 122, 124, 125, 135, 135, 149, 160, 173, 191, 199, 207, 206, 194, 160, 110, 57, 
19, 14, 36, 77, 116, 139, 145, 140, 129, 120, 114, 113, 117, 119, 125, 125, 129, 133, 137, 151, 
165, 182, 199, 207, 210, 203, 176, 131, 79, 30, 10, 19, 53, 98, 129, 148, 145, 140, 128, 121, 
114, 115, 118, 120, 126, 126, 131, 134, 142, 156, 170, 189, 203, 209, 209, 196, 161, 112, 58, 17, 
10, 28, 70, 111, 141, 154, 150, 143, 131, 123, 114, 116, 114, 122, 125, 127, 134, 134, 148, 159, 
176, 195, 207, 213, 209, 182, 136, 77, 24, 1, 9, 47, 95, 134, 157, 159, 155, 142, 136, 126, 
122, 117, 113, 116, 114, 124, 130, 142, 155, 165, 180, 192, 201, 206, 197, 163, 112, 54, 12, 2, 
24, 72, 116, 151, 166, 163, 152, 139, 132, 127, 128, 125, 122, 117, 115, 120, 130, 146, 162, 176, 
189, 195, 202, 190, 156, 109, 51, 14, 3, 25, 70, 115, 153, 169, 170, 161, 146, 139, 132, 129, 
125, 118, 111, 105, 107, 119, 133, 153, 171, 183, 195, 198, 198, 177, 139, 92, 42, 14, 13, 38, 
83, 123, 157, 169, 165, 156, 142, 138, 136, 135, 133, 122, 114, 110, 116, 133, 154, 175, 192, 200, 
206, 186, 151, 105, 53, 24, 12, 28, 59, 94, 130, 154, 166, 166, 159, 149, 139, 137, 134, 134, 
127, 117, 111, 111, 124, 143, 163, 185, 196, 204, 200, 168, 126, 71, 27, 11, 16, 52, 93, 127, 
156, 164, 166, 160, 151, 149, 140, 140, 132, 120, 111, 102, 103, 114, 129, 153, 172, 189, 198, 200, 
193, 165, 128, 82, 43, 24, 26, 49, 84, 117, 147, 159, 162, 158, 148, 146, 141, 141, 138, 129, 
124, 118, 122, 134, 149, 171, 186, 198, 195, 163, 127, 75, 37, 23, 27, 59, 93, 125, 150, 156, 
155, 149, 142, 146, 147, 148, 148, 131, 118, 101, 95, 105, 121, 148, 168, 183, 191, 191, 185, 167, 
139, 105, 68, 43, 32, 40, 64, 93, 121, 145, 156, 160, 156, 152, 148, 147, 145, 142, 140, 133, 
132, 134, 141, 156, 176, 194, 187, 158, 113, 58, 28, 15, 31, 67, 102, 135, 150, 152, 147, 139, 
134, 140, 148, 160, 160, 149, 129, 105, 94, 97, 114, 145, 172, 193, 201, 198, 189, 167, 141, 105, 
74, 47, 32, 31, 43, 67, 99, 129, 153, 167, 169, 166, 157, 152, 150, 151, 155, 158, 160, 160, 
160, 165, 176, 173, 150, 114, 65, 35, 25, 36, 65, 86, 108, 113, 115, 119, 124, 139, 154, 162, 
165, 159, 152, 147, 147, 153, 157, 160, 158, 159, 165, 176, 172, 149, 113, 61, 28, 13, 23, 56, 
92, 129, 150, 160, 156, 145, 134, 131, 135, 145, 158, 158, 152, 130, 109, 100, 101, 125, 153, 181, 
198, 201, 196, 174, 148, 115, 84, 61, 45, 42, 48, 62, 82, 108, 130, 152, 166, 171, 169, 160, 
153, 149, 149, 157, 166, 171, 172, 168, 168, 165, 144, 118, 77, 44, 24, 22, 43, 70, 103, 128, 
146, 152, 149, 143, 136, 137, 142, 151, 157, 160, 155, 141, 131, 121, 125, 141, 164, 193, 205, 197, 
164, 114, 67, 31, 22, 33, 56, 84, 109, 125, 134, 139, 140, 143, 148, 155, 162, 167, 167, 164, 
159, 153, 151, 154, 162, 174, 174, 158, 127, 83, 48, 25, 25, 43, 71, 101, 125, 141, 145, 143, 
141, 138, 142, 148, 156, 162, 165, 162, 151, 143, 132, 133, 142, 160, 181, 186, 173, 138, 94, 55, 
31, 31, 46, 70, 97, 118, 130, 137, 138, 137, 138, 143, 150, 160, 167, 169, 166, 159, 152, 147, 
148, 157, 171, 175, 164, 135, 95, 58, 35, 29, 41, 65, 92, 114, 130, 137, 140, 141, 140, 142, 
148, 156, 166, 172, 173, 168, 158, 146, 138, 140, 153, 167, 170, 156, 123, 85, 51, 34, 35, 52, 
76, 101, 122, 136, 142, 143, 142, 142, 143, 148, 157, 165, 172, 173, 168, 159, 149, 142, 144, 154, 
159, 156, 136, 104, 70, 44, 34, 40, 58, 85, 109, 129, 141, 145, 146, 143, 143, 143, 151, 158, 
167, 173, 173, 166, 157, 146, 143, 147, 156, 159, 152, 128, 95, 62, 39, 33, 43, 65, 91, 115, 
133, 143, 147, 147, 145, 144, 146, 152, 160, 169, 176, 176, 169, 159, 148, 141, 142, 145, 143, 130, 
107, 81, 57, 45, 43, 56, 78, 102, 124, 139, 148, 151, 149, 147, 145, 146, 151, 160, 169, 176, 
177, 170, 159, 146, 140, 136, 134, 129, 116, 98, 74, 56, 47, 51, 65, 87, 111, 130, 144, 151, 
153, 150, 147, 146, 147, 154, 164, 172, 179, 177, 170, 158, 147, 135, 128, 122, 111, 98, 82, 67, 
57, 55, 64, 81, 102, 123, 139, 150, 152, 154, 152, 149, 149, 151, 159, 167, 174, 177, 173, 165, 
152, 140, 128, 120, 111, 100, 89, 77, 68, 63, 67, 78, 94, 113, 129, 142, 149, 153, 154, 153, 
152, 153, 156, 161, 167, 172, 172, 167, 158, 149, 135, 125, 113, 101, 91, 79, 71, 67, 68, 76, 
90, 106, 121, 135, 144, 150, 152, 151, 152, 152, 154, 158, 163, 167, 168, 166, 160, 151, 141, 130, 
120, 109, 97, 88, 78, 72, 70, 74, 84, 98, 113, 127, 138, 144, 148, 149, 151, 150, 152, 154, 
158, 162, 163, 163, 159, 153, 145, 136, 127, 119, 109, 99, 90, 82, 76, 76, 81, 91, 103, 117, 
129, 138, 144, 146, 148, 149, 149, 150, 152, 156, 158, 160, 158, 155, 149, 141, 134, 127, 121, 112, 
103, 94, 87, 81, 81, 85, 93, 106, 116, 128, 137, 142, 146, 146, 146, 147, 147, 150, 153, 156, 
156, 156, 153, 147, 141, 134, 128, 122, 115, 108, 99, 92, 86, 84, 87, 94, 104, 117, 128, 137, 
143, 145, 146, 145, 146, 147, 149, 154, 156, 157, 155, 151, 146, 139, 133, 127, 121, 114, 106, 98, 
91, 86, 85, 89, 97, 107, 118, 130, 138, 143, 145, 146, 145, 144, 145, 146, 150, 153, 154, 154, 
152, 145, 140, 132, 125, 119, 114, 107, 101, 95, 92, 92, 95, 102, 111, 120, 129, 137, 141, 144, 
144, 144, 143, 144, 145, 148, 150, 151, 150, 147, 141, 136, 130, 124, 119, 116, 111, 107, 103, 100, 
98, 100, 105, 112, 121, 128, 134, 139, 141, 140, 141, 140, 140, 141, 143, 145, 147, 146, 145, 141, 
136, 130, 125, 119, 117, 113, 111, 108, 106, 106, 106, 109, 114, 119, 126, 131, 135, 137, 139, 139, 
139, 139, 138, 138, 140, 141, 141, 139, 137, 133, 129, 126, 122, 119, 118, 115, 113, 113, 112, 113, 
116, 119, 122, 126, 130, 132, 134, 135, 136, 136, 136, 137, 138, 138, 138, 138, 138, 135, 133, 130, 
126, 122, 120, 120, 118, 118, 117, 117, 118, 120, 122, 124, 126, 128, 131, 131, 133, 134, 133, 134, 
134, 134, 134, 135, 134, 134, 133, 132, 129, 127, 124, 123, 123, 120, 121, 121, 122, 122, 123, 124, 
125, 126, 129, 130, 131, 133, 133, 133, 133, 133, 133, 133, 133, 133, 132, 131, 130, 129, 128, 126, 
125, 123, 123, 123, 123, 125, 124, 127, 127, 128, 128, 128, 129, 129, 130, 130, 131, 130, 131, 130, 
131, 131, 129, 130, 130, 129, 129, 128, 127, 127, 126, 125, 126, 126, 125, 125, 126, 126, 126, 127, 
129, 128, 129, 129, 130, 130, 130, 130, 130, 131, 130, 130, 130, 129, 129, 129, 128, 127, 127, 126, 
126, 125, 126, 126, 127, 127, 126, 127, 128, 127, 128, 128, 129, 129, 130, 129, 129, 130, 129, 128, 
129, 129, 128, 129, 130, 128, 128, 127, 126, 125, 126, 126, 126, 126, 127, 128, 128, 127, 129, 128, 
128, 129, 128, 129, 129, 128, 128, 128, 127, 128, 128, 128, 128, 129, 127, 128, 127, 127, 127, 127, 
127, 128, 127, 127, 128, 128, 129, 128, 128, 128, 128, 128, 127, 128, 127, 128, 129, 129, 129, 128, 
129, 127, 128, 127, 127, 129, 129, 129, 128, 127, 127, 127, 127, 127, 127, 128, 128, 128, 128, 129, 
130, 128, 128, 128, 128, 128, 128, 127, 129, 128, 129, 128, 128, 129, 128, 128, 128, 128, 128, 127, 
128, 129, 128, 128, 128, 128, 129, 128, 129, 128, 128, 129, 128, 128, 128, 129, 129, 129, 128, 129, 
127, 128, 128, 128, 129, 128, 127, 127, 128, 128, 128, 129, 128, 128, 129, 129, 129, 128, 128, 128, 
128, 127, 127, 128, 129, 128, 129, 129, 127, 126, 127, 126, 128, 128, 129, 128, 129, 128, 128, 127, 
128, 127, 128, 128, 129, 130, 129, 128, 128, 127, 125, 127, 128, 129, 130, 129, 129, 128, 126, 126, 
127, 128, 129, 129, 129, 128, 128, 126, 127, 127, 127, 127, 128, 129, 129, 129, 129, 128, 127, 127, 
127, 127, 128, 129, 128, 128, 127, 128, 128, 127, 128, 128, 128, 129, 129, 127, 127, 127, 128, 127, 
128, 128, 129, 127, 129, 128, 129, 128, 129, 128, 128, 127, 128, 129, 129, 128, 129, 129, 128, 128, 
127, 128, 128, 128, 129, 128, 129, 129, 128, 128, 128, 128, 129, 128, 129, 128, 129, 128, 128, 128, 
128, 129, 129, 129, 129, 126, 124, 122, 122, 125, 126, 131, 132, 132, 131, 129, 129, 128, 126, 128, 
129, 132, 134, 135, 135, 129, 127, 124, 125, 129, 133, 133, 132, 129, 128, 127, 129, 130, 131, 130, 
128, 127, 127, 127, 127, 128, 129, 129, 129, 128, 126, 125, 124, 125, 128, 130, 131, 129, 127, 125, 
126, 127, 128, 128, 128, 127, 128, 127, 127, 128, 129, 127, 127, 126, 127, 128, 129, 130, 129, 127, 
125, 124, 126, 128, 130, 131, 129, 125, 126, 126, 127, 128, 128, 127, 127, 127, 127, 127, 127, 128, 
127, 127, 127, 127, 127, 127, 127, 126, 128, 128, 128, 128, 128, 127, 127, 128, 128, 127, 127, 127, 
127, 127, 129, 129, 129, 129, 128, 127, 127, 128, 126, 127, 127, 128, 129, 129, 128, 127, 127, 126, 
127, 128, 128, 129, 129, 126, 126, 127, 128, 130, 131, 129, 127, 127, 127, 129, 129, 128, 128, 128, 
129, 129, 127, 127, 128, 129, 129, 129, 127, 126, 127, 128, 130, 129, 127, 125, 126, 127, 129, 131, 
129, 128, 128, 129, 129, 128, 128, 128, 129, 128, 128, 129, 127, 127, 129, 129, 129, 127, 128, 128, 
129, 129, 129, 129, 128, 127, 126, 127, 127, 128, 130, 128, 127, 127, 128, 128, 127, 127, 128, 131, 
132, 130, 129, 126, 127, 129, 129, 129, 127, 126, 126, 128, 130, 130, 129, 128, 128, 129, 130, 129, 
129, 128, 128, 129, 128, 128, 127, 129, 129, 130, 129, 128, 127, 129, 130, 130, 128, 128, 127, 128, 
129, 130, 129, 126, 127, 127, 129, 129, 129, 128, 127, 129, 129, 128, 127, 127, 128, 129, 129, 127, 
126, 127, 129, 129, 129, 126, 126, 128, 128, 129, 127, 126, 126, 128, 129, 128, 128, 128, 129, 128, 
128, 128, 128, 129, 129, 127, 125, 126, 127, 130, 129, 128, 125, 127, 129, 129, 130, 128, 126, 128, 
127, 128, 128, 127, 127, 127, 128, 127, 127, 128, 128, 127, 127, 127, 127, 128, 128, 128, 127, 127, 
127, 126, 127, 128, 130, 129, 128, 128, 127, 128, 129, 127, 128, 129, 129, 128, 128, 128, 129, 129, 
128, 127, 127, 129, 129, 129, 128, 127, 129, 128, 130, 128, 128, 127, 128, 128, 129, 129, 129, 129, 
129, 128, 128, 127, 128, 128, 128, 128, 127, 128, 127, 128, 128, 129, 128, 128, 128, 129, 129, 129, 
127, 127, 127, 128, 129, 128, 128, 128, 128, 129, 128, 129, 128, 129, 129, 129, 128, 127, 127, 129, 
129, 128, 129, 128, 128, 129, 128, 127, 126, 128, 129, 129, 129, 128, 128, 128, 127, 127, 128, 129, 
128, 128, 127, 128, 128, 127, 128, 127, 127, 128, 128, 129, 128, 128, 127, 127, 128, 129, 129, 128, 
129, 128, 128, 126, 128, 127, 129, 129, 128, 127, 129, 128, 128, 128, 127, 128, 128, 128, 128, 128, 
129, 128, 128, 128, 128, 128, 128, 127, 127, 129, 129, 128, 127, 127, 129, 129, 128, 128, 128, 128, 
128, 126, 127, 128, 128, 128, 128, 127, 127, 129, 129, 129, 127, 126, 126, 128, 129, 128, 128, 129, 
128, 128, 127, 127, 128, 128, 128, 128, 129, 129, 128, 127, 127, 128, 128, 129, 129, 129, 128, 129, 
129, 128, 129, 129, 128, 128, 129, 129, 129, 129, 129, 129, 129, 128, 128, 129, 129, 129, 128, 129, 
128, 128, 128, 128, 128, 130, 129, 129, 129, 129, 129, 128, 127, 127, 128, 129, 129, 128, 128, 128, 
128, 128, 127, 128, 129, 129, 129, 129, 129, 129, 128, 127, 127, 129, 129, 128, 128, 128, 128, 127, 
127, 127, 127, 128, 128, 128, 128, 127, 128, 128, 127, 128, 128, 128, 128, 129, 128, 128, 127, 128, 
128, 128, 128, 128, 129, 128, 128, 128, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 127, 
128, 129, 128, 128, 129, 129, 128, 127, 128, 127, 127, 128, 129, 128, 128, 128, 129, 129, 127, 128, 
128, 128, 129, 128, 128, 129, 128, 128, 128, 128, 128, 129, 128, 129, 128, 129, 129, 128, 127, 129, 
128, 128, 127, 127, 127, 129, 129, 128, 127, 128, 128, 128, 127, 127, 128, 129, 128, 128, 127, 128, 
128, 126, 126, 128, 128, 128, 128, 127, 128, 128, 127, 128, 127, 128, 128, 128, 128, 128, 128, 127, 
127, 128, 128, 127, 128, 127, 128, 128, 128, 127, 127, 128, 128, 128, 129, 128, 127, 127, 128, 128, 
128, 128, 127, 127, 128, 128, 128, 129, 128, 128, 129, 128, 128, 129, 128, 128, 128, 129, 129, 127, 
128, 128, 129, 128, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 127, 128, 128, 128, 129, 
128, 128, 129, 129, 128, 128, 128, 128, 127, 128, 128, 129, 128, 128, 128, 128, 128, 128, 128, 129, 
128, 128, 128, 128, 128, 128, 128, 128, 129, 128, 128, 128, 128, 129, 129, 128, 129, 128, 128, 128, 
128, 128, 128, 128, 128, 129, 128, 127, 128, 128, 128, 127, 128, 128, 128, 128, 128, 128, 127, 128, 
128, 127, 128, 128, 128, 127, 128, 127, 128, 127, 128, 128, 128, 128, 128, 128, 128, 128, 128, 127, 
128, 128, 127, 128, 128, 128, 127, 128, 128, 128, 128, 127, 128, 128, 128, 128, 128, 127, 128, 127, 
127, 127, 128, 128, 128, 128, 128, 127, 127, 128, 127, 128, 127, 128, 128, 127, 127, 127, 127, 128, 
128, 127, 128, 128, 128, 128, 128, 128, 129, 127, 128, 128, 128, 128, 128, 128, 129, 128, 129, 128, 
127, 128, 128, 129, 128, 128, 128, 128, 128, 128, 128, 128, 129, 128, 129, 129, 128, 128, 128, 128, 
127, 129, 129, 128, 129
};

And I use this code (terrible quick hack) to get the raw wave data out of the wave files, though, you really need to be sure the input is in the right format with the right sample rate and resolution:

#include <stdio.h>


int main(int argc, char **argv)
{
  FILE *wf,*hf;
  int   i,c;

  if( argc < 3 ) {
    fprintf(stderr,"Usage:\n\tw2c <wave> <source>\n");
    return 1;
  }

  wf = fopen(argv[1],"r");
  hf = fopen(argv[2],"w");

  fprintf(hf,"const unsigned char bu_data[]=\n{\n");
  for(i=0; (c=fgetc(wf)) != EOF; i++) {
    // Skip header
    if( i < 44 ) continue;
    // Write to h file
    fprintf(hf,"%u, ",((unsigned char)(c)));
    if( !(i%10) ) fprintf(hf,"\n");
  }
  fprintf(hf,"\n};\n");

  return 0;
}

I also glued the hall-effect sensor to the inside of the mailbox by the door with Ryan, for door open/close sensing:



And there is some Arduino code for reading the sensor as well:

#define STATE_NEAR 1
#define STATE_FAR  2
#define RESET      50

const int analogInPin = A0;  

int sensorValue = 0;

int counter = 0;
int state   = STATE_FAR;

void setup() {
  Serial.begin(9600); 
}

void loop() {
  sensorValue = analogRead(analogInPin);            
  outputValue = map(sensorValue, 0, 1023, 0, 255);  
  
  if( sensorValue == 0 || sensorValue == 255) {
    counter = RESET;
    state = STATE_FAR;
  } else {
    if( counter ) counter--; 
  }
  
  if( counter == 0 ) {
     state = STATE_NEAR;
  }

  Serial.print(state);                       
  Serial.print("  ");      
  Serial.println(counter);   

  delay(2);                     
}

Day 2.5   (12/28/2013):

The camera came in the mail, so I soldered on some Cat5 twisted pair for power and the TTL serial interface.



This is the example provided from AdaFruit for taking a still image with the camera:
(> git clone "https://github.com/adafruit/Adafruit-VC0706-Serial-Camera-Library.git")

// This is a basic snapshot sketch using the VC0706 library.
// On start, the Arduino will find the camera and SD card and
// then snap a photo, saving it to the SD card.
// Public domain.

// If using an Arduino Mega (1280, 2560 or ADK) in conjunction
// with an SD card shield designed for conventional Arduinos
// (Uno, etc.), it's necessary to edit the library file:
//   libraries/SD/utility/Sd2Card.h
// Look for this line:
//   #define MEGA_SOFT_SPI 0
// change to:
//   #define MEGA_SOFT_SPI 1
// This is NOT required if using an SD card breakout interfaced
// directly to the SPI bus of the Mega (pins 50-53), or if using
// a non-Mega, Uno-style board.

#include <Adafruit_VC0706.h>
#include <SD.h>

// comment out this line if using Arduino V23 or earlier
#include <SoftwareSerial.h>         

// uncomment this line if using Arduino V23 or earlier
// #include <NewSoftSerial.h>       

// SD card chip select line varies among boards/shields:
// Adafruit SD shields and modules: pin 10
// Arduino Ethernet shield: pin 4
// Sparkfun SD shield: pin 8
// Arduino Mega w/hardware SPI: pin 53
// Teensy 2.0: pin 0
// Teensy++ 2.0: pin 20
#define chipSelect 10

// Pins for camera connection are configurable.
// With the Arduino Uno, etc., most pins can be used, except for
// those already in use for the SD card (10 through 13 plus
// chipSelect, if other than pin 10).
// With the Arduino Mega, the choices are a bit more involved:
// 1) You can still use SoftwareSerial and connect the camera to
//    a variety of pins...BUT the selection is limited.  The TX
//    pin from the camera (RX on the Arduino, and the first
//    argument to SoftwareSerial()) MUST be one of: 62, 63, 64,
//    65, 66, 67, 68, or 69.  If MEGA_SOFT_SPI is set (and using
//    a conventional Arduino SD shield), pins 50, 51, 52 and 53
//    are also available.  The RX pin from the camera (TX on
//    Arduino, second argument to SoftwareSerial()) can be any
//    pin, again excepting those used by the SD card.
// 2) You can use any of the additional three hardware UARTs on
//    the Mega board (labeled as RX1/TX1, RX2/TX2, RX3,TX3),
//    but must specifically use the two pins defined by that
//    UART; they are not configurable.  In this case, pass the
//    desired Serial object (rather than a SoftwareSerial
//    object) to the VC0706 constructor.

// Using SoftwareSerial (Arduino 1.0+) or NewSoftSerial (Arduino 0023 & prior):
#if ARDUINO >= 100
// On Uno: camera TX connected to pin 2, camera RX to pin 3:
SoftwareSerial cameraconnection = SoftwareSerial(2, 3);
// On Mega: camera TX connected to pin 69 (A15), camera RX to pin 3:
//SoftwareSerial cameraconnection = SoftwareSerial(69, 3);
#else
NewSoftSerial cameraconnection = NewSoftSerial(2, 3);
#endif

Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);

// Using hardware serial on Mega: camera TX conn. to RX1,
// camera RX to TX1, no SoftwareSerial object is required:
//Adafruit_VC0706 cam = Adafruit_VC0706(&Serial1);

void setup() {

  // When using hardware SPI, the SS pin MUST be set to an
  // output (even if not connected or used).  If left as a
  // floating input w/SPI on, this can cause lockuppage.
#if !defined(SOFTWARE_SPI)
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  if(chipSelect != 53) pinMode(53, OUTPUT); // SS on Mega
#else
  if(chipSelect != 10) pinMode(10, OUTPUT); // SS on Uno, etc.
#endif
#endif

  Serial.begin(9600);
  Serial.println("VC0706 Camera snapshot test");
  
  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }  
  
  // Try to locate the camera
  if (cam.begin()) {
    Serial.println("Camera Found:");
  } else {
    Serial.println("No camera found?");
    return;
  }
  // Print out the camera version information (optional)
  char *reply = cam.getVersion();
  if (reply == 0) {
    Serial.print("Failed to get version");
  } else {
    Serial.println("-----------------");
    Serial.print(reply);
    Serial.println("-----------------");
  }

  // Set the picture size - you can choose one of 640x480, 320x240 or 160x120 
  // Remember that bigger pictures take longer to transmit!
  
  cam.setImageSize(VC0706_640x480);        // biggest
  //cam.setImageSize(VC0706_320x240);        // medium
  //cam.setImageSize(VC0706_160x120);          // small

  // You can read the size back from the camera (optional, but maybe useful?)
  uint8_t imgsize = cam.getImageSize();
  Serial.print("Image size: ");
  if (imgsize == VC0706_640x480) Serial.println("640x480");
  if (imgsize == VC0706_320x240) Serial.println("320x240");
  if (imgsize == VC0706_160x120) Serial.println("160x120");

  Serial.println("Snap in 3 secs...");
  delay(3000);

  if (! cam.takePicture()) 
    Serial.println("Failed to snap!");
  else 
    Serial.println("Picture taken!");
  
  // Create an image with the name IMAGExx.JPG
  char filename[13];
  strcpy(filename, "IMAGE00.JPG");
  for (int i = 0; i < 100; i++) {
    filename[5] = '0' + i/10;
    filename[6] = '0' + i%10;
    // create if does not exist, do not open existing, write, sync after write
    if (! SD.exists(filename)) {
      break;
    }
  }
  
  // Open the file for writing
  File imgFile = SD.open(filename, FILE_WRITE);

  // Get the size of the image (frame) taken  
  uint16_t jpglen = cam.frameLength();
  Serial.print("Storing ");
  Serial.print(jpglen, DEC);
  Serial.print(" byte image.");

  int32_t time = millis();
  pinMode(8, OUTPUT);
  // Read all the data up to # bytes!
  byte wCount = 0; // For counting # of writes
  while (jpglen > 0) {
    // read 32 bytes at a time;
    uint8_t *buffer;
    uint8_t bytesToRead = min(32, jpglen); // change 32 to 64 for a speedup but may not work with all setups!
    buffer = cam.readPicture(bytesToRead);
    imgFile.write(buffer, bytesToRead);
    if(++wCount >= 64) { // Every 2K, give a little feedback so it doesn't appear locked up
      Serial.print('.');
      wCount = 0;
    }
    //Serial.print("Read ");  Serial.print(bytesToRead, DEC); Serial.println(" bytes");
    jpglen -= bytesToRead;
  }
  imgFile.close();

  time = millis() - time;
  Serial.println("done!");
  Serial.print(time); Serial.println(" ms elapsed");
}

void loop() {
}


Day 2   (12/22/2013):

The Liquid Nails glue we had used to connect the flag to the stepper motor wasn't very good for such a task. I got some Loctite two-part epoxy from the hardware store that worked _much_ better.







Also, a tiny bit of coding has been done. There is at least a mashup of some of the example Arduino scripts, which supports some of the features that iSmartMailboxHD.com will need:

#include <SPI.h>
#include <WiFi.h>
#include <SD.h>
#include <Stepper.h>


const int steps = 505;

File root;

char ssid[]  = "SSID_HERE";
char pass[]  = "WPA2_KEY_HERE";
int keyIndex = 0;   // network key index number (only for WEP)

int status = WL_IDLE_STATUS;

WiFiServer server(80);

// Initialize stepper library on specified pins
Stepper myStepper(steps, 37,35,36,34);  

void setup() {
  Serial.begin(9600);
  pinMode(9, OUTPUT);  

  myStepper.setSpeed(25);

  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present"); 
    while(true);  
  } 

  while ( status != WL_CONNECTED) { 
    Serial.print("Attempting to connect to Network named: ");
    Serial.println(ssid);          

    status = WiFi.begin(ssid, pass);
    // wait 10 seconds for connection:
    delay(10000);
  } 
  server.begin();                           // start the web server on port 80
  printWifiStatus();                        // you're connected now, so print out the status
  
  Serial.print("Initializing SD card...");
  pinMode(4, OUTPUT);

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  //root = SD.open("/");
  //printDirectory(root, 0);
  
  Serial.println("done!");
}


void loop() {
  WiFiClient client = server.available();   // listen for incoming clients

  if (client) {                             // if you get a client,
    Serial.println("new client");           // print a message out the serial port
    String currentLine = "";                // make a String to hold incoming data from the client
    while (client.connected()) {            // loop while the client's connected
      if (client.available()) {             // if there's bytes to read from the client,
        char c = client.read();             // read a byte, then
        Serial.write(c);                    // print it out the serial monitor
        if (c == '\n') {                    // if the byte is a newline character

          // if the current line is blank, you got two newline characters in a row.
          // that's the end of the client HTTP request, so send a response:
          if (currentLine.length() == 0) {  
            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
            // and a content-type so the client knows what's coming, then a blank line:    
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println();

            // the content of the HTTP response follows the header:
            client.print("<html><body>");
            client.print("Click <a href=\"/H\">here</a> to move the flag up.<br>");
            client.println("Click <a href=\"/L\">here</a> to move the flag down.<br><br>");

            //if( root ) root.close();
            //root = SD.open("/");
            //cprintDirectory(client, root, 0);
            
            client.print("</body></html>");

            // The HTTP response ends with another blank line:
            client.println();
            
            // break out of the while loop:
            break;         
          } 
          else {      // if you got a newline, then clear currentLine:
            currentLine = "";
          }
        }     
        else if (c != '\r') {    // if you got anything else but a carriage return character,
          currentLine += c;      // add it to the end of the currentLine
        }

        // Check to see if the client request was "GET /H" or "GET /L":
        if (currentLine.endsWith("GET /H")) {
          digitalWrite(9, HIGH);               // GET /H turns the LED on
          myStepper.step(steps);
        }
        if (currentLine.endsWith("GET /L")) {
          digitalWrite(9, LOW);                // GET /L turns the LED off
          myStepper.step(-steps);
        }
      }
    }
    // close the connection:
    client.stop();
    Serial.println("client disonnected");
  }
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
  // print where to go in a browser:
  Serial.print("To see this page in action, open a browser to http://");
  Serial.println(ip);
}

void printDirectory(File dir, int numTabs) {
  while(true) {
     
    File entry =  dir.openNextFile();
    if (! entry) {
      // no more files
      //Serial.println("**nomorefiles**");
      break;
    }
    for (uint8_t i=0; i<numTabs; i++) {
      Serial.print('\t');
    }
    Serial.print(entry.name());
    if (entry.isDirectory()) {
      Serial.println("/");
      printDirectory(entry, numTabs+1);
    } else {
      // files have sizes, directories do not
      Serial.print("\t\t");
      Serial.println(entry.size(), DEC);
    }
    entry.close();
  }
}

void cprintDirectory(WiFiClient client, File dir, int numTabs) {
  while(true) {
     
    File entry =  dir.openNextFile();
     
    if (! entry) {
      // no more files
      break;
    }
    for (uint8_t i=0; i<numTabs; i++) {
      client.print("&nbsp;&nbsp;");
    }
    client.print(entry.name());
    if (entry.isDirectory()) {
      client.println("/<br>");
      cprintDirectory(client, entry, numTabs+1);
    } else {
      // files have sizes, directories do not
      client.print("&nbsp;&nbsp;&nbsp;&nbsp;");
      client.print(entry.size(), DEC);
      client.println("<br>");
    }
    entry.close();
  }
}

Day 1.5   (12/20/2013):

I connected the stepper motor and gave the flag control a quick try:



Day 1   (12/15/2013):

Just got started today. We have a couple of mailboxes to use to mockup parts as we go. We'll get all the electrical work and code done with a simple mounting on a first boxen, and then remount things more permanently on a "real" mailbox at the curb. For the first day we talked about the design a bit and at least mounted a stepper motor to the mailbox, and attached the flag to the stepper.





Day 0:

What is an iSmartMailboxHD.com? An iSmartMailboxHD.com is a mailbox with some of the following properties:

  • Based on Arduino.
  • Solar-powered with battery backup.
  • Flag position sense and control.
  • Equipped with a camera.
  • WiFi-enabled: e-mails or SMS texts you when mail arrives/departs.
  • Scale reporting mail's weight.
  • Audio message to thank the mailman.
  • Secure mail deposit.

  • Some recommended parts to get started:
    Arduino ATmega2560:
    http://www.newegg.com/Product/Product.aspx?Item=9SIA2E60ZE1984
    Arduino WiFi Shield:
    https://www.sparkfun.com/products/11287
    TTL Serial Camera:
    http://www.adafruit.com/products/397
    Stepper Motor:
    http://www.ebay.com/itm/5V-DC-Stepper-Step-Motor-and-Driver-Test-Module-Board-ULN2003-For-Arduino-/261345465843?pt=LH_DefaultDomain_0&hash=item3cd96755f3
    SD Card Slot:
    http://www.ebay.com/itm/New-SD-Card-Module-Slot-Socket-Reader-LC-Studio-3-3-5V-For-Arduino-ARM-MCU-NEW-/261076314932?pt=LH_DefaultDomain_0&hash=item3cc95c6b34
    Hall Effect Sensor:
    http://dx.com/p/hall-magnetic-sensor-module-for-arduino-dc-5v-135033
    Light Sensor:
    http://www.ebay.com/itm/3-3-5V-input-LM393-light-Sensor-Module-for-Arduino-DO-AO-output-Dupont-cables-/310532141291?pt=LH_DefaultDomain_0&hash=item484d2870eb

    Some quick references for wiring and coding some of these:

  • http://arduino.cc/en/Reference/WiFi
  • http://arduino.cc/en/Reference/SD
  • http://arduino.cc/en/reference/serial
  • http://arduino.cc/en/reference/stepper