DelayMicroseconds

From Pinguino
Revision as of 11:35, 7 March 2011 by Skc (talk | contribs) (Example: re-indent)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Name

delayMicroseconds - Wait for a specified amount of time

Description

Pause for a NUMBER micro-seconds.

Since
Beta 10 (?)

Syntax

delayMicroseconds(time);
time
delay time in microseconds.
Valid values from 1 to 65535 microseconds.
Argument type: unsigned int
Output
none

Example

 // Test for delayMicroseconds function:
 // Modify the value of pulsewidth, and check 
 // the square wave at user pin 0 with specified width.
 // by Jesús Carmona Esteban
 // to be compiled with Pinguino IDE 10 or upper.

 unsigned int pulsewidth=2;

 void setup(void)
 {
 	pinMode(0,OUTPUT);
 }

 void loop(void)
 {
 	PORTBbits.RB0 = 0xff;
	delayMicroseconds(pulsewidth);
	PORTBbits.RB0 = 0;
	delayMicroseconds(pulsewidth);
	PORTBbits.RB0 = 0xff;
	delayMicroseconds(pulsewidth);
	PORTBbits.RB0 = 0;
	delayMicroseconds(pulsewidth);
 }

Bugs

There is a bug at IDE versions previous to Beta 10, and DelayMicroseconds function produce a much larger microseconds delay than specified by argument. At Beta 10 IDE and later versions this delayMicroseconds function produces the exact amount of microseconds delay.

See also

Delay

Comments