Project Update

I set the whole thing up. Spent a day wiring a board to test my entire setup. Turns out I was asking too much of the micro-controller. One of the three servos would not respond correctly. I read somewhere it eats a lot of memory whenever you update a LCD display. I stripped the code for the LCD figuring it was asking too much of the UNO. The third servo still didn't rotate correctly. One of the other things I was asking the UNO to look at on each cycle was the position of three potentiometers. This turned out to be the problem. I used a different means to set the speed and rotation of the servos. Now all three servos responded correctly. I added back in the code for the LCD and it worked great too. Now I just have three empty holes where the pots were, but I can live with that. I'll update the code and the diagrams in a day or two.

Pinger Project

Yes I call it the Pinger Project. I guess for no other reason then I use a Parallax Ping ultrasonic sensor as the backbone of this project. I'm still way in the early planning phase and things are changing as I try to work out all the hicups or roadblocks, mainly in my knowledge of how the Arduino works.

The scope of the project was to use the sensor to track a persons progress down a hall. Set off a series of events as the person got closer to the end of the hall where the sensor was located.

One of the things I can see that might limit the usefulness of the Ping is it's sensor range. It only senses out to ten feet. This does function but I'd like to be able to spread the effect out over a wider area. Maxbotix offers a series of ultrasonic sensors with a wider range of detection. Someone has written a Arduino library for them. For now I will play with the Parallex.

General Idea

Basically my plan is to use the ultrasonic sensor to activate a set of three events. We will have a wall along a corridor covered in bones and beasts in various states of decay. As the group walks into sensor range part of the bones and beasts start to move, LED spot lights come on and errie sound effects are played. As they move closer to the sensor a second and third set of bones and beasts start to move and light up. I first tested it with three LED, seeing how the sensor worked. Here is the void loop I used:

  • void loop() {
  • pinMode(pingPin, OUTPUT);
  • digitalWrite(pingPin, LOW);
  • delayMicroseconds(2);
  • digitalWrite(pingPin, HIGH);
  • delayMicroseconds(5);
  • digitalWrite(pingPin, LOW);
  • pinMode(pingPin, INPUT);
  • duration = pulseIn(pingPin, HIGH);
  • inches = duration / 74 / 2;
  • if (inches <= 200) {
  • digitalWrite(ledPin1, HIGH); }
  • if (inches > 200) {
  • digitalWrite(ledPin1, LOW); }
  • if (inches <= 100) {
  • digitalWrite(ledPin2, HIGH); }
  • if (inches > 100{
  • digitalWrite(ledPin2, LOW); }
  • if (inches <= 50) {
  • digitalWrite(ledPin3, HIGH); }
  • if (inches > 50 {
  • digitalWrite(ledPin3, LOW);}
  • delay(200);
  • }

  • As someone gets within 200 inches of the sensor the first LED (ledPin1) comes on. If the person leaves the area during the 200 millisecond cycle time, the LED goes off. When then continue to the sensor, at 100 inches the second LED (ledPin2) comes on. Finally when they walk nearly up to the sensor the final LED (ledPin3) comes on. All the LEDs will turn off when the group leaves the detection area.

    Can it get more complicated?

    If all I was doing was lighting up some LED's it'd be easy. The LCD module will display the distance during testing. I'll disconnect it when I'm done.

    I have to load several libraries to get it all to work. NewPing.h, SoftwareSerial.h, servo.h so far. I'm sure it'll get more crazy. I'm thinking I'm going to only have the servos rotate continuously. I found a website called ServoCity. This site is outstanding. They have all sorts of toys for servos and bots in general. Stuff I can use to connect my servos to the creatures that need to be moved around. This should make it easier to control the servos. I seem to need to fine tune them quite a bit. I'll play with a servo for several minutes, get it all tweaked in perfect. The next time I power it up I get a slow rotation in one direction or another. I think this would be annoying while the haunted house was running.

    I don't know if the parallax servos are going to have to power I need to move all the creatures. I might need to go to a couple of stepper motors. If this proves the case I will have to move up to an Arduino Mega for the addional pin outputs.

    Different Zones

    I am breaking it down into four areas. I was going to draw a diagram of the entire layout but it started get too complicated. I'm hoping I don't run out of memory tying all these different functions together. So the four diagrams are:

  • Ping and Serial LCD Diagram
  • Servo Control Diagram
  • LED Control Diagram
  • Audio Player Control Diagram

  • I posted the diagrams for the individual areas to the right. You can click on the image and open a larger PDF version. As the project develops I'll change the diagrams as necessary.

    I have determined I needed to setup a timer sequence for the audio control relays. As with any sketch the void loop will cycle through continually looking to see if the conditions are met or not. In this case it's how far away from the sensor the people are. I only want the sound file to activate once. The sound file will be long enough to play through many cycles of the sketch. Basically I can't have the first sound triggered everytime it cycles through that will destroy the effect. I compared the time since I started the project, as previousMillis to currentMillis. The currentMillis being updated each cycle of the of the sketch. I set it up that once the audio file had been triggered it couldn't be triggered again for a couple of minutes.


    I wrote this whole complex sketch. I included all the parts, servos, LED Spots, fading LED eyes, audio, the pinger and a LCD panel to check out the distance. I got it all together and it compiled! It was 7106 bytes, massive compared to a blinking LED. I jumpered everything over to my little breadboard, used all the jumpers I had. It was amazing, I plugged it in, uploaded the sketch and it didn't work! I had tested every area seperately prior to combining it. They all worked. I came to the conclusion I was trying to draw too much power out of the Arduino UNO. I built my transistor circuits, powered the servos from an external 5 vdc source. After a little tweaking, the sketch worked. I am happy. Here is a PDF of the sketch. I color coded the areas to help the home user following along.

    It appears you don't have a PDF plugin for this browser. Click on link below to download it.

    Click here to open a PDF of the Pinger Project