1 / 8

Embedded Programming and Robotics

Embedded Programming and Robotics. Lesson 19 Raspberry Pi Programming in C. Get the WiringPi Library. sudo apt-get install git -core git clone git:// git.drogon.net/wiringPi Build the library: cd wiringPi ./ build. Compiling C Programs.

gwend
Download Presentation

Embedded Programming and Robotics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Embedded Programming and Robotics Lesson 19 Raspberry Pi Programming in C Raspberry Pi Programming in C

  2. Get the WiringPi Library • sudo apt-get install git-core • git clone git://git.drogon.net/wiringPi • Build the library: • cd wiringPi • ./build Raspberry Pi Programming in C

  3. Compiling C Programs • You can use any text editor, such as leafpad, nano, vi, etc. to create your source file • Always give the file a .c (lower case) extension, such as RobotControl.c • To compile to an executable, do this: • gcc –o RobotControlRobotControl.c • The –o option gives the output executable name Raspberry Pi Programming in C

  4. Compiling C Programs • The parameter is the C file name, and the extension is required • If you get error messages about libraries not being found, use the sudoldconfig command to check what default libraries are available Raspberry Pi Programming in C

  5. Executing Your Program • Run the program with ./RobotControl • If you know about make files and shell scripts you can use them, but they’re beyond the scope of this simple introduction Raspberry Pi Programming in C

  6. Writing a C Program • You’ll need to include the following two things: #include <stdio.h> #include <wiringPi.h> • They’re not needed on the Arduino, but you need them for C • The gcc compiler really compiles C++ Raspberry Pi Programming in C

  7. Writing a C Program • Initialize the library with the following: wiringPiSetupGpio(); • Set GPIO pins: pinMode(LED1, OUTPUT); Raspberry Pi Programming in C

  8. Writing a C Program • Blink an LED: • digitalWrite (LED1, HIGH) ; • delay (500) ; • digitalWrite (LED1, LOW) ; • delay (500) ; Raspberry Pi Programming in C

More Related