Multiple Void Loop

Hey guys i am currently working on a project and i need at least 2 void loop functions what i am trying to in my project that i need a lot of pwm pins on arduino uno (and i cant get a arduino mega at the moment) and i found out that pwm function on arduino can be copied by digitalWrite command but i need this function to be running forever in my sketch so can i have 2 loops in arduino IDE. THANKS :slight_smile:

Read Demonstration code for several things at the same time; it might get you on the way.

And no, you can not have 2 void loops.

UnoWatt:
I don't know what you mean here: can you elaborate?

You can create a PWM by simply bit-banging any digital output...

Regards,
Ray L.

Take a look at this project, where I created up to 13 tones (square-waves - i.e. 50% PWM) using a Atmega1284P, with 13 buttons to determine when outputs were output, with bit-banged time for outputs.
You can do the same with an Uno for 13 outputs, just change the button reading code to have an output on all the time.
Change the array with frequencies from audio/piano tones to what you want.
http://forum.arduino.cc/index.php?topic=179761.0

NewStudent:
Hey guys i am currently working on a project and i need at least 2 void loop functions what i am trying to in my project that i need a lot of pwm pins on arduino uno (and i cant get a arduino mega at the moment) and i found out that pwm function on arduino can be copied by digitalWrite command but i need this function to be running forever in my sketch so can i have 2 loops in arduino IDE. THANKS :slight_smile:

The microprocessor on an Ardiono is not quad-core. It's not even dual-core. It has one core, one thread of execution. To write code to do anything like what you are attempting, you have to frequently duck out in the middle of whatever else you are doing and check to see if it's time to toggle the PWM output. No matter what - it's not going to be fast.

Why not describe what you are really trying to do? At the end of the day, you may need external hardware controlled by the arduino. There are many, many options. Tell us what you want to connect to all these pwm outputs of yours.