Comments (5)
Hi @fred-dev sorry for delay, but i'm traveling for work.
you can set the status (UP / DOWN) of the pin during setup, the last parameter accepts:
LOW or HIGH.
example:
pin.setup(GPIO17, OUT, LOW);
reference:
https://github.com/kashimAstro/ofxGPIO/blob/master/src/gpio.h#L37
https://github.com/kashimAstro/ofxGPIO/blob/master/src/gpio.h#L42
sorry, what is node red?
from ofxgpio.
from ofxgpio.
After some more serious debugging, I still have this error. Initially using code from your examples I get no response from ofxGpio using an input pin. If I use python or node-red to check the gpio (using an input as I am using a button), it works, once I have done that I can then use code with ofxGpio. This works for some time and then stops. I can get the button working again 100 percent of the time by udsing node red or python to acceess the gpio and then it will work perfectly. ofxGpio stops working 100% of the time if the pi loses power, other . It seems it does not initialise the input pin properly (output pins always work).
Also your above comment to use gave me a more often functioning result, you suggest this:
pin.setup(GPIO17, OUT, LOW);
is a bit confusing, in your examples you use the syntax
gpio6 = new GPIO("6");
gpio21 = new GPIO("21");
gpio21->export_gpio();
gpio21->setdir_gpio("in");
How should this work? Maybe this is what is giving me strange results.
gpio21 = new GPIO("21", "in", "high");
gpio21->export_gpio();
gpio21->setup("21", "in" , high);
It is not clear from your code and as far as I can see your examples use a syntax that in my code does not work for a simple input, when my circuit works perfectly with other code. I would really like this project to have a button....
from ofxgpio.
Hi @fred-dev,
This is very strange, i have a lot of work around on raspberry using I / O
and i've never encountered this problem.
I can tell you with certainty that ofxgpio unlike other library
works with: "/sys/class/gpio/" for the gpio settings, and does not work on "/dev/mem"
if you are having problems with I/O through ofxgpio you can try to execute your own execs to initialize the pins and manage I/O
example on pin 17:
/* create pin 17 */
echo 17 > /sys/class/gpio/export
/* conf pin direction (in/out) */
echo out > /sys/class/gpio/gpio17/direction
/* write value ON */
echo 1 > /sys/class/gpio/gpio17/value
/* write value OFF */
echo 0 > /sys/class/gpio/gpio17/value
/* delete GPIO17 */
echo 17 > /sys/class/gpio/unexport
this weekend I will a check on ofxgpio to verify this your report. I keep you updated!
Thanks!
Dario
from ofxgpio.
Hello @kashimAstro ,
Thanks for the addon. I also want to change the pull up / pull down resistor that the bcm chip provides.
I don't know a lot, but I think this is very different from the output value you can set ?
I have a button on pin 4, connected to ground on the other side:
gpio4.setup("4");
gpio4.export_gpio();
works great, because, pin4 (BCM) has by default PULL UP resistor.
Well now I need a second button and there is no more defaulted pin like this one, so I need to be able to set pin17 to a pull-up resistor. Is this provided with the addon ??
EDIT: I found out that pin3 is working for my second button, but question remains, how to change the PUD ? There is function in bcm2835.h file of the addon:
extern void bcm2835_gpio_set_pud(uint8_t pin, uint8_t pud);
Thanks :)
from ofxgpio.
Related Issues (20)
- ADS1015 GPIO HOT 1
- Problem example-i2c-scanner HOT 1
- Can't compare ofstream or ifstream to int in gpio.cpp HOT 4
- example-apa102-ledstrip not lighting leds with Stretch HOT 5
- Use SPI1 for APA102 HOT 5
- 12c examples HOT 9
- Orange Pi 4G IOT HOT 2
- Cannot make SPI work HOT 2
- unable to set direction of gpio HOT 1
- Setting pull up resistors HOT 7
- how do i add ofxGPIO to an existing project? HOT 1
- servo example on rpi 2 - no movement HOT 1
- for Asus TinkerBoard HOT 1
- OPERATION FAILED: Unable to set direction of GPIO4 - openFrameworks not working HOT 2
- Adapting read-write example to distance sensor HOT 5
- using spi1 with MCP
- Issues with using input and output and startup.
- doesnt seems to work with RPi5 Bookworm 0F12.0 arch64 HOT 2
- error open frameworks compiling with window HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ofxgpio.