Just the Terrells

June 26, 2010

Getting useful Data from an web4robot i2c LCD into an Arduino.

Filed under: Arduino — Ken @ 3:00 pm

I got the coolest Christmas present ever, and I am finally starting to do something with it!!!

#include < WString.h >
#include < Wire.h >
#include < LCDi2cW.h >

// Doing something slightly useful with the Aduino and my web4robot i2c LCD and 4×4 keypad
// Ken Terrell

#define VERSION “1.0b”

#define KEYPAD_BUTTON_1     1
#define KEYPAD_BUTTON_4     2
#define KEYPAD_BUTTON_7     3
#define KEYPAD_BUTTON_STAR  4
#define KEYPAD_BUTTON_2     5
#define KEYPAD_BUTTON_5     6
#define KEYPAD_BUTTON_8     7
#define KEYPAD_BUTTON_0     8
#define KEYPAD_BUTTON_3     9
#define KEYPAD_BUTTON_6     10
#define KEYPAD_BUTTON_9     11
#define KEYPAD_BUTTON_POUND 12
#define KEYPAD_BUTTON_A     13
#define KEYPAD_BUTTON_B     14
#define KEYPAD_BUTTON_C     15
#define KEYPAD_BUTTON_D     16

#define maxLength  8

LCDi2cW lcd = LCDi2cW(4,20,0×4C,0);             // Number of lines and i2c address of the display

int lcdBacklight = 60;
char SecretCode[] = “1234″;
String Guess = String(maxLength);
char charGuess;
int keyInput = 0;
int ledPin = 12;

