For the sake of time, I had changed course to map the servo motors to the Ultrasonic Sensor. However, since I “had time”, I decided to test out the accelerometer that I had acquired. The MMA7455 was a bit more complex than the one for the labs, but I was able to find some code and tutorials which helped tremendously.

Step 1: Test out the X, Y, Z values and play with the sensitivity (gravity)

I need to figure out how to set up the wings of the servos to know exactly how to map the degrees for the final eye movements.


Accel & Servo Schematic_bb

IMG_2595 (1)


Step 2: Test an Eye

I have set up the servo that is linked to the x axis movement to move one eye. At first, one servo is controlling the right/left movement for one eye. The goal is to have it move both eyes. Also the movement is 180, and needs to be tweaked. But it works!




I am noticing that any time I power back up, the servo resets and moves 90-80 degrees. This will not work long term, as if the device resets then goes into its programming, then we will have a problem with eye alignment and detachment. Perhaps there is an issue in the code and the delays.



IMG_2605  IMG_2606 IMG_2607





Step 3: Test the Connection of Tail & Eyes

Standing alone in their separate codes and setups, the eyes work along the X axis and the tail wags.

I put the two sketches together, the code checked out fine. However, the DC motor does not work when hooked up together with the servo motor, even though the servo motor requires just 3.3 volts.  I am no100% sure what the issue may be here.

OK9 All Together_bb


I have checked the libraries feeding into the code. The MMA7455 (accelerometer) has a delay called in its library so that may be what is causing the ultrasonic sensor/DC motor to stop working together. I am getting the read from the ultrasonic sensor, but the write is not happening.

I went in changed the delays in the code to Millis, as referenced in the Blink Without Delay example. This did not work. I went into the MMA7455 library and changed that delay to millis, and now I am getting an error:

MMA_7455/MMA_7455.cpp.o:(.bss.previousMillis+0x0): multiple definition of `previousMillis’
Accel_Test_Take_4.cpp.o:(.bss.previousMillis+0x0): first defined here
collect2: error: ld returned 1 exit status
Error compiling.


I have previousMillis called both in the MMA7455 library and in the sketch. I went and changed this to priorMillis on one of the two, and still that did not work.

I even tried creating my own .h file and calling that for the MMA7455, but that did not work either.

I returned the MMA7455 library to its original state, and now I am getting no readings on anything except for “0.” As long as delay in the main sketch has been turned to millis, it looks like I can’t get a read. I removed the millis and now I am still getting a “0” read.

Next step is to start over with combining the sketches.


::::::NEW PLAN::::::

I will be saying adieu to the MMA_7455 and using the ADXL335 accelerometer, as it may be the better option.

In fact, I may be able to just ignore the code from the MMA_7455 and just map the numbers that come from the analogRead. For some reason I went along rugged path. But after the advice of some experienced ITPers, the ADXL335 is the better option.



Even with the ADXL335 accelerometer, the code is still not working together.

I think I have suspicions about where the error might be…it is in the translation of the inches and cm to microseconds in the DC/Ultrasonic code. This must be getting interrupted somehow. HOWEVER, the numbers are still printing out correcting, So I am not quite sure that this is the issue.