Last active
December 7, 2017 11:10
-
-
Save kuetsuhara/306ba40fe601979c92b42dedfa0511dd to your computer and use it in GitHub Desktop.
node-red connet to microbit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var BBCMicrobit = context.global.microbit | |
var text = 'Hello there'; | |
console.log('Scanning for microbit'); | |
BBCMicrobit.discover(function(microbit) { | |
console.log('\tdiscovered microbit: id = %s, address = %s', microbit.id, microbit.address); | |
microbit.on('disconnect', function() { | |
console.log('\tmicrobit disconnected!'); | |
}); | |
console.log('connecting to microbit'); | |
microbit.connectAndSetUp(function() { | |
console.log('\tconnected to microbit'); | |
console.log('sending text: "%s"', text); | |
microbit.writeLedText(text, function() { | |
console.log('\ttext sent'); | |
console.log('disconnecting'); | |
microbit.disconnect(); | |
}); | |
}); | |
}); | |
return msg; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment