Sunday night – bwahahaha

Blissfully little to report today. It was a great transition day from vacation.. nothing planned.. and not much attempted. Diane and I took the dogs for a run up honey hollow this morning. It was a bright, cool clear morning though it rained most o the rest of the day.

Around 12:30 I drove over the Homer’s to pick up some of the microprocessors I’d left over there the other day. Unfortunately Homer and Mary were not home.. I think they were kayaking.. I grabbed my stuff and came back home.

Buddy and Seth came over at 3 for a work session on the Haunted Forest Project-X project. We’ve been falling a bit behind on our schedule.. A bunch of the intern’s who are helping with the project are about to go back to wherever they came form. i was determined to get the face animatronics done this week in time for our work session with Sara and Becca.. the articts.. on Wednesday night .

We got a ton tun between about 3 and about 11 tonight. Seth Buddy and I finshed the mechanicals for the the face animations including the jaw that moves to sound/voice, moiving eyebrows and lights that flicker and brighten in synch with the sound.

I really enjoy workign with these kids.. they’re shapr prorammers.. It’s fun watching them get familiar witht he joys and limitations of 8 bit microcontrollers.

We broke for a delicous dinner that Diane made… We had a bunch of kids around for one reason oranother.. gabefriends, maxi’s freinds.. my project friends..

Dianemade a mutant vegan pizza.. it looked lik it was ready to explode when she pulled it out of the oven.

Then back to work.. Around 11:00 everythign came together. I’d finished the wiring and Seth had finished the programming. We actually got everything we needed done for ou rwednesday meeting with the artists who are doing the creatures skeleton .

We still have lot sof tuning to do.. but the creatures jaw moves and eyebrows move to sound.. And it’s lighs flicker and brgheen as the sounds changes.. Here’s a low quality first example.. many more to come

..

If anyone’s interested.. here’s the Arduino code we wrote tongight.. Not beutiful.. but it’s fun to post code in your blog…


include ..nterrupt.h> // For interrupt functions cli() abd sei()
include ..o.h> // This file will look for the appropriate header file for the chip being used (ie., iom168.h will be included in our project)
include “Servo.h” // For open source servo library

// Create a count value for the timer to reset to:

static const unsigned char countValue = 6;
int in = 0;
int dimCounter = 0;
int yellowSwitch = 2;
int powerYellow = 0;
int yellowLED = 5;
int redLED = 3;
int inputVal = 0;
int mouthAvg = 0;
int inputTotal = 0;
int eyebrowVal = 0;
int inputArray16;
int i = 0;
int countMouth = 0;
int countEyebrow = 0;
boolean yellowOn = false;

// Make a macro to reset the timer when called:
define RESET_TIMER2 TCNT2 = countValue

// Evil global servo handlers:
Servo mouth;
Servo rightEyebrow;
Servo leftEyebrow;
// Timer 2 ISR:
ISR(TIMER2_OVF_vect)
{
Servo::refresh();
RESET_TIMER2;
}

// Setup timer 2 to trigger an interrupt everytime it rolls over
void Timer2Init(void)
{
//Timer2 Settings: Timer Prescaler /1024
TCCR2B |= 0x07;
// Use normal mode
TCCR2A |= 0x00;
// Use internal clock
ASSR |= 0x00;
//Timer2 Overflow Interrupt Enable
TIMSK2 |= 0x01;
// Reset the timer to whatever TIMER_COUNT is set to:
RESET_TIMER2;
}
void setup()
{
// Initialize timer 2 for operation:
Timer2Init();
// Enable interrupts (cli() will disable them)
sei();
mouth.attach(9);
leftEyebrow.attach(10);
rightEyebrow.attach(11);
Serial.begin(9600);
}

void loop()
{
inputVal = analogRead(in);
inputArraycountMouth = inputVal;
countMouth ++;
if (countMouth == 8)
{
countMouth = 0;
}
inputTotal = 0;
for (i = 0; i <= 7; i ++)
{
inputTotal = inputTotal + inputArrayi;
}
mouthAvg = (inputTotal/2)+80;
mouthAvg = constrain(mouthAvg,80,120);

inputArraycountEyebrow = inputVal;
countEyebrow ++;
if (countEyebrow == 16)
{
countEyebrow = 0;
}
inputTotal = 0;

for (i = 0; i <= 15; i ++)
{
inputTotal = inputTotal + inputArrayi;
}
eyebrowVal = inputTotal;

if(analogRead(yellowSwitch) == 0)
powerYellow++;
if(powerYellow > 0 && powerYellow < 255)
{
dimCounter++;
if(dimCounter % 16 == 0)
{
powerYellow++;
yellowOn = true;
}
}
if(yellowSwitch == LOW && yellowOn)
powerYellow = 0;

if(inputVal>=8 && yellowOn)
{
analogWrite(redLED,random(100));
}
else
{
analogWrite(redLED,0);
}
eyebrowVal = eyebrowVal/16;
analogWrite(yellowLED,powerYellow);
rightEyebrow.write(eyebrowVal);
leftEyebrow.write(150 – eyebrowVal);

mouth.write(mouthAvg);
Serial.print(inputVal);
Serial.print(” “);
Serial.print(eyebrowVal);
Serial.print(” “);
Serial.print(analogRead(yellowSwitch));
Serial.println();
}


And there you have it.. the source code for my day.. OK.. I gotta get to selep now.. Gnood night to you all. G’nite Sam !
-me