How to program Pin D5&D6 in Arduino nano both at a time?

Hi guys,

 I have facing problem in generating 30Hz in D5 and D6 in Arduino nano at a time. The problem I am facing is, I can able to generate 30Hz at either D5 or D6.

So, I am here to ask you guys for the solution to get 30Hz at D5&D6 with 90deg phase shift between them.

Thank you
charan

I have moved your Topic to Programming Questions ....Please try not to post in Uncategorised again, If you are unsure about the categories refer to this guide or to the stickies for each category.

Thank You.

Please post your code attempt, using the code tags so the code is clearly formatted.

port manipulation

If you look at the pinout of the nano, pin 5 and 6 are both in PORTD (bits 5 and 6) so you have to directly manipulate PORTD. Since you want the pins to be out of phase, you will have to

  1. read the port
  2. set the bit you want
  3. clear the bit you want
  4. write the value back to the port
  5. wait some amount of milliseconds before the next transition
  6. repeat
1 Like

Can you guys help me with code using timer0 in Arduino,which is supported by pin D5&D6.
I am trying with timer0. I am getting either at D5 or D6.

Please post your best effort

Sorry, writing a code on demand is not in traditions of the forum.

You wrote. that they were able to generate the desired signal on one of the pins. Show your code - we'll tell you what needs to be fixed to generate a signal on two pins at once

Thank you forum
Successfully completed :slightly_smiling_face:.
Thank you for the support.

Welcome to the best arduino forum in the world!

So what was the solution ?

For the benefit of anyone else with the same or similar problem please post the working code and mark one of the replies as the solution

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.