I made two separate libraries, and I need the code in void loop, below, to run simultaneously. I've heard that in general this is possible with threading, but I have no idea how to do it. I also saw in a post that this may not be possible on the arduino. Is this the case? If so, what other options do I have? Would it be best to try to incorporate the libraries into a single library? The basic idea is that I want to create a multisensor feedback loop, in which each object is looking for a different type of input, and emitting a different output based on that input. One of the libraries reads in analog input from one pin, maps it to a meaningful output and writes out onto another pin. The other library controls a servo motor which scans a room looking for meaningful input and, when it finds it, goes to the location with the greatest input.
The two libraries work fine independently, but do not work together. This is where I try to call them together:
#include <MoreInMoreOut.h> //controls output of object (light/sound, etc) based on input
#include <carrot_h2.h> //controls motor scanning the room
#include <Servo.h>
#include <Array.h>
MoreInMoreOut buzz1(2, 9); //2 is input (distance), 9 is output (piezo)
MotorScan firstMotor(10, 2); //10 is output (motor), 2 is input (distance)
void setup()
{
Serial.begin(9600);
Serial.println("test");
}
void loop()
{
firstMotor.scanAndGetSerialValues();
buzz1.getSerialValues();
delay(10);
//how can I get these to run parallel to one another instead of consecutively? Should I try to combine it into a single library?
}
Thanks for your thoughts!