Quantcast
Channel: fritzing forum - Latest posts
Viewing all articles
Browse latest Browse all 28182

Please check my module

$
0
0

var express = require('express');
var app = express();
var path = require('path');
var bodyParser = require('body parser');
var Gpio = require('onoff').Gpio;

app.user(bodyParser.urlencoded({
extended: true
}));

const dht = require('node-dht-sensor');

if(!dht.initialize(11, 4)){
console.log('Failed to initialize sensor');
}

var led1 = new Gpio(17, 'out');
var led2 = new Gpio(18, 'out');
var led3 = new Gpio(27, 'out');

setInterval(function() {
const readout = dht.read();
if(readout.temperature.toFixed(1) > 35){
led1.writeSync(1);
}

else if(readout.temperature.toFixed(1) > 36){
led1.writeSync(1);
led2.writeSync(2);
}

else if(readout.temperature.toFiexd(1) > 37){
led1.writeSync(1);
led2.writeSync(2);
led3.writeSync(3);
}
}, 2000);

35℃ turn on a 1 led
36℃ turn on a 2 led
37℃ turn on a 3 led

it doesn't work.

how to fix?

thanks you.


Viewing all articles
Browse latest Browse all 28182

Trending Articles