tableflip / nodebot-workshop

A nodeschool workshop on how to get your ardunio alive with johnny-five
https://www.npmjs.org/package/nodebot-workshop
210 stars 59 forks source link

Exercise Six; Ping Bell does not work for me #15

Closed varjmes closed 8 years ago

varjmes commented 10 years ago

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);
});
olizilla commented 10 years ago

Hey thanks for reporting this, will take a look first thing tomorrow!

gorhgorh commented 10 years ago

hi there, little question, you said you followed the diagram for the wiring and i realised that it the piezo is connected to pin 9 in the diagram, instead of the pin 8 required by the solution, what pin is the piezo attached to in your setup ?

varjmes commented 10 years ago

A lot of the diagrams have those inconsistencies; It is wired to pin 8 :)

Sent from my iPad

On 14 Oct 2014, at 08:15, gorhgorh notifications@github.com wrote:

hi there, little question, you said you followed the diagram for the wiring and i realised that it the piezo is connected to pin 9 in the diagram, instead of the pin 8 required by the solution, what pin is the piezo attached to in your setup ?

— Reply to this email directly or view it on GitHub.

alanshaw commented 10 years ago

@Charlotteis if you notice inconsistencies please open an issue or send a PR so we can improve! :)

varjmes commented 10 years ago

@alanshaw I may try and do that once I've finished the course, thanks for the suggestion!

gorhgorh commented 10 years ago

My bad, I'll fix that asap :)

2014-10-14 10:49 GMT+02:00 Charlotte Spencer notifications@github.com:

@alanshaw https://github.com/alanshaw I may try and do that once I've finished the course, thanks for the suggestion!

— Reply to this email directly or view it on GitHub https://github.com/tableflip/nodebot-workshop/issues/15#issuecomment-59008999 .

achingbrain commented 8 years ago

I think this has been resolved. Please reopen if not so.