0% found this document useful (0 votes)
113 views1 page

Raspberry Pi & Arduino Coding Guide

This document provides instructions for writing and executing shell scripts, C programs, and Python programs on Raspberry Pi. It outlines the basic steps to create files with the appropriate extensions, add code, compile if needed, make the files executable, and run the programs.

Uploaded by

Andreea Ionescu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views1 page

Raspberry Pi & Arduino Coding Guide

This document provides instructions for writing and executing shell scripts, C programs, and Python programs on Raspberry Pi. It outlines the basic steps to create files with the appropriate extensions, add code, compile if needed, make the files executable, and run the programs.

Uploaded by

Andreea Ionescu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Circuit Basics

Raspberry Pi, Arduino, and DIY Electronics Tutorials

Raspberry Pi Programming Cheat Sheet


How to write and execute Shell Scripts, C programs, and Python programs:

Shell Scripts
1. Create a file with a ".sh" extension by entering this at the command prompt:
sudo nano [Link]
2. Add the shebang to the first line of the script file:
#!/bin/sh
3. Write and save the script, then make it executable by entering this at the command prompt:
sudo chmod +x [Link]
4. To run the shell script, navigate to the directory where you saved the script file and enter this:
sh [Link]
or
./[Link]

Python Programs
1. Create a file with a ".py" extension by entering this at the command prompt:
sudo nano [Link]
2. After writing your program, you can run it by navigating to the directory where the file is saved, then entering this:
python [Link]
3. To make the program executable, enter this at the command prompt:
chmod +x [Link]
4. Now you can run the program by entering this:
./[Link]

C Programs
1. Create a new file with a “.c” extension by entering this at the command prompt:
sudo nano example.c
2. Write your code, save the file, and exit Nano.
3. Compile the source file into a new file with this command:
gcc example.c -o compiledexample
4. Make the compiled file executable by entering this at the command prompt:
chmod +x compiledexample
5. Run the program by entering this:
./compiledexample

You might also like