adding node 4

master
louisa 2 years ago
parent 6ec07e361c
commit 22c554e0f1

@ -0,0 +1,102 @@
#include <LoRa.h>
#include <Wire.h>
#include "boards.h"
#include <PN532_I2C.h>
#include <PN532.h>
#include <NfcAdapter.h>
PN532_I2C pn532_i2c(Wire);
NfcAdapter nfc = NfcAdapter(pn532_i2c);
String tagId = "None";
String cleanString = "";
void setup()
{
Serial.begin(9600);
Serial.println("System initialized");
nfc.begin();
initLoRa();
}
void loop()
{
readNFC();
if (!cleanString.isEmpty()) {
sendLoRaData(cleanString);
}
}
void initLoRa()
{
Serial.println("Initializing LoRa...");
LoRa.setPins(RADIO_CS_PIN, RADIO_RST_PIN, RADIO_DI0_PIN);
if (!LoRa.begin(LoRa_frequency))
{
Serial.println("Starting LoRa failed!");
while (1);
}
Serial.println("LoRa initialized successfully!");
}
void sendLoRaData(String data)
{
String message = "node3 " + data; // Concatenate "node3 " with the value of cleanString
LoRa.beginPacket();
LoRa.print(message);
LoRa.endPacket();
}
void readNFC()
{
if (nfc.tagPresent())
{
NfcTag tag = nfc.read();
tagId = tag.getUidString();
Serial.print("Tag ID: ");
Serial.println(tagId);
if (tag.hasNdefMessage())
{
NdefMessage message = tag.getNdefMessage();
int recordCount = message.getRecordCount();
Serial.print("Number of NDEF records: ");
Serial.println(recordCount);
for (int i = 0; i < recordCount; i++)
{
NdefRecord record = message.getRecord(i);
int payloadLength = record.getPayloadLength();
byte payload[payloadLength];
record.getPayload(payload);
String payloadAsString = "";
for (int c = 0; c < payloadLength; c++)
{
payloadAsString += (char)payload[c];
}
if (payloadLength > 0) {
cleanString = payloadAsString;
cleanString.remove(0, 3);
Serial.print("Payload: ");
Serial.println(cleanString);
}
String uid = record.getId();
if (uid != "")
{
Serial.print("Record ID: ");
Serial.println(uid);
}
}
}
else
{
Serial.println("No NDEF message found on the tag.");
}
delay(2000);
}
}

@ -22,7 +22,12 @@
if (node === 'node3' && value === '15') { if (node === 'node3' && value === '15') {
// Change the background color to red // Change the background color to red
document.body.style.backgroundColor = 'red'; document.body.style.backgroundColor = 'red';
} else { }
if (node === 'node4' && value === '20') {
// Change the background color to red
document.body.style.backgroundColor = 'blue';
}
else {
// Restore the default background color // Restore the default background color
document.body.style.backgroundColor = 'white'; document.body.style.backgroundColor = 'white';
} }
@ -46,7 +51,7 @@
<div class="section" id="objective"><br><br><br><br> <div class="section" id="objective"><br><br><br><br>
<p>OBJECTIVE:<br>Enter S/ash Gallery to step into the game and unlock gateway 1. Tap the different markers on the map in order to navigate and receive objectives. When set to the right digit, the modules in the locations will reveal a port number. Enter it above to collect dream logs. Follow the blue markers on the pavement to make your way through the landmarks.</p> <p>OBJECTIVE:<br>RUN</p>
</div> </div>
<div> <div>
<embed class ="embed" src="https://hack.chat/?mtmw"> <embed class ="embed" src="https://hack.chat/?mtmw">

Loading…
Cancel
Save