Goal

Intaraction

Compiler

Char set

Builtin editor

Invoke editor

Command

Editing

Setting

WiringPi

OPL <==================================> C

wiringpi_spi_setup(ch,speed) <===> wiringPiSPISetup (SPI_CH, SPI_SPEED) wiringpi_setup_gpio(X) <===> X=wiringPiSetupGpio() pin-mode(N,output) <====> pinMode(N, OUTPUT) or input -> INPUT or pwm_output ->PWM-OUTPUT digital_write(n,v) <===> digitalWrite(n, v); digital_write_byte(value) <===> digitalWriteByte(value) digital_read(pin,X) <===> X=digitalRead(pin) delay(howlong) <===> void delay(unsigned int howLong) pull_up_dn_control(pin, pud) <===> pullUpDnControl(pin,pud) pwm_set_mode(pwm_mode_ms) <===> pwmSetMode(PWM_MODE_MS) or pwm_mode_bal -> PWM_MODE_BAL pwm_set_clock(n) <===> pwmSetClock(n); pwm_set_range(n) <===> pwmSetRange(n); pwm_write(pin,value) <===> pwmWrite(pin , value)

LED on/off

setup :- not(flag),wiringpi_setup_gpio(X),assert(flag), pin_mode(5,output). test(0). test(N) :- digital_write(5,1), delay(1000), digital_write(5,0), delay(1000), N1 is N - 1, test(N1). %execute ?- setup. ?- test(10).

control servo moter

%hardware Micro servo Digital 9g SG90 setup :- not(flag),wiringpi_setup_gpio(X),assert(flag), pin_mode(18,pwm_output), pwm_set_mode(pwm_mode_ms), pwm_set_clock(400), pwm_set_range(1024). test1(N) :- pwm_write(18,N). %execute ?- setup. ?- test1(24). ?- test1(115).

TCP/IP

%test for TCP/IP server :- server_create('127.0.0.1','5000',S), server_accept(S,Y,C), repeat, socket_recieve(C,D), write(D), socket_send(C,D), D == end, socket_close(S). client :- client_connect('127.0.0.1','5000',S), repeat, read(X), socket_send(S,X), socket_recieve(S,Y), write(Y), Y == end, socket_close(S).

document