tableflip / nodebot-workshop Goto Github PK
View Code? Open in Web Editor NEWA nodeschool workshop on how to get your ardunio alive with johnny-five
Home Page: https://www.npmjs.org/package/nodebot-workshop
A nodeschool workshop on how to get your ardunio alive with johnny-five
Home Page: https://www.npmjs.org/package/nodebot-workshop
I'm still learning so please forgive me if this is wrong.
But for me, this exercise works if the black cable coming from the button goes to 'Grnd', but in the diagram the black cable from the button goes to '5V'?
As our validation is done in the exercise code rather than by comparing the output of the solution with the users code, we should have a test that ensures the solutions pass the verifications.
The Littlebits Arduino controller uses a different pin for LED output. An Arduino Uno uses pin 13, the Littlebits Leonardo board uses pin 5. The tests for the first workshop verify the pin settings of the program; which breaks in this case.
To reproduce: try and verify a working "blink" solution with Johnny-Five and a LIttleBits Arduino kit. Alertnatively, you can try changing the Led to something instead of 13, and you'll see the test breaking when it encounters the wrong pin number.
I'm just attempting Exercise 8: Fire Alarm.
How do we test our code?
My code below doesn't work and I'm wondering if there might be room for an exercise in troubleshooting?
I can run
instead of verify
to get console.log()
output but that doesn't seem to work within the testing script.
And I have no idea how to use io.digitalWrite.called
from within exercise.js
Thanks!
var five = require('johnny-five')
var board = five.Board()
board.on('ready', function () {
var temp = new five.Temperature({
controller: 'TMP36',
pin: 'A0'
})
var piezo = new five.Piezo(9)
var led = new five.Led(13)
var button = new five.Button(5)
var buttonState = false
led.stop().off()
piezo.noTone()
button.on('press', function () {
buttonState = true
led.stop().off()
piezo.noTone()
})
temp.on('data', function () {
if (buttonState === false && this.celsius > 50) {
piezo.frequency(587, 500)
led.strobe(1000)
} else {
led.stop().off()
piezo.noTone()
}
})
})
johnny-five-is-alive is too long to type on the command line. The current bin property in package.json
calls it j5-tut
...which is a bit boring.
What do you think about five-alive
? It's available on npm (at the moment) as well.
If not, do you have any suggestions for catchy names?
I just added a street lamp exercise. I think we should put ASCII circuit diagrams in the question text to make them look badass.
PhotoR 10K
+5 o---/\/\/--.--/\/\/--.--o GND
| |
Pin 0 o----------- |
|
LED 330 |
Pin 9 o--->|-----/\/\/------
Running on osx (have not upgraded to yosemite)
I have latest node v0.10.33 installed., I installed johnny five.
installed nodebot-workshop and the program runs correctly from command line.
Upon selecting any challenge, the following error occurs:
TypeError: Object 13.4.0 has no method 'contains'
at /usr/local/lib/node_modules/nodebot-workshop/node_modules/johnny-five/lib/board.js:28:18
at Object. (/usr/local/lib/node_modules/nodebot-workshop/node_modules/johnny-five/lib/board.js:30:3)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Object.require.extensions.(anonymous function) (/usr/local/lib/node_modules/nodebot-workshop/node_modules/proxyquire/lib/proxyquire.js:235:43)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Proxyquire._require (/usr/local/lib/node_modules/nodebot-workshop/node_modules/proxyquire/lib/proxyquire.js:156:19)
at require (module.js:380:17)
at Object. (/usr/local/lib/node_modules/nodebot-workshop/node_modules/johnny-five/lib/accelerometer.js:1:75)
Any ideas what might be going on?
Hello,
A Bill of Material would be really nice to have. I'm thinking about using this at a conference and having attendees build the circuits and run their apps on physical hardware after they pass each level. I need to figure out what would be required to create a kit for the people doing the exercise.
Once I'm done creating the list of parts, could I add it in the readme or somewhere else? I'll put together a PR for it.
Awesome work on this by the way. It's a really cool workshop. :)
Kyle
every time i try to run the code nodebot-workshop
it states bash:nodebot-workshop command not found
I have had this problem with everything that i tried installing using NPM
Seems like strobe() is the only acceptable way of doing the .blink() behaviour in 01-blink-blink ... (despite https://github.com/rwaldron/johnny-five/wiki/Led#api having blink() be an alias to strobe()!)
(I've got a bunch of other minor things : would you accept a pull request?)
Martin
:-)
PS: And thanks for making this : I have to say that it was one of the best structured & explained nodeschool modules I've gone through...
let's meet !!!
i would realy love to talk about this project, it could really fuels the nodebots thing ( i really think that the whole chain needed make nodebot too much developper oriented)
just tell me when you think would be the good time to do that
Hello:
I tried to install nodebot-workshop with the command:
npm install -g nodebot-workshop
but i get these instead:
C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\src\win_delay_load_hook.c(34): error C2373: '__pfnDliNot
ifyHook2': redefinition; different type modifiers [C:\Users\nerve\AppData\Roaming\npm\node_modules\nodebot-workshop\nod
e_modules\weak\build\weakref.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\delayimp.h(134): note: see declaration of '__pfnDliNot
ifyHook2'
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\nerve\AppData\Roaming\npm\node_modules\nodebot-workshop\node_modules\weak
gyp ERR! node -v v6.4.0
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm WARN install:[email protected] [email protected] install: `node-gyp rebuild`
npm WARN install:[email protected] Exit status 1
How can i solve this?
Thank you
Hi,
I've been using this on my mac without connecting any Arduino. It started a couple of node process which has slowed down my mac.
At the moment I've got 4 node process, each one requesting an average of 88% of the CPU.
(went up to 15 process w/ an average of 20% cpu load).
Doesn't make actual sense to me but maybe you guys will manage to fix that.
( I guess it's related to the Arduino simulation when you verify/run the exercises. )
Thanks.
The third level doesn't verify for us, even not with the correct solution from here.
We always get the following error:
Could not verify: motor not started again at 200: expected undefined to equal 200
We are trying this on a Mac with node v0.10.26.
I create a sensor
like so:
new Sensor({
pin: "A0",
freq: 250
})
this fails.
new five.Sensor('A0')
this passes
The asciigrams are a work of art, but a fritzing style diagram might be easier to interpret.
The Johnny Five docs state that a Piezo's noTone
or off
methods clear queued tones, so that a previously run play
method will be stopped and not restarted. However, this doesn't seem to be happening in the stub - an individual tone
is indeed stopped, but a tune passed to play
will continue playing with the next scheduled note.
hello,
is there any instructions how to test the hardware.
My arduino is wired up like is suggested in the png schematics.
When I run my code I get the following error:
"Could not verify: Piezo didn't play a tone when sent a UDP message: expected 0 to be above 0"
I also get this error when I run the code shown in the solution of this repository.
Code:
// EXERCISE SIX: PING BELL
// TODO: Create a UDP server that plays a sound when a message is received
// Attach a piezo to pin 8
// Use the "dgram" mode to create a "udp4" socket
// Bind your server to port "1337" and listen for messages
// When a message is received, have the piezo play a tune
// Require the johnny-five module
var five = require("johnny-five");
// Require "dgram" to work with datagram sockets for udp
var dgram = require("dgram");
// Instantiate a new board
var board = new five.Board();
board.on("ready", function() {
// Creating a udp4 socket
// TODO: What is dgram and a udp socket?
var s = dgram.createSocket("udp4");
// Attach the piezo to pin 8
var piezo = new five.Piezo(8);
// When server receives a message, play tune
s.on("message", function() {
piezo.tone(five.Piezo.Notes.c4, 1000);
console.log("played");
});
// Bind to port "1337"
s.bind(1337);
});
I'm still learning so please forgive me if this is wrong.
But for me, this exercise works if the black cable coming from the button goes to 'Grnd', but in the diagram the black cable from the button goes to '5V'?
https://github.com/tableflip/nodebot-workshop/blob/master/schematics/png/04_lightSwitch.png
Solution shows using five.Sensor('A0')
instead of five.Temperature({...
Is this a deprecation problem or am I just Doing It Wrongβ’?
Thanks for advice in advance π
var five = require('johnny-five')
var dnode = require('dnode')
var board = new five.Board()
board.on('ready', function () {
var t = null
var server = dnode({
getTemperature: function (cb) {
cb(t)
}
})
server.listen(1337)
var temp = new five.Temperature({
controller: 'TMP36',
pin: 'A0'
})
temp.on('data', function (err, data) {
if (err) {
console.error(err)
}
t = data.celsius
})
})
Hello hello,
Just got on board with nodebot-workshop
, really enjoying it and finding everything a breeze to understand, it's very well done. However, on exercise 6, I get the following error:
Piezo didn't play a tone when sent a UDP message
Now, I've compared my code to the solution, even trying a copy+paste at one point, yet it still fails. Is there something I'm missing here? Is something outdated?
var five = require('johnny-five');
var dgram = require('dgram');
var board = new five.Board();
board.on('ready', function() {
var piezo = new five.Piezo(8);
var server = dgram.createSocket('udp4');
server.on('message', function() {
piezo.tone(five.Piezo.Notes.c4, 1000);
});
server.bind(1337);
});
Answers on a postcard.
It was confusing to me initially when the circuit diagram said 'Pin 0' instead of 'Pin A0', especially as the the instructions state 'Connect the photoresistor to A0 and the LED to 9'.
First nodeschool in paris is this weekend, I'll make a fast translation of the current ws content since i'm in a rush, but now the newer version of the workshopper have now l10n support i think we should update so we can decouple exercise and language and avoid package duplication.
what do you think about it ?
I really love that the workshop system can be run with no hardware attached, but, while seeing tests pass is alway nice, see things blink and move is a bit more rewarding, so i was thinking that we could make for all exercise a already built hardware setup, and a script that would require the student solution and inject it, so when someone's is passing the testing, he could just hook it to its usb and test it live.
If i have time i'll laser cut some boxes so the setup is sturdy and nice to look at
Using nodebot-workshop version 2.2.5
, and running the first exercise throws an exception:
MacBook-Pro-Dmitri:nodebot-workshop dmitri$ nodebot-workshop verify 01-blink-blink.js
module.js:338
throw err;
^
Error: Cannot find module '/usr/local/lib/node_modules/nodebot-workshop/node_modules/johnny-five/node_modules/serialport/build/serialport/v1.7.4/Release/node-v14-darwin-x64/serialport.node'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Proxyquire._require (/usr/local/lib/node_modules/nodebot-workshop/node_modules/proxyquire/lib/proxyquire.js:158:19)
at require (module.js:384:17)
at Object.<anonymous> (/usr/local/lib/node_modules/nodebot-workshop/node_modules/johnny-five/node_modules/serialport/serialport.js:14:25)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/nodebot-workshop/node_modules/proxyquire/lib/proxyquire.js:237:43)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
Any ideas?
01-blink-blink.js
var five = require('johnny-five');
var board = new five.Board();
board.on('ready', function () {
var led = new five.Led(13);
led.strobe(1000);
});
Node version is 0.12.4
, OS X 10.10.3
.
Seems as though 'spin_motor_spin' will always fail.
Even ran the solution in the source code and it also failed.
Hello, i trying to install in windows for node v6 and i get this error, how can i fix it?:
C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\src\win_delay_load_hook.c(34): error C2373: '__pfnDliNotifyHook2': redefinition; different type mo
difiers [C:\Users\DiegoCamilo\AppData\Roaming\npm\node_modules\nodebot-workshop\node_modules\weak\build\weakref.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\delayimp.h(134): note: see declaration of '__pfnDliNotifyHook2'
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe
failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "C:\Program Files (x86)\nodejs\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\DiegoCamilo\AppData\Roaming\npm\node_modules\nodebot-workshop\node_modules\weak
gyp ERR! node -v v6.7.0
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm WARN install:[email protected] [email protected] install: node-gyp rebuild
npm WARN install:[email protected] Exit status 1
Close to the start of the problem description, it says 'Ardunio', instead of Arduino. Easy typo.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.