Interfacing via Lua
so. want communicate arduino.
i have arduino ide istalled , if use it, works fine.here sketch:
if start serial monitor , type in "9", 252 , led jups full brightness. , if type "0", led goes off!
this wanted recreate via lua. downloaded rs232 , tried run following:
i have arduino ide istalled , if use it, works fine.here sketch:
code: [select]
const int ledpin = 11; // pin led attached to
void setup() {
// initialize serial communication:
serial.begin(9600);
// initialize ledpin output:
pinmode(ledpin, output);
}
void loop() {
byte brightness;
// check if data has been sent computer:
if (serial.available()) {
// read recent byte (which 0 255):
brightness = (serial.read()-48)*28;
// set brightness of led:
analogwrite(ledpin, brightness);
serial.println(brightness);
}
}
if start serial monitor , type in "9", 252 , led jups full brightness. , if type "0", led goes off!
this wanted recreate via lua. downloaded rs232 , tried run following:
code: [select]
local rs232 = require "rs232"
local e, p = rs232.open('/dev/ttyacm0',{
baud = '_9600';
data_bits = '_8';
parity = 'none';
stop_bits = '_1';
flow_control = 'off';
rts = 'on';
})
input=io.read()
p:write(input)
print(p:read(1))
p:close()[/code
but nothing happens. without p.read() part
i use linux centos 7 , arduino uno
please help
if want here, post sketch here. i'm not going site download anything.
Arduino Forum > Using Arduino > Interfacing w/ Software on the Computer > Interfacing via Lua
arduino
Comments
Post a Comment