Questions tagged [c]

For questions pertaining to compiling C programs on the Raspberry Pi.

C (pronounced like the letter C) is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system.

Although C was designed for implementing system software, it is also widely used for developing portable application software.

C is one of the most widely used programming languages of all time and there are very few computer architectures for which a C compiler does not exist. C has greatly influenced many other popular programming languages, most notably C++, which began as an extension to C, and Java.

Design

C is an imperative (procedural) systems implementation language. It was designed to be compiled using a relatively straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support. C was therefore useful for many applications that had formerly been coded in assembly language.

Despite its low-level capabilities, the language was designed to encourage cross-platform programming. A standards-compliant and portably written C program can be compiled for a very wide variety of computer platforms and operating systems with few changes to its source code. The language has become available on a very wide range of platforms, from embedded microcontrollers to supercomputers.

280 questions
12
votes
3 answers

Push buttons getting too many events

I am writing a mp3 player that writes info to a LCD display, I'd like to convert it from using the keyboard to using push buttons but I'm constantly getting too many key presses. I've tried pull up and falling/rising edge but I'm still getting the…
linuxgnuru
  • 625
  • 10
  • 21
10
votes
2 answers

Turn LED on and off with switch

I'm trying to write code to get an LED to turn on when it is off and to turn off when it is on using a tactile push button switch. I've written what I believe to be is the right code with the wiringPi library, but I can only get it to turn on when…
Mark Luna
2
votes
3 answers

Errors compiling C program with time.h library

I am facing some problems in my raspberry Pi 3 B+ when I compile this simple program that uses time library: #include #include int main(int argc, char** argv) { struct timespec now; clock_gettime(CLOCK_REALTIME, &now); …
Arcones
  • 123
  • 1
  • 6
2
votes
1 answer

How do I read just the Pi's serial number with a program coded in C?

I'm trying to write a small C program that reads the Pi's serial number, just the serial number and not all the other information, to do this I'm using fseek here is my code, based on a few C examples and tutorials: int main() { FILE *fp =…
tyllgoed
  • 23
  • 3
2
votes
1 answer

Boilerplate c pocketsphinx mic input

What I am trying to do is have pocket sphinx get my mic input and have it then translate and based on the results compare it to predefined words and then execute a command/script. I was able to get pocketsphinx installed and running on my Raspberry…
Vlad
  • 41
  • 5
1
vote
1 answer

Traffic light in C wiringPi

I am working on a project for my C programming class and need to use wiringPi on my raspberryPi. I need to create a traffic light (like a real one- red to green to yellow to red, etc.) and a pedestrian signal that turns on a white light and turns…
user45649
0
votes
2 answers

Why does my SPI-using program in C give varying results?

I've attached a soil hygrometer I bought on ebay to my rpi via an MCP3008 ADC. All I want is a small program that can spit out the current value as an integer. I don't want to use Python... I must emphasize that I'm not a C programmer at all, so I'm…
fiskeben
  • 221
  • 4
  • 9
0
votes
1 answer

Fast OS for embedded system

I'm creating a project with raspberry pi and I need an "os" which boots in a few seconds when the power is turned on. The os has to have the following features: audio driver (3.5mm) c/c++ running ability with sdl library ability to mount usb (or an…
Atte
  • 1
0
votes
1 answer

How to set an initial value of a variable of struct in C?

Im making a library for a raspberry pi program and im running into trouble of a struct variable having an initial value. myLib.h typedef struct { int startingNumber = 0; // this throw an error in C } myStruct void increment(myStruct * a){ …
DrakeJest
  • 75
  • 1
  • 10
0
votes
1 answer

code gets stock in keypad function

i am doing this project where i want to put a keypad and take in password from a user and then open the door or not. i used C but every time i call the keypad function in my code the code will not continue. pls help me void keypad() { int i,j; …
chenko
  • 1
-1
votes
1 answer

L293D wiring only works when 6v ground connected to 5v live

I have the following code which I use to run some DC motors on the Raspberry Pi with an L293D H-Bridge. I should be able to control which motor is driven and in which direction. #include #include #define MOTOR1_FWD 16 #define…
Quintin Balsdon
  • 681
  • 5
  • 19