-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd281b2
commit bd1a23e
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Control M5StickC Plus2</title> | ||
</head> | ||
<body> | ||
<h2>Send Number to Firebase</h2> | ||
<button onclick="sendNumber(1)">1</button> | ||
<button onclick="sendNumber(2)">2</button> | ||
<button onclick="sendNumber(3)">3</button> | ||
<button onclick="sendNumber(4)">4</button> | ||
<button onclick="sendNumber(5)">5</button> | ||
|
||
<script> | ||
function sendNumber(num) { | ||
const databaseURL = "https://local-roomba-control-default-rtdb.firebaseio.com/command.json"; // Update with your database URL | ||
|
||
fetch(databaseURL, { | ||
method: "PUT", | ||
body: JSON.stringify(num), // Send just the number, not an object | ||
headers: { "Content-Type": "application/json" } | ||
}) | ||
.then(response => response.json()) | ||
.then(data => console.log("Sent:", data)) | ||
.catch(error => console.error("Error:", error)); | ||
} | ||
</script> | ||
</body> | ||
</html> |