shokai / arduino_firmata

Arduino Firmata protocol implementation on Ruby
http://shokai.github.io/arduino_firmata
MIT License
104 stars 23 forks source link

10 second delay before using Arduino Mega 2560 #36

Open phemmer opened 10 years ago

phemmer commented 10 years ago

I have an Arduino Mega 2560 and whenever using this library, I have to wait 10 seconds after connecting before sending any commands. I've been testing with a simple LED on pin 10 and using digital_write(10, true). If I write within the first 10 seconds after connect, nothing happens. Also If I write at the 9th second, I have to wait 10 more seconds before it will respond. Basically it requires 10 seconds of silence after connect before it will start working.

However by removing the following code in arduino.rb line 54, it only requires a 1 second delay.

  (0...6).each do |i|
    write(REPORT_ANALOG | i)
    write 1
  end
  (0...2).each do |i|
    write(REPORT_DIGITAL | i)
    write 1
  end

I'm not sure exactly why this occurring, or why that code is there, but if it's causing such a huge delay, perhaps it should be removed, or at least made optional.