PDA

View Full Version : pwm to pin using variable



wsmrite
- 7th April 2006, 15:57
I want to send a PWM output to a pin that is chosen at random. How do I specify the PIN in the PWM syntax using a variable generated by RANDOM?

I.E. I would normaly send:

PWM PORTD.0, 155,50

Want to send:

PWM "random pin",155,50

Where "random pin" would be a variable generated by a previous RANDOM command being a number between 0 and 7 corresponding to the pin number on port D. I know how to generate the random number I need to know how to use a variable for the pin in the PWM command.

picster
- 7th April 2006, 17:00
You could define an array, then have your random # be the array element pointer (after defining each element).

------------Picster--------------

mister_e
- 7th April 2006, 17:05
too do this easy you'll be limited to the available pin number stated in section 4.11 in the PBP manual.

Acetronics2
- 7th April 2006, 17:08
Hi, writer

Manual section 5.61 ... you just have to format your random number to meet section 4.11

Rather Easy ...

Alain