Raspberry PI (23)
Needed
1. Raspberry Pi
2. 16x2 LCD display 202A-D REV.A
3. Cables
4. Recommend install Raspbian
Schematic
Pictures on Display
-
1
sudo dpkg-reconfigure tzdata sudo apt-get update sudo apt-get upgrade
-
2Set the date and time. From the command line type (replace parts as necessary):
sudo date --set="15 September 2014 11:13:00"
-
3To install Apache and PHP, execute the following commands:
sudo apt-get install apache2 php5 libapache2-mod-php5
-
4Now restart the service:
sudo service apache2 restart
OR
sudo /etc/init.d/apache2 restart
-
5To install MySQL, install a few packages with the following command:
sudo apt-get install mysql-server mysql-client php5-mysql
-
6We will now install FTP to allow transferring files to and from your Raspberry Pi.
-
7Take ownership of the web root:
sudo chown -R pi /var/www
-
8Next, install vsftpd:
sudo apt-get install vsftpd
-
9Edit your vsftpd.conf file:
sudo nano /etc/vsftpd.conf
-
10Make the following changes:
- anonymous_enable=YES to anonymous_enable=NO
- Uncomment local_enable=YES and write_enable=YES by deleting the #symbol in front of each line
- then go to the bottom of the file and add force_dot_files=YES.
-
11Now save and exit the file by pressing CTRL-O, CTRL-X.
-
12Now restart vsftpd:
sudo service vsftpd restart
-
13Create a shortcut from the Pi user's home folder to /var/www:
ln -s /var/www/ ~/www
-
14You can now FTP using the Pi user and access the /var/www folder via a shortcut that should appear on login.
Now I'll show you a very easy way how to control RS232 8 relays
with the help of Raspberry PI
1 RS232 KMTronic 8 Relay Board
1 USB cable
Commands for control shell script of the relays:
Web interface
For full shell scrip download this - Download
Download web interface -Download
Compiling C and C++ Programs
gcc is the "GNU" C Compiler, and g++ is the "GNU C++ compiler, while cc and CC are the Sun C and C++ compilers also available on Sun workstations. Below are several examples that show how to use g++ to compile C++ programs, although much of the information applies to C programs as well as compiling with the other compilers.
Example 1: Compiling a simple program
Consider the following example: Let "hello.C" be a file that contains the following C++ code.#include "iostream.h" int main() { cout << "Hello\n"; }The standard way to compile this program is with the command
g++ hello.C -o hello
This command compiles hello.C into an executable program named "hello" that you run by typing 'hello' at the command line. It does nothing more than print the word "hello" on the screen.
Alternatively, the above program could be compiled using the following two commands.g++ -c hello.C g++ hello.o -o hello
The end result is the same, but this two-step method first compiles hello.C into a machine code file named "hello.o" and then links hello.o with some system libraries to produce the final program "hello". In fact the first method also does this two-stage process of compiling and linking, but the stages are done transparently, and the intermediate file "hello.o" is deleted in the process.
Frequently used compilation options
C and C++ compilers allow for many options for how to compile a program, and the examples below demonstrate how to use many of the more commonly used options. In each example, "myprog.C" contains C++ source code for the executable "myprog". In most cases options can be combined, although it is generally not useful to use "debugging" and "optimization" options together.
- Compile myprog.C so that myprog contains symbolic information that enables it to be debugged with the gdb debugger.
-
g++ -g myprog.C -o myprog
- Have the compiler generate many warnings about syntactically correct but questionable looking code. It is good practice to always use this option with gcc and g++.
-
g++ -Wall myprog.C -o myprog
- Generate symbolic information for gdb and many warning messages.
-
g++ -g -Wall myprog.C -o myprog
- Generate optimized code on a Solaris machine with warnings. The -O is a capital o and not the number 0!
-
g++ -Wall -O -mv8 myprog.C -o myprog
- Generate optimized code on a Solaris machine using Sun's own CC compiler. This code will generally be faster than g++ optimized code.
-
CC -fast myprog.C -o myprog
- Generate optimized code on a Linux machine.
-
g++ -O myprog.C -o myprog
- Compile myprog.C when it contains Xlib graphics routines.
-
g++ myprog.C -o myprog -lX11
- Compile a C program that uses math functions such as "sqrt".
-
gcc myprog.C -o myprog -lm
- Compile a C program with the "electric fence" library. This library, available on all the Linux machines, causes many incorrectly written programs to crash as soon as an error occurs. It is useful for debugging as the error location can be quickly determined using gdb. However, it should only be used for debugging as the executable myprog will be much slower and use much more memory than usual.
-
gcc -g myprog.C -o myprog -lefence
Example 2: Compiling a program with multiple source files
If the source code is in several files, say "file1.C" and "file2.C", then they can be compiled into an executable program named "myprog" using the following command:g++ file1.C file2.C -o myprogThe same result can be achieved using the following three commands:
g++ -c file1.C g++ -c file2.C g++ file1.o file2.o -o myprogThe advantage of the second method is that it compiles each of the source files separately. If, for instance, the above commands were used to create "myprog", and "file1.C" was subsequently modified, then the following commands would correctly update "myprog".
g++ -c file1.C g++ file1.o file2.o -o myprogNote that file2.C does not need to be recompiled, so the time required to rebuild myprog is shorter than if the first method for compiling myprog were used. When there are numerous source file, and a change is only made to one of them, the time savings can be significant. This process, though somewhat complicated, is generally handled automatically by a makefile.
FTDI lib installation guide
Code
clear.sh
dmx512.c
http://www.info.kmtronic.com/software/Raspberry_PI/DMX512.zip
.....
How to connect DS18B20 to RaspberryPI GPIO
How to view what is the ID of the Device?
How to test DS18B20
cat /sys/bus/w1/devices/28-000004d13e6d/w1_slave
t=26500 = 26.5 C
PHP Script
Download PHP Script - DOWNLOAD