<commit_before>var arduino = require('../');

var board = new arduino.Board({
  debug: true
});

var servo = new arduino.Servo({
  board: board,
  pin: "A0"
});



servo.on("attached", function() {

  this.read(function(current) {
    this.write(180);
  });



});<commit_msg>Servo event examples<commit_after>var arduino = require('../'),
    board, led, servo;

// Construct instances
board = new arduino.Board({
  debug: true
});

led = new arduino.Led({
  board: board,
  pin: 13
});

servo = new arduino.Servo({
  board: board,
  pin: 9
});

// Once servo is attached:
//  - "read"
//      - log position
//  - "aftersweep"
//      - blink the led
//      - read the position
//      - detach the servo
//  - "detached"
//      - log detach message
//
//  - execute full sweep

servo.on('attached', function() {
  console.log('attached');

  this.on('read', function(pos) {
    console.log(pos);
  });

  this.on('detached', function() {
    console.log('detached');
  });

  this.on('aftersweep', function() {
    led.blink();

    this.read();
    this.detach();
  });

  this.sweep();
});
{'fraction_non_alphanumeric': 0.19525547445255476, 'fraction_numerical': 0.006386861313868613, 'mean_word_length': 2.6204620462046204, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7345133', 'n_tokens_mistral': 419, 'n_tokens_neox': 387, 'n_words': 89}