Hi guys,
I’m trying to send some data from an Arduino to openframeworks.
I have simply set up the Arduino to print an integer with serial.print(), but when I try to establish the connection in openframeworks, I can’t seem to open the port.
I use the serialExample, but with a slight modification.
Instead of using:
serial.setup(“COM4”);
I use:
serial.setup(“COM24”, 9600);
But when I run the code, it says that it can’t open the port.
From what I have read around the internet, the error should be because my Arduino is not connected - but it is.
It even shows up among the devices that are found with serial.enumerateDevices();…
I have tried some other methods as well, like:
setup(0, 9600);
which to my understanding should simply try to establish a connection with the first available device - which in my device list should be the Arduino.
Can anyone help me?
Arduino code: (still under development)
int IRpin2 = 2; // analog pin for reading the IR sensor
void setup() {
Serial.begin(9600); // start the serial port
}
void loop() {
float interactionMade;
float initialDistance2 = analogRead(IRpin2);
if (initialDistance2 > 200){
interactionMade = 2;
} else {
interactionMade = 0;
}
Serial.print(interactionMade); // print either 0 or 1, 1 meaning detection has happened
delay(200); // arbitary wait time.
}