LED Blink Example Not Working

I am using C++ to control GPIO 0 to blink and LED. Similar to another post in February, I can light the LED with a 330ohm resistor in series from the 3.3V or 5V pins. However, I get nothing with the GPIO #0 pin.

Here is the code I modified from the gpio_demo example:

#include <unistd.h>
#include

#include “…/cpp/driver/everloop.h”
#include “…/cpp/driver/everloop_image.h”
#include “…/cpp/driver/gpio_control.h”
#include “…/cpp/driver/imu_data.h”
#include “…/cpp/driver/imu_sensor.h”
#include “…/cpp/driver/matrixio_bus.h”

namespace hal = matrix_hal;
#define INPUT 0
#define OUTPUT 1
#define PIN_0 0
#define PIN_1 1

#define CLK_FRQ 200000000

int main() {
hal::MatrixIOBus bus;
if (!bus.Init()) return false;

hal::GPIOControl gpio;
gpio.Setup(&bus);
gpio.SetMode(0,OUTPUT);
usleep(100000);
while (true) {
usleep(50000);
gpio.SetGPIOValue(0,1);
usleep(50000);
gpio.SetGPIOValue(0,0);
}

return 0;
}

hmm…

if you have installed the kernel modules you can use the gpios directly with wiringpi, or from the shell, you can find the GPIO-IDs with:

sudo cat /sys/kernel/debug/gpio
...
...
gpiochip2: GPIOs 496-511, parent: spi/spi0.0, matrixio-gpio, can sleep

# control the GPIO0 from the shell

# in this case GPIO0 is GPIO496
# export gpio0
echo 496 > /sys/class/gpio/export
# set to output
echo out > /sys/class/gpio/gpio496/direction
# high
echo 1 > /sys/class/gpio/gpio496/value
# low
echo 0 > /sys/class/gpio/gpio496/value

if you want you can try also my led_blinking example in python, using my paython-hal:

I’m embarrassed to say that a reboot of the Matrix/Pi cured it as written. No telling what was hanging it up.

Thanks for the quick reply, though.

did you attach hardware while running the system? when i plug in my logic analyzer it somtimes resets something on the board and i need a could reboot. so better attach hardware while the system is off. :slight_smile: