A few days ago, I came across the Gobot website. Gobot is a framework written in the Go Programming Language (golang) to work with robots, drones and the Internet of Things (IoT). Gobot work on several different platforms including the Raspberry Pi.
After grabbing a Raspberry Pi and an SD Card that I had laying around. My first step was to download DietPi and burn it to the SD Card. The 'Getting Started' page was easy to follow and had me running a lightweight version of Linux in short order.
After digging through the Gobot documentation for a bit, I figured that I had enough knowledge to be dangerous. The rough plan is to setup a simple circuit and control that circuit with a simple go program running on a Rasberry Pi. The Gobot documentation has an example of flashing a LED using Rasberry Pi. In the past, I followed the 'Turning on an LED with your Raspberry Pi's GPIO Pins' tutorial from The PiHut with good results.
It was time to get out some electronics parts. I grabbed a breadboard, a 330 Ohm resistor, a red LED, and a few Male-Female jumpers wires.
I am using a Raspberry Pi 3 Model V1.2. From pin 12 on the Pi the orange jumper goes to the anode (long) leg of the LED. The cathode (short) leg goes to the resistor. The resistor is connected to the yellow jumper which is connected to pin 14 (ground) on the Pi. The following picture shows the setup. Please note that the blue and green jumper wires are not connected to anything.
My next step was to copy the example code from Gobot into a file on my computer. I changed the example code to use pin 12 and saved the change.
The Gobot documentation shows the compiler switches needed to create a binary that can run on a Rasberry Pi. I used the following.
GOARM=7 GOARCH=arm GOOS=linux go build {filename.go}
After copying the file binary to the Rasberry Pi, I ran the file using a terminal and the LED began to flash.
References
- Gobot
- Go Programming Language (golang)
- DietPi
- Turning on an LED with your Raspberry Pi's GPIO Pins
- Raspberry Pi Pinout - https://pinout.xyz/pinout/pin12_gpio18
- Gobot example code for flashing a LED
- Gobot Compiling
No comments:
Post a Comment