Skip to content

Driver to access Arduino GPIO (config, set and get state) through PC-serial

License

Notifications You must be signed in to change notification settings

a2gs/Arduino_GPIO_Driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Arduino_GPIO_Driver

Driver to access Arduino GPIO (config, set and get state) through PC-serial

(Arduino Uno D0 and D1 are alloced to TX-RX Serial communication)

Protocol:

PC (serial) to Arduino:

To set pin as OUTPUT:
outd2\n
outd3\n
outdXX\n
outa3\n

To set pin as INPUT:
ind2\n
ind3\n
indXX\n
ina3\n

To set pin as INPUT_PULLUP:
inupd0\n
inupd1\n
inupdXX\n
inupa3\n

To read a digital input pin state:
getdd2\n
getddXX\n
getda3\n
(Arduino returns to host)

To read a analog input pin state:
getad2\n
getadXX\n
getaa3\n
(Arduino returns to host)

To set a value to digital output pin as HIGH or LOW:
setdd0=1\n
setdd1=0\n
setddXX=1\n
setda3=0\n

To set a value to analog output pin:
setdd0=123\n
setdd1=234\n
setddXX=345\n
setda3=456\n

Arduino to PC (serial):
All messagens returns "OK" or "NOK".
Reads (get commands) returns "xOK" or "xNOK" where x is "0" or "1" to digital input pins or "0" to "1023" to analog input pins.

Sample:

At linux prompt:
# tail -f /dev/tty0 &
Ready

# echo "outd2" > /dev/tty0
cmd: [outd2]
OK


# echo "setdd2=1" > /dev/tty0
cmd: [setdd2=1]
OK


# echo "getdd2" > /dev/tty0
cmd: [getdd2]
0OK


# echo "setdd2=0" > /dev/tty0
cmd: [setdd2=0]
OK


# echo "inupd3" > /dev/tty0
cmd: [inupd3]
OK


# echo "getdd3" > /dev/tty0
cmd: [getdd3]
1OK


# echo "getdd3" > /dev/tty0     (putting pin D3 to LOW)
cmd: [getdd3]
0OK


# echo "ina2" > /dev/tty0
cmd: [ina2]
OK


# echo "getaa2" > /dev/tty0     (putting pin A2 to HIGH)
cmd: [getaa2]
1023OK


# echo "getdd3" > /dev/tty0     (putting pin A2 to LOW)
cmd: [getaa2]
0OK



Or using the interactive access:
# ./serialComm.sh /dev/arduinoPort

About

Driver to access Arduino GPIO (config, set and get state) through PC-serial

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published