Skip to content

Commit e8f0464

Browse files
authored
Add files via upload
1 parent c7dbfac commit e8f0464

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

main.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
const Discord = require('discord.js');
2+
const five = require('johnny-five');
3+
const client = new Discord.Client();
4+
const { Board, Thermometer } = require("johnny-five");
5+
const AsciiTable = require("ascii-table");
6+
const board = new Board();
7+
board.on("ready", () => {
8+
const led = new five.Led(13);
9+
const piezo = new five.Piezo(3);
10+
const thermometer = new Thermometer({
11+
controller: "LM35",
12+
pin: "A0"
13+
});
14+
15+
16+
17+
client.on('message', msg => {
18+
if (msg.content === "led-open") led.on()
19+
else if (msg.content === "led-close") led.off()
20+
});
21+
22+
23+
24+
client.on('message', msg => {
25+
const {celsius, fahrenheit, kelvin} = thermometer;
26+
if (msg.content === "weather-degrees") {
27+
var table = new AsciiTable()
28+
table
29+
.addRow('°C:', celsius)
30+
.addRow('°F:', fahrenheit)
31+
.addRow('K:', kelvin)
32+
let embed = new Discord.RichEmbed()
33+
.setDescription(`\`\`\`${table.toString()}\`\`\``)
34+
msg.channel.send(embed)
35+
}
36+
});
37+
38+
client.on('message', msg => {
39+
if (msg.content === "music") {
40+
led.blink();
41+
board.repl.inject({
42+
piezo: piezo
43+
});
44+
piezo.play({
45+
song: "E D F D A - A A A A G G G G - - C D F D G - G G G G F F F F - -",
46+
beats: 1 / 4,
47+
tempo: 100
48+
});
49+
} else if (msg.content == "music-close") {
50+
led.stop()
51+
}
52+
})
53+
54+
})
55+
56+
57+
client.login('Token'); //Token Here

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "arduino-discord",
3+
"version": "1.0.0",
4+
"description": "Managing-Arduino-from-discord",
5+
"main": "main.js",
6+
"dependencies": {
7+
"ascii-table": "^0.0.9",
8+
"cli-table": "^0.3.1",
9+
"discord.js": "^11.6.4",
10+
"johnny-five": "^1.4.0",
11+
"serialport": "^9.0.0"
12+
},
13+
"devDependencies": {},
14+
"scripts": {
15+
"test": "echo \"Error: no test specified\" && exit 1"
16+
},
17+
"repository": {
18+
"type": "git",
19+
"url": "git+https://github.com/Furtsy/managing-arduino-from-discord.git"
20+
},
21+
"keywords": [
22+
"discord.js"
23+
],
24+
"author": "Furtsy",
25+
"license": "ISC",
26+
"bugs": {
27+
"url": "https://github.com/Furtsy/managing-arduino-from-discord/issues"
28+
},
29+
"homepage": "https://github.com/Furtsy/managing-arduino-from-discord#readme"
30+
}

0 commit comments

Comments
 (0)