void setup()
{
  Serial.begin(9600);
  Serial.print(”Secret Code Box v”);
  Serial.println(VERSION);
  Serial.println(”");
  Serial.println(”Written by Ken Terrell”);
  Serial.println(”");

  lcd.init();                           // Init the display, clears the display

  pinMode(ledPin, OUTPUT);

  resetAll();
  splashscreen();
  mainscreen();
}

void loop()
{
  charGuess = processKey(); //Get a keypress from the keypad if one is available.

  if (charGuess) // We got one.
  {
    if (charGuess == ‘A’)
    { // End of Input, Check Results. Celebrate. Reset. and Redraw main screen.
      if(checkResults()) //checkResults is TRUE if you guessed the secret.
      {
        celebrate();
      }
      resetAll();
      mainscreen();
    }
    else if (Guess.length() < maxLength){
      Guess.append(charGuess);
      lcd.setCursor(2,Guess.length());
      lcd.print('*');
    }

    while(processKey()) //Now we need to spin our wheels while until the user releases the key.
    { // do nothing in here just waiting on the user.
      // delay(20); // if we need to throttle back the i2c bus usage.
    }
  }

}

int checkResults() //return a 1 if correct, a 0 if incorrect.
{
  lcd.cursor_off();
  lcd.blink_off();
  lcd.clear();
  lcd.print("Your Guess was :");
  lcd.setCursor(1,0);
  lcd.print(Guess);
  lcd.setCursor(2,0);
  if (Guess.equals(SecretCode)){
    lcd.print("Congrats!");
    return(1);
  }
  else {
    lcd.print("Bummer....");
    delay(3000);
    return(0);
  }
}

void celebrate()
{
  for (int i=0; i<10; i++)
  {
    digitalWrite(ledPin, LOW);
    lcd.setBacklight(255);
    digitalWrite(ledPin, HIGH);
    lcd.setBacklight(0);
  }
}

void resetAll() //clear all strings and reset settings back to normal.
{
  Guess = NULL;
  digitalWrite(ledPin, LOW);
  lcd.setBacklight(lcdBacklight);
  lcd.cursor_off();
  lcd.blink_off();
}  

char processKey() // read character from keypad translate to correct letter and return it.
{
  char pressed;

  int localkey;
  localkey=lcd.keypad();
  switch(localkey){
  case KEYPAD_BUTTON_1:
    pressed = '1';
    break;
  case KEYPAD_BUTTON_2:
    pressed = '2';
    break;
  case KEYPAD_BUTTON_3:
    pressed = '3';
    break;
  case KEYPAD_BUTTON_4:
    pressed = '4';
    break;
  case KEYPAD_BUTTON_5:
    pressed = '5';
    break;
  case KEYPAD_BUTTON_6:
    pressed = '6';
    break;
  case KEYPAD_BUTTON_7:
    pressed = '7';
    break;
  case KEYPAD_BUTTON_8:
    pressed = '8';
    break;
  case KEYPAD_BUTTON_9:
    pressed = '9';
    break;
  case KEYPAD_BUTTON_0:
    pressed = '0';
    break;
  case KEYPAD_BUTTON_A:
    pressed = 'A';
    break;
  case KEYPAD_BUTTON_B:
    pressed = 'B';
    break;
  case KEYPAD_BUTTON_C:
    pressed = 'C';
    break;
  case KEYPAD_BUTTON_D:
    pressed = 'D';
    break;
  case KEYPAD_BUTTON_STAR:
    pressed = '*';
    break;
  case KEYPAD_BUTTON_POUND:
    pressed = '#';
    break;
  }
  return(pressed);
}

void splashscreen() {
  lcd.setCursor(0,2);
  lcd.print("Keypad Ver ");             // Show Version
  lcd.print(VERSION);
  lcd.setCursor(3,0);
  lcd.print("www.bloomingfool.net");
  lcd.setCursor(1,4);
  lcd.print("Ken Terrell");
  delay(3000);
  lcd.clear();
}

void mainscreen() {
  beeper();
  lcd.clear();
  lcd.print("Enter the Secret!");
  lcd.setCursor(1,0);
  lcd.print("Then press 'A'.");
  lcd.setCursor(2,0);
  lcd.print("> “);
  lcd.cursor_on();
  lcd.blink_on();
  lcd.setCursor(2,1);
}

void beeper()
{
  digitalWrite(ledPin, HIGH);
  delay(50);
  digitalWrite(ledPin, LOW);
  delay(50);
}

November 9, 2008

Good boy.

Filed under: Uncategorized — Ken @ 11:19 am

Well, we knew it was coming…but it still sucks.

We had to put Bogie down Sunday night. He had been having a lot of trouble breathing the last six months or so, It finally got to be too much to bear. The kids were up this weekend, and everybody got to say goodbye. I gave Bogie at least a half a pack of Bacon, and the kids fed him so much pizza and goodies that his gas was nearly unbearable. He could literally make your eyes water.

We had planned to put him down Tuesday afternoon (Nate had a band trip to Disneyland, and we wanted to wait). God had different plans. Sunday night Bogie got too uncomfortable, and we decided to do it early.

He laid down his head and went to sleep. It was the right thing, but I wish we had more time. I will and do miss him a lot.

Good Boy

Good Boy.

October 26, 2008

Deer Hunting 2008

Filed under: Family — Ken @ 11:08 am

I went out a few days earlier than the kids. I got the camper all set up and spent a relaxing couple of days driving/hiking around to our ‘Secret Spots’ looking for the Deer. This year the weather was really warm compared to every other year. Hot and dusty was the theme.

Something about the weather kept the deer confused. There were no Bucks any where in our normal happy hunting grounds. The Elk were even more scarce. All the other hunters said ‘Go high’. So up we went.

Lisa, Nate, and Matt showed up Wednesday morning. That morning I found the Deer, a little fork buck. I was watching him through the binoculars when Nate called and said they were about an hour away. “This should be easy” I though. Go back to camp, get the kids together, and head back out and shoot this deer.

Not so.

Nate, Matt and I spent the next two days looking all over the mountain to no avail. Nate and Lisa left Thursday night to get Nate back for band competition.

Friday afternoon, Matt and I were sitting in some scrub aspen, looking across the valley to the other side. I shouldn’t say sitting, we were standing. If we sat, we wouldn’t have been able to see the other side. After about 45 minutes, legs tired, feet asleep, I spotted a deer bounding up the valley, coming out the very bottom and quartering up the other side of the valley.

Matt loaded up and fired. After a few shots, Matt got a clean hit. Not a bad shot, standing, 150 yards with a 1940’s vintage military surplus rifle, open sites. One more shot to finish the deer, and Matt had officially downed a 10 point buck.

Matt

It took a little help from the ‘California guys’ to get him into the back of the Bronco, and we were skinning and hanging him in camp Saturday morning.

Deer Hunting 2008

All in all, a LOT of work, but a great trip.

August 6, 2008

Nerd God.

Filed under: Uncategorized — Ken @ 8:44 am

I am nerdier than 99% of all people.


I am nerdier than 99% of all people. Are you a nerd? Click here to find out!

July 24, 2008

Now Stop!

Filed under: Uncategorized — Ken @ 7:07 am

Yesterday Tim and I replaced the Brake pads on the Bronco. Actually I can’t really say that. Tim replaced the brake pads without any real help. Basically a few “Like this?” and a couple of “This doesn’t fit right.” questions was all he asked.

We bled the system and fixed the brake light wiring and the brakes work great.

Thanks Tim

June 13, 2008

Maybe we should have thought it through

Filed under: Uncategorized — Ken @ 2:44 pm

Looking back, setting our goal for emergency room visits to 4 for last year might have been a mistake. We had to injure the kids twice just to meet the goal. Well this year we set the goal to zero.

Apparently Nate set his goals a little higher in the Terrell/Anderson summer injury-off. Nate has jumped out to a spectacular early lead with a Broken Collarbone/road rash combo which will be difficult to top.

Nate wrecked in the street behind our house, and skidded down the pavement on his helmet (Yes, he was actually wearing ihs helmet even though there were no grown-ups around). He got a little road rash on his shoulder, elbow, and knee, butis going to be just fine.

Nate and Nurse

Matt, who has always been proud of his broken collar bone xray could only say “Holy Crap!” when he saw Nate’s Xray. This is a very impressive break. Nate should be proud.

Nate X-Ray

March 23, 2008

So why doesn’t anyone beleive me?

Filed under: Uncategorized — Ken @ 8:31 am

I really did manage to get Lisa’s car in the garage. Actually, it is snowing outside right now, and the car is comfortably tucked away within four walls. I built a little worksurface on the south wall today. But really, Lisa’s car is inside. It really is.

Happy Lisa

February 26, 2008

So who says you can’t buy a good car for $300?

Filed under: Uncategorized — Ken @ 6:23 pm

I have been talking to a guy on craigslist since January, he had a 1997 Thunderbird, 4.6L V8 which “needed a new computer”, had a dent in the back bumper, and a broken parking light. All for the low low price of $300. It took us almost a month to find a time when we were both off work and not sick. Finally, last night Lisa and I went to take a look.

It was the same crappy green color as the cougar, a little old and run down in the interior, and had a big smash in the front fender……Oh wait a minute, this is not a 1997. I guess it is THAT one over there.

Da Car 01

Immaculate on the inside, nice clear paint, and a little ding in the back bumper, and it needs a new turn signal lens.

I brought it home, futzed with it all day, and while setting the clock, it suddenly started running right. I just got back from a trip around the neighborhood. It is great.

Da Car 02

November 17, 2007

Monkey Kick off

Filed under: Uncategorized — Ken @ 4:37 pm

Monkey Kick-off

November 15, 2007

The gift exchange

Filed under: Uncategorized — Ken @ 1:03 pm

It started sometime ago, I am not really sure when or how, but Sara and Lisa’s co-worker Jenny started exchanging gifts. Nothing too extravagant, a half eaten doughnut, a calculator ribbon, little things like that. Just to show each other that they care. Well, Sara up the ante big time by giving Jenny an extra special gift… Here is the note Sara wrote.

Dearest Jenny:

Let me tell you. That Calculator Ink you gave me just swept me off my monster feet. I still have it right here, and every time I look at calculators, I think of you. It just breaks my heart that that is my only evidence of your existence currently in this world. Let me tell you something. Every time you go to bed, I bet you would like to have a little company, right. (Don’t worry, I ain’t a perv.) Well, knowing that the half-eaten doughnut I gave you wasn’t enough, I figured it was about time for me to upgrade your gifts. I told this creature that you were the best, and I told him ALL about you. It made him teary. So for days, and weeks, and months he labored, sweated, suffered and cried just to give you this. Honestly, I think you should give him a little credit. After all, all I did was crack him with a whip if he slept or took a lunch break.

Anyway, one morning I woke, and right in the middle of his house, was the present. Just lying their like a helpless, hungry puppy in the road. Excited, I reached into the CAGE and pulled it out. Now you probably are getting really anxious to know what it is. Here goes: A Golden egg made by a pure bred Swan and a Flamingo. NAH just messing. It’s 10x better. What soon will lie in your hands, is a Clear, Genuine, limited edition Western Garter Snake leftover epidermis, or snake skin. My mother, being your most awesome and cherished alter ego, (So I’ve heard.) has told me about your love of miniature serpents. And, knowing that I have rightful ownership of one, I knew that I just had to get you one.

This gift is so delicate, I place it in your hands with no regret, for I know that you are worth trusting. Like I said before, this is a limited edition; special and rare. I beg of you to take good care of Nimby’s dead epidermis, because he misses it more than I do. Take care, Jenny, and write me back anytime.

With adulation, infatuation, inclination, flatteration, and adoration :

Wilbur Driscoll.

(Or Lisa’s daughter. either one.)

P.S- And yes I said infatuation, not inFLATUTATION, or in other words, I didn’t mean you were like flatulence to me, which is excessive amounts of pressure through the anus, by the way.

Next Page »

Powered by WordPress