Hello, I am trying to create an LED demon mask similar to the one in the adafruit video: Electronic Demon Costume - How To! #Adafruit - YouTube. I am not using the adafruit matrices, though. I am using 8x8 matrices with MAX7219 chips. I found a really cool instructable that tells how to animate the eyes and even provides a spreadsheet to help generate the binary codes for the bitmaps.
I have the eyes working, but am now having problems trying to get the mouth working. I intend to have the mouth animations be voice activated, but for now I'm just trying to learn how to get the mouth part working. I have the eye matrices and mouth matrices on two separate sets of pins on an arduino nano, and I instantiate two separate LedControls. When I start the sketch, the eyes animate fine, but the mouth does nothing. If I comment out the eyes parts, the mouth will work (well, the bitmaps are 90 degrees out, but they work).
I have tried searching the net and this forum, but haven't been able to find out how to get both the eyes and mouth to work at the same time. Any help would be greatly appreciated.
I have attached the code I have so far - this is the version where the eyes are working.
EvilEyes3.ino (10.7 KB)
What would help is if you posted the code that doesn't work rather than the code that works.
However I am assuming you did not write this code because whoever did had no idea about the Arduino. The function:-
void delayMillis(int milliseconds)
{
for(int i=0; i < milliseconds; i++)
delayMicroseconds(1000);
}
is just duplicating the built in delay function.
Thank you for your reply. This is the code that is not working - the eyes work, but the mouth does not. I wrote some of the code but not all of it. I took the original code for the eyes, and then added another LedControl instance (mth), and duplicated the code for the eyes and renamed the duplicated variables in case there were conflicts.
If I comment out the eyes code - that is, the LedControl lc code - in the setup and loop sections, the mouth lights up. If I uncomment the eyes, then the eyes work, but the mouth does not.
If I comment out the eyes code
is that all the code?
I am trying to get a handle on what you remove to make it work.
is it all the lines starting "lc." and "mth." ?
Yes, I comment out all the "lc" lines in void setup and void loop (along with their surrounding for-next loops). I leave the "mth" lines, which then start working. They do not work if "lc" is not commented out. Could it be because the "lc" loop never ends?
I finally managed to get both the eye and mouth parts to light up at the same time with their own animations using the MD_MAX72xx library, but what I noticed is that the eye animation would run, then the mouth animation, then the eyes again, then the mouth, etc.
Because I want to animate the mouth using a microphone as an input, and the eyes need to move and blink independent of the mouth, I think I need to use two arduinos. I am now working on getting that to work. There might be a way to do it with one, but I only have a week to get this working, so I'm going with the simplest solution (simple for someone just learning).
Thanks for your help and interest. I'll post here if I actually get it all working.
I think I need to use two arduinos.
No. That is a bad idea.
What you need to do is to write the code properly. To so two things at the same time you need to use a state machine.
See my
http://www.thebox.myzen.co.uk/Tutorial/State_Machine.html
Or Robin2's several things at once
http://forum.arduino.cc/index.php?topic=223286.0
Thanks for pointing me at state machines. The two links you provided, plus this video: Arduino State Management Explained (BlinkWithoutDelay) - YouTube helped me get it all working all correctly on one arduino nano!
Thanks again!