B9 Robot Brain

Hi, I'm new here but not totally new to electronics, I can follow a wiring diagram fairly well, its just designing circuits I have trouble with. I did take electronics at collage nearly 30 years ago, so I know the theory behind how most components work, its just putting them together in a design I can't do.

Anyway, I'm currently building a replica B9 robot from the 1960's TV show 'Lost in Space'. The brain of the robot is stuffed full of flashing lights and I've decided to use an Arduino to make some cool effects in there.

I have a duemilanove which should be up to the job of flashing a few LEDs, indeed I've managed to follow some of the sketches in the beginner guides with success.

A lot of the C programming is similar to BASIC that I used to type in to my old Sinclair Spectrum computers, so I'm not totally lost there either.

The more I research the Arduino, the more I realise what its capable of, my original thoughts of just having LEDs flashing randomly have grown, lol, I want to try and do much more.

The brain unit on B9 is triangular, I intend to have 8 to 10 LEDs along each side, each side will have the same patern replicated on it. I fancy random twinkling and 'Knight-Rider' type scanning at least. I also quite like the idea of using RGB LEDs to get changing colours too, with an option of turning all the LEDs red when he gets upset.

There are also two eyes which will just be steady white LEDs, except when the rest of the brain goes red, then they will go red too.

A further six LEDs in the head just need to flash randomly a steady white, with the possibility of turning red too.

I have so many things I need to work out, but I have plenty of time. For now I need to find out how to generate a 'random' flashing of LEDs and how to get the Auduino to change the pattern depending upon the press of a button, ie flash 10 LEDs randomly unless I press a button then go into Knight-Rider style scan, returning to random if button pressed again.

I'm also waiting for some RGB LEDs to be delivered, when they are I'll be asking questions on them too.

Sorry for all the words from a newbie, thanks for reading.

Adam S

With your random flashing, it's probably perfect to attach the leds via 74hc595 serial to parallel buffers. Just daisy-chain them across your robot and have the Arduino spew out random bit streams. All this takes only 3 digital pins. If you attach colour RGB-leds, probably the best is to attach the pins always in the same order and you either put random bits to all 3 colours or in case of anger just on the red channel and keep the two other channels 0.

If you want to be able to dim the leds all together, you can do that by attaching a PWM signal to the output enable of the 74HC595. That solution is probably quite cheap but has the inconvenience is that you can't dim the leds individually. This might be a little annoying for RDG leds, as you don't get all colours. I would drive the colours for the eyes individually.

Korman

thanks for the reply, I was just searching for those 74hc959 chips as I thought they might be what I needed to start with. I have literally just ordered them.

Oh hark at me, I sound like I know what I'm doing. Honestly I didn't know about those chips until yesterday when I was looking through the tutorials. I have very little experience with chips, I've put a 555 timer in a couple of circuits but thats it. Datasheets and DIL packages are all new to me.

Adam S
http://www.strawson.freeuk.com/b9

Look at the linked tutorial. Random numbers can be generated with random(). To get random patters wandering across the brain, something like this should work (modified example from the shiftOut Tutorial page) :

//Pin connected to ST_CP of 74HC595
const int latchPin = 8;
//Pin connected to SH_CP of 74HC595
const int clockPin = 12;
////Pin connected to DS of 74HC595
const int dataPin = 11;

void setup() {
  //set pins to output so you can control the shift register
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

void loop() {
    // take the latchPin low so 
    // the LEDs don't change while you're sending in bits:
    digitalWrite(latchPin, LOW);
    // shift out the bits:
    shiftOut(dataPin, clockPin, MSBFIRST, random(256));  
    //take the latch pin high so the LEDs will light up:
    digitalWrite(latchPin, HIGH);
    // pause before next value:
    delay(200);
}

Perhaps that gives you some ideas.

Korman

Thats brilliant, thank-you so much. Hopefully my order for the 74hc959 chips will arrive tomorrow so I can have a go. I certainly like the idea of chaining the chips so that the pattern is replicated, that will make it easier to build.

A quick question; the number in the brackets after the random command, is that a limiting number for the generation of the random value?

Yes, 256 was chosen because it creates numbers from 0 to 255 which covers all 8 bits. Here's the documentation for random().

Korman

The chips came today and I wasted no time in testing it out, with rather pleasing results:

Now to move onto the next phase....