Ashish
Published © CC BY

Controlling Brightness of LED Through Web Interface

A simple project to use Node.js with Arduino Uno and control an LED's brightness by simply moving a slider.

IntermediateFull instructions provided5,910
Controlling Brightness of LED Through Web Interface

Things used in this project

Story

Read more

Schematics

Connecting LED with Arduino Uno

Code

Code snippet #7

Plain text
var express = require('express');
app = express();
server = require('http').createServer(app);
io = require('socket.io').listen(server);
var SerialPort = require("serialport")//.SerialPort

Code snippet #10

Plain text
io.sockets.on('connection', function (socket) {
socket.on('led', function (data) {
brightness = data.value;
var buf = new Buffer(1);
buf.writeUInt8(brightness, 0);
serialPort.write(buf);

Code snippet #11

Plain text
io.sockets.emit('led', {value: brightness});   
});
socket.emit('led', {value: brightness});
});

Credits

Ashish
1 project • 3 followers
Contact

Comments

Please log in or sign up to comment.