-
Create a folder named "SerialCom"
-
Copy all files from the src subdirectory into the new folder.
|--SerialCom | |- Communication.h | |- Data.h | |- SerialManager.cpp | |- SerialManager.h | |- README --> THIS FILE
-
zip it
-
Open ArduinoIDE -> Sketch -> Include library -> Add ZIP Library...
-
Test by checking: Sketch -> Include library -> SerialCom
Copy and past the hole folder in your lib directory:
|--lib
| |
| |--SerialCom
| | |--examples
| | |--Fast
| | |- Master.cpp
| | |- params.h
| | |- Slave.h
| | |--Secure
| | |- Master.cpp
| | |- params.h
| | |- Slave.h
| | |--src
| | |- Communication.h
| | |- Data.h
| | |- SerialManager.cpp
| | |- SerialManager.h
| | |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
- at least two Arduinos (can be different models)
- 2 cables for
- a power suply
We will use to control the onboard LED on the other board.
First change go to data and
/*
* vvv Change Data to fit your need! vvv
*/
using PIN_status = CheckedValue<HIGH>;
struct Data
{
Pressure press_expi;
Pressure press_inspi;
Flow flow_expi;
Flow flow_inspi;
};
/*
* ^^^ Change Data to fit your need! ^^^
*/
#include <Arduino.h>
#include "params.h"
#include "LiquidCrystal.h"
#include "MenuOption.h"
#include "LCDMenu.h"
#include "SerialManager.h"
const int rs = 12, en = 11, d4 = 6, d5 = 7, d6 = 8, d7 = 9;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
LCDMenu<1> menu(&lcd);
Data input = {{0, true}, {0, true}, {0, true}, {0, true}};
Data output = {{0, true}, {0, true}, {0, true}, {0, true}};
SerialManager manager(input, output, NONE, FAST);
void setup() {
// put your setup code here, to run once:
menu.getMenuEntry(0).init("MASTER" ,"", 0);
lcd.begin(16, 2);
lcd.clear();
delay(500);
menu.print();
Serial.begin(SERIAL_BAUD);
}
void loop() {
//Serial.println("Arduino nano 328P new Bootloader");
//Serial.println("Test");
menu.getMenuEntry(0).setValue(input.flow_expi.value);
manager.update();
++input.flow_expi.value;
delay(1000);
}
Data is the only file in the library you can change to adape the Data struct for your own popuse.
Main library to include.