These are chat archives for nebrius/raspi-io

17th
Feb 2015
Bernard Mordan
@bmordan
Feb 17 2015 22:46
Hello can I ask for some help. I've just spent hours try to get a motor to reverse. I can spin the motor fine, but can't flip direction. Which pin on the pi should go in the ??? hole?
var raspi = require('raspi-io')
var five = require('johnny-five')
var board = new five.Board({
  io: new raspi()
})

board.on('ready', function () {
  var l = new five.Motor(
    pins: {
      pwm: 'GPIO18',
      dir:  ? ? ?
    }
  })

  var m = {
    f: function () {
      l.forward(80)
    },
    s: function () {
      l.stop()
    },
    r: function () {
      l.reverse(80)
    }
  }

  board.repl.inject({
    m: m
  })

})
Bryan Hughes
@nebrius
Feb 17 2015 22:47
just an FYI, looks like you had one too many backticks for gitter to format it
Bernard Mordan
@bmordan
Feb 17 2015 22:48
that still doesn’t look right
:smile:
Bryan Hughes
@nebrius
Feb 17 2015 22:48
no worries, I formatted it on my end (my brain has a hard time reading non-indented code). Give me one sec
Are you using a motor shield/driver that takes a direction pin?
ah, there it goes :)
Bernard Mordan
@bmordan
Feb 17 2015 22:51
Yes its a L298N with the B rev 2 raspberry pi
Bryan Hughes
@nebrius
Feb 17 2015 22:51
If so, you can connect it to any GPIO pin. There is a table with all of the pins at https://github.com/bryan-m-hughes/raspi-io/wiki
You can connect it to (randomely picking one) GPIO17, which is on pin 11 of the P1 header
Bernard Mordan
@bmordan
Feb 17 2015 22:53
OK I’ll try that
Thanks Bryan
Oh closer Cannot digitalWrite to pin "' + pin + '" unless it is in OUTPUT mode
Bernard Mordan
@bmordan
Feb 17 2015 22:58
  this.pinMode('GPIO17', five.Pin.OUTPUT)
  var l = new five.Motor(['GPIO18','GPIO17'])
Error: Unknown pin "GPIO17"
Boo
  this.pinMode(0, five.Pin.OUTPUT)
  var l = new five.Motor(['GPIO18','GPIO17'])
Bryan Hughes
@nebrius
Feb 17 2015 23:01
Did that work?
Bernard Mordan
@bmordan
Feb 17 2015 23:01
Holy crapping air punch this totally worked :punch:
Awesome
Bryan Hughes
@nebrius
Feb 17 2015 23:01
ok, so pins aren’t being aliased for some reason. Would you mind filing an issue on github?
Bernard Mordan
@bmordan
Feb 17 2015 23:02
Of cause.
Bryan Hughes
@nebrius
Feb 17 2015 23:03
Thanks