Interactive C Function Notes: Alloff Alloff
Interactive C Function Notes: Alloff Alloff
Page 1 of 6
the inverse of the actual reading from the digital hardware/ if the reading is *ero volts or logic *ero the digital() function will return true.
HB
Page 2 of 6
reset_s-ste!_ti!e(). !seconds()
function).
5rinting 7$a!ples
7$a!ple ": 5rinting a !essage. The following statement prints a te-t string to the screen. printf(>)ello world?@n>)# In this e-ample the format string is simply printed to the screen. The character @n at the end of the string signifies end-of-line. ;hen an end&of&line character is printed the =25 screen will be cleared when a subse,uent character is printed. Thus most printf statements are terminated by a @n. 7$a!ple *: 5rinting a nu!ber. The following statement prints the value of the integer variable - with a brief message. printf(>Aalue is Bd@n>, $)# The special form Bd is used to format the printing of an integer in decimal format. 7$a!ple &: 5rinting a nu!ber in binar-. The following statement prints the value of the integer variable - as a binary number. printf(>Aalue is Bb@n>, $)# The special form Bb is used to format the printing of an integer in binary format. 8nly the low byte of the number is printed. 7$a!ple 8: 5rinting a floating point nu!ber. The following statement prints the value of the floating point variable n as a floating point number. printf(>Aalue is Bf@n>, n)# The special form Bf is used to format the printing of floating point number.
Page 3 of 6
7$a!ple .: 5rinting t0o nu!bers in 'e$adeci!al for!at. printf(>'CB- 7CB-@n>, a, b)# The form B- formats an integer to print in he-adecimal.
For!atting Co!!and 4u!!arFor!at Co!!and 3ata 9-pe 3escription :d int 3eci!al nu!ber :$ int He$adeci!al nu!ber :b int /o0 b-te as binar- nu!ber :c int /o0 b-te as ;4CII c'aracter :f float Floating point nu!ber :s <c'ar C'aracter arra- (string) 4pecial Notes The final character position of the =25 screen is used as a system >heartbeat.> This character continuously blin#s between a large and small heart when the board is operating properly. If the character stops blin#ing the board has failed. 2haracters that would be printed beyond the final character position are truncated. ;hen using a two&line display the printf() command treats the display as a single longer line. "rinting of long integers is not presently supported.
HB set_digital_out: <int> (<int>) HB sin: float (<float>) HB sleep: <void> (<float>) void sleep(float sec)
;aits for an amount of time e,ual to or slightly greater than sec seconds. 4ec is a floating point number. .-ample/ 3< wait for !.5 seconds <3 sleep("..)#
HB sonar: <int> ()
Page 4 of 6
Page 5 of 6
HB _s-ste!_print_off: <void> () HB _s-ste!_print_on: <void> () HB _s-ste!_p0!_off: <void> () HB _s-ste!_p0!_on: <void> () HB tan: float (<float>) float tan(float angle)
Returns tangent of angle. 'ngle is specified in radians( result is in radians.
HB test_digital_out: <int> (<int>) HB tone: <void> (<float>, <float>) void tone(float fre=uenc-, float lengt')
"roduces a tone at pitch fre,uency )ert* for length seconds. Returns when the tone is finished. 7oth fre,uency and length are floats.
Page 6 of 6