 gpio = require 'gpio'
 app = express()
 gpio18 = gpio.export 18
+gpio23 = gpio.export 23
+gpio22 = gpio.export 22, {
+   direction: 'in'
+}
 
+beatsInterval = null
 
 app.configure ->
   app.set 'port', process.env.PORT or 4000

   gpio18.state = val


app.listen app.get('port'), ->
  console.log "Listening on port #{app.get('port')}"


app.get '/off/18', (req, res) ->
  gpio18.reset()
  clearInterval beatsInterval
  res.send('off')

app.get '/beats/18', (req, res) ->
  beatsInterval = setInterval ->
    gpio18.set()
    setTimeout ->
      gpio18.reset()
    , 200
  , 1000
  res.send('beats started')



app.get '/toggle/18', (req, res) ->
