Closed abdullahyildiz closed 9 years ago
Did you try this?
var myOnboardLed = new mraa.Gpio(3, false, true);
And yes on gen1 there is no good way of doing this as the LED is not on the same pin as pin13, it's an annoying hardware 'feature'.
var myOnboardLed = new mraa.Gpio(3, false, true);
is definitely a lot easier. :+1:
Do you have an idea that why using the pin number 13 on Arduino sketch worked? That is, is it through the firmware which is kept on 8 MByte SPI Flash by translating the pin numbers?
When you compile an arduino sketch for a g1 the wiring library has a hack to change both gpios at the same time. I don't like this 'feature' so I decided not to implement it as the LED & pin13 won't flip at the same frequency and I consider the behaviour confusing and essentially removes a 'fast' GPIO. Also previously the library couldn't really handle it, nowadays it would be fairly easy with an advance hook. I've just updated our doc to mention it with 78fe6f427082ba4541ae190af2c65da3d531b7a7
I cannot run the default example which uses the GPIO pin 13 for the onboard LED:
When I run the code, the onboard LED does not blink. However, when I use an Arduino LED blink sketch using Arduino IDE (and use the pin 13), it works.
I tried updating mraa and upm, but it didn't work.
As a workaround,
I changed the line 85 at file api/mraa/gpio.hpp:
as
to make mraa use
mraa_gpio_init_raw(pin)
function which afterwards accesses sysfs:Then built mraa and installed the new node module instead of the existing one (which was version 0.4.5).
Then I changed the GPIO pin number to 3 instead of 13 in the example above:
This is because the GP LED (onboard LED) has the GPIO pin number of 3 within sysfs and as I see, mraa uses sysfs to access the GPIO pins.
I know it is not a good solution but I couldn't find an easier way.