UPDATED: This page contains a both a Forth hardware abstraction level (HAL) much like the m328def.inc file for AVR programming in C and an example of debouncing buttons.
New Words#
This HAL provides the words:
I/O Words#
The Arduino pins are defined by bit port so one can use the following commands using the Arduino pin number. This is true for pins D0-D13.
high ( bit port -- ) set a Arduino pin high
low ( bit port -- ) set a Arduino pin low
toggle ( bit port -- ) toggle output value on an Arduino pin
output ( bit port -- ) set Arduino pin as output
input ( bit port -- ) set a Arduino pin as input
pullup ( bit port -- ) set Arduino pin as input_pullup
read ( bit port -- f ) read a Arduino pin, returns bit valueFor example: