Maker Pro
Maker Pro

Halloween rat

bigone5500

Apr 9, 2014
712
Joined
Apr 9, 2014
Messages
712
Wanted to give these guys some personality. Put some 3mm green LEDs in the eyes. Loaded a modified flicker sketch and ... IT'S ALIVE! IT'S ALIVE!

Code:
/*
Feel free to do whatever you want with this sketch.
*/

int ledPin0 = 2;    // Define LED pins
int ledPin1 = 3;

void setup()
{
  pinMode(ledPin0, OUTPUT);    // Define LED pins as Outputs
  pinMode(ledPin1, OUTPUT);
}

// Both LED outputs will flicker at the same time at a randomly chosen rate.

void loop()
{
  digitalWrite(ledPin0, HIGH);    // Turn on LEDs
  digitalWrite(ledPin1, HIGH);
  delay(random(100));            // Wait a random amount of time
  digitalWrite(ledPin0, LOW);    // Turn off LEDs
  digitalWrite(ledPin1, LOW);
  delay(random(100));            // Wait a random amount of time
}

tmp_27351-20141004_225552-1261561315.jpg

http://blog.jaredelliott.com/halloween-decor-with-arduino/ <<<---video
 
Last edited:
  • Like
Reactions: Ian

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Let's see... 1 Uno per rat. Seems exorbitant :)
 

bigone5500

Apr 9, 2014
712
Joined
Apr 9, 2014
Messages
712
No. I Wil be using pro minis. Probably will use 1 per 2 or 3 rats. Maybe they won't chew the wires...
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
You could always just use a PIC or AVR by itself. At $3-5 a pop, it will cut your cost at least in half ;)
 

bigone5500

Apr 9, 2014
712
Joined
Apr 9, 2014
Messages
712
You could always just use a PIC or AVR by itself. At $3-5 a pop, it will cut your cost at least in half ;)

I got these pro minis for about $3.50 each on ebay. I also found 2 atmega328P chips for $5.98 shipped. I just need to find out how to get the 328s on as small a pcb as possible.

On a side note, is it possible to have the arduino play sounds?
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
If you got em that cheap then fly at 'er.

What kind of sound were you hoping for?
If you're hoping for a small voice clip or recording, you may be out of luck... grab a wav file, and get your hands on a DAC to see if you can perhaps squeeze it on there.
Keep in mind that if you manage to get a small audio clip on there, playing back smoothly will require some code magic if you want to flicker the LEDs at the same time. Those delay(random(100)) will not play nice with audio.
Alternatively, if you wanted to make sound like the arcade games of old, or something like a gameboy or NES, you could play with outputting specific notes. (buzzes, beeps, and such)

*This is not based on experience, but my understanding thus far on audio for an MCU.
 

bigone5500

Apr 9, 2014
712
Joined
Apr 9, 2014
Messages
712
If you got em that cheap then fly at 'er.

What kind of sound were you hoping for?
If you're hoping for a small voice clip or recording, you may be out of luck... grab a wav file, and get your hands on a DAC to see if you can perhaps squeeze it on there.
Keep in mind that if you manage to get a small audio clip on there, playing back smoothly will require some code magic if you want to flicker the LEDs at the same time. Those delay(random(100)) will not play nice with audio.
Alternatively, if you wanted to make sound like the arcade games of old, or something like a gameboy or NES, you could play with outputting specific notes. (buzzes, beeps, and such)

*This is not based on experience, but my understanding thus far on audio for an MCU.

I was thinking of something like rat squeaks or something like that.
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
Oh hell... that may not be too hard to do.
Off the top of my head, there would be two things I would try...
PWM, at a varying frequencies. (Duty cycle will change the volume... you want to find a good frequency to sound like a squeak when it's run for a fraction of a second.. you may need to slow it down considerably)
Alternatively, much like your flicker sketch, you could simply toggle a pin with a delay(amount) ... increasing the delay will decrease the frequency

Do you plan to use a speaker or piezo element?
 

bigone5500

Apr 9, 2014
712
Joined
Apr 9, 2014
Messages
712
Oh hell... that may not be too hard to do.
Off the top of my head, there would be two things I would try...
PWM, at a varying frequencies. (Duty cycle will change the volume... you want to find a good frequency to sound like a squeak when it's run for a fraction of a second.. you may need to slow it down considerably)
Alternatively, much like your flicker sketch, you could simply toggle a pin with a delay(amount) ... increasing the delay will decrease the frequency

Do you plan to use a speaker or piezo element?

So is arduino capable of sawtooth waveform? I could mix that and a sine wave to make some cool effects.
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
So is arduino capable of sawtooth waveform? I could mix that and a sine wave to make some cool effects.
Not that I'm aware of.
You have PWM to play with as a square wave. There is also an 'analoguewrite' function, but it merely uses PWM to produce your value.
 

bigone5500

Apr 9, 2014
712
Joined
Apr 9, 2014
Messages
712
I worked on 'Count Ratula' a little more today. I soldered some low profile female headers onto a pro mini and uploaded the sketch. Works great. What's more, the pro mini fits perfectly in his belly.

Something I want to do however, is to have battery power inside the rat. I really don't want a battery pack sitting about. Can three 3v LR44 cells power this project for a while or will they discharge too quickly?

I also made a slight change to the sketch. I thought the LEDs were flickering too quickly so I modified the delay.

Code:
/*
Feel free to do whatever you want with this sketch.
*/

int ledPin0 = 2;    // Define LED pins
int ledPin1 = 3;

void setup()
{
  pinMode(ledPin0, OUTPUT);    // Define LED pins as Outputs
  pinMode(ledPin1, OUTPUT);
}

// Both LED outputs will flicker at the same time at a randomly chosen rate.

void loop()
{
  digitalWrite(ledPin0, HIGH);    // Turn on LEDs
  digitalWrite(ledPin1, HIGH);
  delay(random(50, 200));            // Wait a random amount of time from 50 to 199 ms
  digitalWrite(ledPin0, LOW);    // Turn off LEDs
  digitalWrite(ledPin1, LOW);
  delay(random(50, 200));            // Wait a random amount of time from 50 to 199 ms
}
 
Last edited:

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
Looked at wikipedia, they dont have much in terms of capacity. ~150mAh each.
I'm sure you can loosely do the math to determine what kind of life you will get from these.
 

bigone5500

Apr 9, 2014
712
Joined
Apr 9, 2014
Messages
712
Looked at wikipedia, they dont have much in terms of capacity. ~150mAh each.
I'm sure you can loosely do the math to determine what kind of life you will get from these.

I wasn't sure how much capacity they had. I checked a website with a calculator and came up with 3.25 hours runtime. That's only the LEDs. Probably 2.5 hours with the pro mini. Battery pack sounds a lot better now.
 
Top