So. I want to communicate with my Arduino.
I have the Arduino IDE istalled and if I use it, everything works perfectly fine.Here is my sketch:
const int ledPin = 11; // the pin that the LED is attached to
void setup() {
// initialize the serial communication:
Serial.begin(9600);
// initialize the ledPin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
byte brightness;
// check if data has been sent from the computer:
if (Serial.available()) {
// read the most recent byte (which will be from 0 to 255):
brightness = (Serial.read()-48)*28;
// set the brightness of the LED:
analogWrite(ledPin, brightness);
Serial.println(brightness);
}
}
If I start the Serial Monitor now and type in "9", I get back an 252 and the LED jups to full brightness. And if you type "0", the LED goes off!
This is what I wanted the recreate via Lua. I downloaded rs232 and then I tried to run the following:
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 just nothing happens. Even without the p.read() part
I use Linux CentOS 7 and a Arduino UNO
Please Help