GOBOT loading code with grot wont do anything

I started to play with Arduino and GOBOT and i having an issue the run the basic blink example.

I run the blink example from the arduino IDE and it works fine

now I’m trying to test the gobot example with a serial connection but noting happen

Also when i load it using gort i cant see any error

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file “/tmp/128305084”
avrdude: writing flash (12224 bytes):

Writing | ################################################## | 100% 1.94s

avrdude: 12224 bytes of flash written
avrdude: verifying flash memory against /tmp/128305084:
avrdude: load data flash data from input file /tmp/128305084:
avrdude: input file /tmp/128305084 contains 12224 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 1.51s

avrdude: verifying …
avrdude: 12224 bytes of flash verified

avrdude done. Thank you.

Any suggestion how to figure what’s wrong?

I haven’t played with Arduino for some time and don’t have access to one now, but I will try to help.

The instructions on the example page you linked to don’t do a good job of explaining what should be happening. Firmata is a protocol for controlling a remote device, in this case your Arduino. This means you need to have the Firmata firmware installed on the Arduino, the Arduino connected to your computer, and the Go program that tells the Arduino what to do running on your computer.

I think you may have gotten the firmware installed (I can’t really tell because the name of the input file in inconclusive). Assuming the correct firmware was loaded, you are most of the way there because you have successfully connected the Arduino and figured out what port it is connected over.

Next, you should change the line firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0") in the Go code, replacing /dev/ttyACM0 with whatever you used with gort.

Compiling and running the Go code should start the LED blinking. You might need to reboot the Arduino after installing the firmware, but I don’t remember if that is needed or if avrdude starts the firmware after loading it.

If this doesn’t help, tell us more about what you did.

BTW, its also OK to load the Firmata firmware from the Arduino IDE.

Hi,

i load the firmata framework to the Arduino uno with Arduino IDE.

and then this is exactly what i did

mik@mik-Aspire-S3:~/Programing/gobot/blink$ gort scan serial
1 serial port(s) found.

  1. [/dev/ttyUSB0] - [usb-1a86_USB2.0-Serial-if00-port0]
    mik@mik-Aspire-S3:~/Programing/gobot/blink$ go run main.go 2017/06/16 17:15:24 Initializing connections…
    2017/06/16 17:15:24 Initializing connection Firmata-698E90E2FF9B7668 …
    2017/06/16 17:15:24 Initializing devices…
    2017/06/16 17:15:24 Initializing device LED-14A20F94B31604C5 …
    2017/06/16 17:15:24 Robot bot initialized.
    2017/06/16 17:15:24 Starting Robot bot …
    2017/06/16 17:15:24 Starting connections…
    2017/06/16 17:15:24 Starting connection Firmata-698E90E2FF9B7668 on port /dev/ttyUSB0…
    mik@mik-Aspire-S3:~/Programing/gobot/blink$ sudo gort arduino upload firmata /dev/ttyUSB0

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file “/tmp/677463253”
avrdude: writing flash (12224 bytes):

Writing | ################################################## | 100% 1.94s

avrdude: 12224 bytes of flash written
avrdude: verifying flash memory against /tmp/677463253:
avrdude: load data flash data from input file /tmp/677463253:
avrdude: input file /tmp/677463253 contains 12224 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 1.51s

avrdude: verifying …
avrdude: 12224 bytes of flash verified

avrdude done. Thank you.

still no blink :frowning:

Gort is a tool for loading firmware on Arduino. You don’t need to load the firmware with both the Arduino IDE and Gort.

The next step to get blinking to work is to build and run the example code (I already changed the tty to match what you used for Gort):

package main

import (
	"time"

	"gobot.io/x/gobot"
	"gobot.io/x/gobot/drivers/gpio"
	"gobot.io/x/gobot/platforms/firmata"
)

func main() {
	firmataAdaptor := firmata.NewAdaptor("/dev/ttyUSB0")
	led := gpio.NewLedDriver(firmataAdaptor, "13")

	work := func() {
		gobot.Every(1*time.Second, func() {
			led.Toggle()
		})
	}

	robot := gobot.NewRobot("bot",
		[]gobot.Connection{firmataAdaptor},
		[]gobot.Device{led},
		work,
	)

	robot.Start()
}

If you save that to blink.go and have already successfully ran:

go get -d -u gobot.io/x/gobot/...

Then run (while the Arduino is connected)

go run blink.go

And the Arduino should start blinking.

1 Like

thanks man it works perfectly

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.