This commit is contained in:
2013-12-27 22:02:24 +08:00
parent 580fe40d28
commit 278476e946
4 changed files with 66 additions and 4 deletions
+1
View File
@@ -7,6 +7,7 @@ All the demos write with CoffeeScript
* Multiple LEDs
* Temperature sensor(LM 35)
* LCD
## How to run the code
+35
View File
@@ -0,0 +1,35 @@
# JST Pin 1 (Black Wire) => Arduino GND
# JST Pin 3 (Red wire) => Arduino 5VDC
#JST Pin 4 (Yellow wire) => Arduino Digital Pin 8
#*/
#
#int pin = 8;
#unsigned long duration;
#unsigned long starttime;
#unsigned long sampletime_ms = 30000;//sampe 30s ;
#unsigned long lowpulseoccupancy = 0;
#float ratio = 0;
#float concentration = 0;
#void setup() {
# Serial.begin(9600);
# pinMode(8,INPUT);
# starttime = millis();//get the current time;
#}
#
#void loop() {
# duration = pulseIn(pin, LOW);
# lowpulseoccupancy = lowpulseoccupancy+duration;
#
# if ((millis()-starttime) > sampletime_ms)//if the sampel time == 30s
# {
# ratio = lowpulseoccupancy/(sampletime_ms*10.0); // Integer percentage 0=>100
#concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve
#Serial.print(lowpulseoccupancy);
#Serial.print(",");
#Serial.print(ratio);
#Serial.print(",");
#Serial.println(concentration);
#lowpulseoccupancy = 0;
#starttime = millis();
#}
#}
+23
View File
@@ -0,0 +1,23 @@
five = require 'johnny-five'
board = new five.Board()
board.on 'ready', ()->
lcd = new five.LCD {
#LCD pin name RS EN DB4 DB5 DB6 DB7
pins: [10, 11, 1, 2, 3, 4]
}
lcd.on 'ready', ()->
lcd.useChar("check");
lcd.useChar("heart");
lcd.useChar("duck");
lcd.clear().print("Junv");
lcd.cursor(1, 0);
lcd.print("I :heart: johnny-five");
return
this.repl.inject {
lcd: lcd
}
return
+7 -4
View File
@@ -2,12 +2,15 @@ five = require 'johnny-five'
five.Board().on 'ready', ()->
sensor = new five.Sensor {
pin: 'A0',
freq: 200
pin: 'A1',
freq: 2000
}
sensor.on 'data', ()->
voltage = this.value * 0.004882814
celsius = (voltage - 0.5) * 100
# celsius = this.value / 9.31
# celsius = (voltage-0.3) * 100
# celsius = 5.0 * this.value * 100.0/1024.0
celsius = (val + 1) * 0.0048828125 * 1000
console.log this.value
fahrenheit = celsius * (9 / 5) + 32
console.log "#{celsius}°C", "#{fahrenheit}°F"