Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
arduino.on('ready', function () {
// Access the push button on pin D2
var button = new five.Button(2);
// Access the LED on pin D6
var led = new five.Led(6);
// Event listeners with callback functions
// Will capture button down event
button.on('down', function () {
led.on();
console.log('button is pressed');
});
// Will capture button held down event
button.on('hold', function () {
led.blink(100);
console.log('button is held down for over half a second');
});
board.on("ready", function() {
console.log("Board ready!");
const button = new five.Button("A0");
const imu = new five.IMU({
pins: [11,12], // connect SDA to 11 and SCL to 12
controller: "MPU6050"
});
imu.on("data", function() {
let dataAvailable = this.accelerometer.x;
if(dataAvailable && !started){
console.log('imu ready')
}
button.on("hold", () => {
predictionDone = false;
let data = {xAcc: this.accelerometer.x,
board.on('ready', function() {
button = new five.Button(2) // digital pin 2
board.repl.inject({
button: button
})
button.on('down', function() {
console.log('down')
})
button.on('hold', function() {
console.log('hold')
})
button.on('up', function() {
console.log('up')
})
board.on('ready', function () {
var piezo = new five.Piezo(9)
var led = new five.Led(13)
var btn = new five.Button(5)
var thermo = new five.Sensor('A0')
var threshold = 50
var isOnFire = false
var isReset = false
var sirenInterval = null
// Sound the alarm
function panic () {
if (isOnFire) return
isOnFire = true
led.strobe(1000)
piezo.tone(five.Piezo.Notes.c4, 750)
sirenInterval = setInterval(function () {
board.on("ready", function() {
button = new five.Button(8);
var led = new five.Led(7);
board.repl.inject({
button: button,
led: led
});
button.on("down", function() {
console.log("down");
led.on();
});
button.on("up", function() {
console.log("up");
led.off();
});
ngOnInit() {
this._button = new five.Button({
pin: this.pin,
isPullup: this.pullup
});
this._button.on('down', () => {
this.zone.run(() => {
this.click.emit({
pin: this.pin
});
});
});
}
}
board.on('ready', () => {
const led = new five.Led('a0');
const button = new five.Button({
pin: 'a2',
isPullup: true,
});
button.on('press', () => led.on());
button.on('release', () => led.off());
});
board.on("ready", function() {
var gate = new five.Pin(9);
var button = new five.Button(2);
button.on("press", function() {
gate.write(1);
});
button.on("release", function() {
gate.write(0);
});
});
componentWillMount(){
const { pin, invert, isPullup } = this.props;
this.button = new five.Button({
pin,
isPullup,
invert
});
this.setButtonEvents(this.props);
}
board.on("ready", function() {
var leds = five.Leds([3,4,5]);
var btn = five.Button(2);
btn.on("press", function() {
leds[0].off();
leds[1].on().blink(500);
leds[2].off().blink(500);
});
btn.on("release", function() {
leds[0].on();
leds[1].off().stop();
leds[2].off().stop();
});
});