From 7cb87432f34ceb5699e4366b6f6476c4419056cb Mon Sep 17 00:00:00 2001 From: Prof Date: Thu, 3 Nov 2022 10:54:28 +0100 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20Slave?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3a610b0..41f3bdc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,11 +1,13 @@ /* ==== CUIZZMASTER ==== -Basé sur Arduino Uno R3 (Atmel MEGA328P) +Basé sur Arduino Nano (Atmel MEGA328P) - Service Slave Seulement */ #include #include // Définition des PIN +#define CUIZZ_VERSION "1.0" + #define CUIZZ_HC12SERIAL_RX 11 #define CUIZZ_HC12SERIAL_TX 10 @@ -13,9 +15,26 @@ Basé sur Arduino Uno R3 (Atmel MEGA328P) SoftwareSerial HC12(CUIZZ_HC12SERIAL_RX,CUIZZ_HC12SERIAL_TX) void setup() { - // put your setup code here, to run once: + // Initialisation + // Open serial communications and wait for port to open: + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + + HC12.begin(9600); + + // Initialisation Slave ONLY + Serial.print("CUIZZMASTER - v"); + Serial.println(CUIZZ_VERSION); + Serial.println("INIT OK"); } void loop() { - // put your main code here, to run repeatedly: + if (HC12.available()) { + Serial.write(mySerial.read()); + } + if (Serial.available()) { + HC12.write(Serial.read()); + } } \ No newline at end of file