Mechanical buttons and switches can suffer from switch bounce where they toggle rapidly between open and closed for several milliseconds.
You can try debouncing the button/switch in software or hardware.
Probably simplest in software.
If the level changes (on to off, or off to on) wait x milliseconds and read the gpio again. If it is still in the new ...
The RPI ARM core is an ARM 1176jzf-S, the suitable flags should then be
-march=armv6zk -mcpu=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp
Drop the -mfloat-abi=hard -mfpu=vfp when on a soft float distro.
These flags can be found by running gcc -mcpu=native -march=native -Q --help=target on gcc >= 4.7`
There is no official library
There are several options. I usually use http://wiringpi.com. This is used for the gpio utility included in recent Raspbian releases.
Joan's pigpio library is at https://github.com/joan2937/pigpio and she also has Python wrappers. If you want to use sockets or a daemon this is recommended and has good support for hardware and ...
Take the time to read Jack Ganssle's debouncing guide. The first page illustrates the problem in great detail, and the second how to deal with it in hardware or software. There isn't a 'perfect' debounce method, but there are a lot of bad ones!
This is a problem you will come across repeatedly if interfacing software with switches, so it's worth taking ...
That example from elinux uses memory-mapped IO. The kernel also exports a user space interface via /sys/class/gpio,1 which is also documented on elinux. Working in C you would use low level read()/write() instead of echo, obviously. Don't use higher level stream based functions.
Some programmers become a bit upset when told to use a file interface for ...
I cannot see a call to bcm2835_init() which must be called before calling any other functions in the bcm2835 library.
Also ensure you run your program with root access, since this is needed to use the bcm2835 library.
command to run code in /etc/rc.local
Three things to remember when putting commands in rc.local:
Don't use sudo, because the script is run as root anyway.
Unless the command exits quickly, it must fork to the background. This is accomplished by adding & to the end:
$PATH may not be set. This is a list of directories where the shell ...
You seem to be creating then sending 1000 waveforms. There will be jitter between each waveform.
Try generating one big waveform and sending that.
Basically de-indent the lines
wid = pi.wave_create()
if wid >= 0:
so that they are executed after the for loop (just the once rather ...
This returns the same thing as reading /sys/class/thermal, i.e., the core temp. Reading the /sys file is preferable programmatically because it is just a sequence of open/read system calls, instead of a fork/execute plus a bunch of open/read/write with pipes.
How would I read the GPU temperature aswell?
The BCM2835/6 ...
To set a pin numbering scheme you use one of four Setup functions:
int wiringPiSetup (void);
int wiringPiSetupGpio (void);
int wiringPiSetupPhys (void);
int wiringPiSetupSys (void);
To use BCM GPIO numbering you would replace you would use wiringPiSetupGpio(void); and modify the pin numbers in your code appropriately.
I'm wondering, may understand that Raspberry Pi's I2C is in fact the SMBus version of I2C ?
I don't think it is limited in that sense but that is the normative way to use it. There is no such limitation with the kernel, since the protocol docs for the interface say, "If you write a driver for some I2C device, please try to use the SMBus commands if at all ...
Here is some code which waits for a GPIO to change state. It should do pretty much the same as you want to do.
gcc -o wfi wfi.c
Shared or dynamic libraries are needed at run time. So you need the library not only on the build system but in on the target system, in this case on the PI.
This is different from static libraries. If you use a static library at build time, all the needed code from the library would be included in the executable, and the library would not be needed to run ...
Previously the kernel would automatically disable interrupts when you set one of rising/falling edge detection methods but that apparently stopped happening, causing a kernel panic.
See this post for more details.
Sniffing other WiFi networks you are not associated must be supported by the WiFi chip, called monitor mode. If you look at the chip configuration on the RasPi with:
rpi ~$ iw list
--- snip ---
Supported interface modes:
I am currently interacting with the terminal using the system() command, such as
Don't do that. All of those commands are implemented in C in the first place and are open source. Many of them are just wrappers on system calls.
if (mount (
Use gettimeofday(), it returns seconds and microseconds.
You are unlikely to get satisfactory results for servos using Linux sleeps. There will be glitches. Unless you have a particularly poor servo the glitches will result in servo twitches.
A B+ has two channels of hardware PWM suitable for driving servos.
The C libraries which generate hardware timed ...
You have misunderstood the usage of the set and clear registers.
If bit x is 1 in the set register then GPIO x is set high. If bit x is 0 then the level of GPIO x is not affected (i.e. if high it stays high, if low it stays low).
If bit x is 1 in the clear register then GPIO x is set low. If bit x is 0 then the level of GPIO x is not affected (i.e. if ...
This type of "clock" support isn't C99 but POSIX.
Try removing -std=c99 from your compilation command and compile your code.
If that doesn't work, Add
#define _POSIX_C_SOURCE 199309L
to your code and compile it.
Refer this man page for more details.
OK. Some good questions here. I'll try to take it in order since that's the easiest way to answer, but it may make the text a bit rambling.
As far as I know there isn't an inbuilt package for the GPIO other than the Python GPIO package. However, WiringPi has been packaged for easier installation. It hasn't yet been included into Rasbian. I think it will be ...
Using sockets would be the standard network solution.
Use TCP/IP if you want guaranteed in-order delivery or UDP if that isn't a concern.
I've used TCP/IP to deliver over 100,000 12 byte messages per second from Pis.
I used netbeans instead of eclipse as an IDE to both Develop and debug C/C++ Programs on my Raspberry Pi. I have listed down how I did it on this blog post: http://precisemath.wordpress.com/2014/04/13/c-dev-pi-2/
The problem was that protobuf installs protoc by default in the /usr/local/bin directory, as opposed to /usr/bin.
Therefore, when I called ./configure with the --with-protoc=/usr/bin parameter, the location was wrong.
SOMEHOW unbeknownst to me, I had an older version of protoc (2.4.0) installed in /usr/bin, so the ./configure didn't complain (maybe this ...
It is much easier to use the wiringSerial module from wiringPi, but if you must do it the hard way tab should be a buffer e.g. char tab not a single char.
It looks like you are sending random junk and storing it who knows where.
NOTE You should use cfsetispeed to set baud rate read man termios
Did you consider 2D Game engines/libraries ? Because OpenGL/OpenVG are very low-level and don't do font handling , the added "belt and suspenders" of those libs will make your life much easier :
TRISA would have to be quite a complicated C macro for that to work on a Pi.
Have a look at http://abyz.me.uk/rpi/pigpio/examples.html#Misc_tiny_gpio which shows possibly the simplest way to access the Pi GPIO via C.
In particular it shows how to implement the following functions.
gpioSetMode /* set GPIO mode */
gpioGetMode /* get GPIO mode */