Preface About SunFounder SunFounder is a technology company focused on Raspberry Pi and Arduino open source community development. Committed to the promotion of open source culture, we strive to bring the fun of electronics making to people all around the world and enable everyone to be a maker. Our products include learning kits, development boards, robots, sensor modules and development tools. In addition to high quality products, SunFounder also offers video tutorials to help your own project.
Contents Components List.............................................................................................................................................. 1 Get Started........................................................................................................................................................ 7 Preparation....................................................................................................................................................
Components List No Name Quantity 1 RGB LED 1 2 Pin Header 40 3 555 Timer IC 1 4 Optocoupler (4N35) 2 5 Shift Register (74HC595) 2 6 L293D 1 Component 1
7 Accelerometer ADXL345 1 8 Rotary Encoder 1 9 Button 5 10 Resistor (220Ω) 8 (red, red, black, black, brown) 11 Resistor (1kΩ) 8 (brown, black, black, brown, brown) 12 Resistor (10kΩ) 4 (brown, black, black, red, brown) 13 Resistor (100kΩ) 4 (brown, black, black, orange, brown) 14 Resistor (1MΩ) 1 (brown, black, green, gold) 15 Resistor (5.
16 Switch 1 17 Potentiometer (50k) 1 18 Power Supply Module 1 19 LCD1602 1 20 Dot Matrix Display (8*8) 1 21 7-Segment Display 2 3
22 DC Motor 1 23 LED (red) 16 24 LED (white) 2 25 LED (green) 2 26 LED (yellow) 2 27 NPN Transistor (S8050) 2 4
28 29 30 PNP Transistor (S8550) Capacitor Ceramic 100nF Capacitor Ceramic 10nF 2 4 4 31 Diode Rectifier 4 32 Breadboard 1 5
33 34 Male-to-Male Jumper Wire Female-to-Male Dupont Wire 65 20 35 Active Buzzer 1 36 Fan 1 Notes: After unpacking, please check that the number of components is correct and that all components are in good condition.
Get Started Preparation 1. Prepare a MicroSD/TF car of no less than 8GB, a 5V 2A DC power adapter with a MicroUSB port, and a network cable (to connect your router and Raspberry Pi, or plug in the USB WiFi adapter directly if you have one). 2. Download the image for the Raspbian system onto your computer. Refer to instructions through DOWNLOADS->RASPBIAN on the official website raspberrypi.org: https://www.raspberrypi.org/documentation/installation/installing-images/README.
Note: The screen monitor shown above is the 7inch one we're using, available on our website www.sunfounder.com and our Amazon store. Check out now and use your Raspberry Pi in a most convenient way. 3. Now click the icon of Terminal on the screen.
4. Then a terminal will pop up as follows: For Windows Users If your computer runs on Windows, you may go to the Raspberry Pi in a remote way, like PuTTY. 1. Similarly plug the TF card into the Raspberry Pi (RPi), power the RPi with a 5V 2A DC power and connect the LAN of the router with the network port of the RPi. So now the Raspberry Pi is ready. 2. Then you need to know the IP address of the RPi. You can find it on the settings interface of your router.
4. Enter the IP address of the RPi you just got in the textbox under Host Name (or IP address) and 22 under Port (by default it is 22) 5. Click Open. Note that when you first log in to the Raspberry Pi with the IP address, you'll be prompted with a security reminder. Just click Yes. When the PuTTY window prompts login as: type in the user name of the RPi: pi, and password: raspberry (the default one, if you haven't changed it).
Pay attention: when you're typing the password in, the window shows nothing just null, but you're in fact is typing things in. So just focus on typing it right and press Enter. After you log in the RPi successfully, the window will display as follows. For Linux or Mac OS X Users Linux and Mac OS X users can only log in the Raspberry Pi via ssh. Go to Applications->Utilities, find the Terminal and open it.
Type in ssh pi@ip_address – ssh is the tool for remote logging, pi, the user name, and ip_address as the name suggests, your RPi's IP address. For example: ssh pi@192.168.0.1 Press Enter to confirm. If you get a prompt that no ssh is found, you need to install an ssh tool like Ubuntu and Debian by yourself: sudo apt-get install ssh For other Linux platforms, please contact your supplier. Now, no matter what method you take, you can get in the client and log into the Raspberry Pi.
Introduction to Raspberry Pi Before starting to learn the commands, you first need to know more about the pins of the RPi, which is key to the subsequent study. There are several models of Raspberry Pi. To know some information about them, both the Raspberry Pi Model B (R1) and Model B have 26 pins, when Model B+, 2 Model B, and 3 Model B have 40.
Raspberry Pi Pin Number Introduction For you to better understand, we draw the pin mapping tables below for the 26-pin/40-pin GPIO Extension Board. The pin mapping table for 26-pin GPIO Extension Board. Its 5V0 and 3V3 pins are not shown.
The middle column is the pin names marked on the extension board, and the corresponding pin names are provided on its left and right for numbering by BCM and by wiringPi. The Name column is what the Raspberry Pi defines of the pin. "-" in two columns on the same line indicates the pin number and name is the same for the two numbering methods. Besides, in Python, pins are usually defined by the physical position on the board.
40-pin GPIO Extension Board 16
Install Libraries Similarly, go to the client and log in to the Raspberry Pi. Here we'll take the Raspberry Pi as the master. WiringPi Introduction WiringPi is a C language GPIO library applied to the Raspberry Pi platform. It complies with GUN Lv3. The functions in wiringPi are similar to those in the wiring system of Arduino. They enable the users familiar with Arduino to use wiringPi more easily. If you've installed the latest Raspbian, you can skip installing this one.
Step 3: Test whether wiringPi is installed successfully or not WiringPi includes lots of GPIO commands which enable you to control all kinds of interfaces on Raspberry Pi. You can test whether the wiringPi library is installed successfully or not by the following instructions. gpio –v If the message above appears, the wiringPi is installed successfully.
RPi.GPIO If you are a Python user, you can program GPIOs with API provided by RPi.GPIO. Introduction RPi.GPIO is a module to control Raspberry Pi GPIO channels. This package provides a class to control the GPIO on a Raspberry Pi. For examples and documents, visit http://sourceforge.net/p/raspberry-gpio-python/wiki/Home/ The Raspbian OS image of Raspberry Pi installs RPi.GPIO by default, so you can use it directly.
Download the Code We provide two methods for download: Method 1: From our website Download the source code from our website. www.sunfounder.com Click LEARN->Get Tutorials, find Super Kit V2.0 for Raspberry Pi and click to download the Super Kit for Raspberry Pi.zip file, unzip it, and then move the folder to the directory /home/pi/. This is a simple way to do it.
Click on the repository. On the page directed, click Clone or download on the right side. After download, transfer the package to /home/pi/. Now you can start the experiments.
Lesson 1 Blinking LED Introduction In this lesson, we will learn how to program Raspberry Pi to make an LED blink. You can play numerous tricks with an LED as you want. Now get to start and you will enjoy the fun of DIY at once! Components - 1 * Raspberry Pi - 1 * Breadboard - 1 * LED - 1 * Resistor (220Ω) - Jumper wires Principle Semiconductor light-emitting diode is a type of component which can turn electric energy into light energy via PN junctions.
Experimental Procedures Step 1: Build the circuit For C language users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_C_code_for_RaspberryPi/01_LED/ Step 3: Compile gcc led.c -o led -lwiringPi Step 4: Run sudo ./led For Python users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_Python_code_for_RaspberryPi/ Step 3: Run sudo python 01_led.py Now, you should see the LED blink.
Further Exploration If you want the LED to speed up the blinking, just change the delay time. For example, change the time to delay (200) in the program, recompile and run, and then you will see the LED blink faster. Summary Raspberry Pi packages many low-level detail designs, which enable you to explore your own apps more conveniently. Maybe that is the charm of Raspberry Pi. Now you have already learnt how to use the Raspberry Pi GPIO to blink an LED. Keep moving to the next contents.
Lesson 2 Controlling an LED by a Button Introduction In this lesson, we will learn how to turn an LED on or off by a button. Components - 1 * Raspberry Pi - 1 * Breadboard - 1 * LED - 1 * Button - 1 * Resistor (220Ω) - Jumper wires Principle Button Buttons are a common component used to control electronic devices. They are usually used as switches to connect or disconnect circuits.
Generally, the button can be connected directly to the LED in a circuit to turn on or off the LED, which is comparatively simple. However, sometimes the LED will brighten automatically without any button pressed, which is caused by various kinds of external interference. In order to avoid this interference, a pull-down resistor is used – usually connect a 1K–10KΩ resistor between the button and GND. It can be connected to GND to consume the interference when the button is off.
Experimental Procedures Step 1: Build the circuit For C language users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_C_code_for_RaspberryPi/02_BtnAndLed/ Step 3: Compile gcc BtnAndLed.c -o BtnAndLed -lwiringPi Step 4: Run sudo ./BtnAndLed For Python users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_Python_code_for_RaspberryPi/ Step 3: Run sudo python 02_btnAndLed.
Now, press the button, and the LED will light up; press the button again, and the LED will go out. At the same time, the state of the LE D will be printed on the screen. Summary Through this experiment, you have learnt how to control the GPIOs of the Raspberry Pi by programming.
Lesson 3 Flowing LED Lights Introduction In this lesson, we will learn how to make eight LEDs blink in various effects as you want based on Raspberry Pi. Components - 1 * Raspberry Pi - 1 * Breadboard - 8 * LED - 8 * Resistor (220Ω) - Jumper wires Principle Set GPIO0-GPIO7 to low level in turn by programming, and then LED0-LED7 will light up in turn. You can make eight LEDs blink in different effects by controlling their delay time and the order of lighting up.
For C language users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_C_code_for_RaspberryPi/03_8Led/ Step 3: Compile gcc 8Led.c -o 8Led -lwiringPi Step 4: Run sudo ./8Led For Python users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_Python_code_for_RaspberryPi/ Step 3: Run sudo python 03_8Led.
Then you will see eight LEDs brighten and dim left to right and right to left circularly, just like flowing water. Further Exploration You can write the blinking effects of LEDs in an array. If you want to use one of these effects, you can call it in the main() function directly.
Lesson 4 Breathing LED Introduction In this lesson, we will try something interesting – gradually increase and decrease the luminance of an LED with PWM, just like breathing. So we give it a magical name Breathing LED. Components - 1 * Raspberry Pi - 1 * Breadboard - 1 * LED - 1 * Resistor (220Ω) - Jumper wires Principle PWM Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means. Digital control is used to create a square wave, a signal switched between on and off.
In this experiment, we use this technology to make the LED brighten and dim slowly so it looks like our breath.
For C language users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_C_code_for_RaspberryPi/04_PwmLed Step 3: Compile gcc PwmLed.c -o PwmLed -lwiringPi Step 4: Run sudo ./PwmLed For Python users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_Python_code_for_RaspberryPi/ Step 3: Run sudo python 04_pwmLed.py Now you will see the gradual change of the LED luminance, between bright and dim.
Lesson 5 RGB LED Introduction Previously we've used the PWM technology to control an LED brighten and dim. In this lesson, we will use it to control an RGB LED to flash various kinds of colors. Components - 1 * Raspberry Pi - 1 * Breadboard - 1 * RGB LED - 3 * Resistor (220Ω) - Several jumper wires Principle RGB RGB LEDs emit light in various colors. RGB stands for the red, green, and blue color channels and is an industry color standard.
Experimental Procedures Step 1: Build the circuit For C language users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_C_code_for_RaspberryPi/05_RGB/ Step 3: Compile gcc rgb.c -o rgb –lwiringPi -lpthread Step 4: Run sudo ./rgb For Python users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_Python_code_for_RaspberryPi/ Step 3: Run sudo python 05_rgb.
Here you should see the RGB LED flash different colors in turn. Further Exploration You can modify the parameters of the function ledColorSet( ) by yourself, and then compile and run the code to see the color changes of the RGB LED. Experimental Summary In this experiment, you have learnt how to control RGB LEDs with the softPwm of Raspberry Pi in this experiment. Try to apply the softPwm to DC motor speed regulation.
Lesson 6 Buzzer Introduction In this lesson, we will learn how to drive an active buzzer to beep with a PNP transistor.
In this experiment, an active buzzer is used. When the GPIO of Raspberry Pi output is supplied with low level (0V) by programming, the transistor will conduct because of current saturation and the buzzer will make sounds. But when high level is supplied to the IO of Raspberry Pi, the transistor will be cut off and the buzzer will not make sounds.
Step 3: Compile gcc beep.c -o beep -lwiringPi Step 4: Run sudo ./beep For Python users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_Python_code_for_RaspberryPi/ Step 3: Run sudo python 06_beep.py Now, you should hear the buzzer make sounds. Further Exploration If you have a passive buzzer in hand, you can replace the active buzzer with it. Now you can make a buzzer sound like “do re mi fa so la si do” with just some basic knowledge of programming.
Lesson 7 How to Drive a DC Motor Introduction In this lesson, we will learn to how to use L293D to drive a DC motor and make it rotate clockwise and counterclockwise. Components - 1 * Raspberry Pi - 1 * Breadboard - 1 * L293D - 1 * DC motor - 1 * Power Module - Jumper wires Principle L293D This is a very practical chip that can independently control two DC motors.
In this experiment, connect two IOs of the Raspberry Pi to two optocouplers which isolate the power supply to protect your Raspberry Pi from interference and crashing when the motor works. Connect the output port of the optocoupler to the driver IC (L293D) of the motor. When one of the two IOs of the Raspberry Pi is at high level and the other is low, the motor will rotate clockwise or counterclockwise. By adjusting the pulse width, you can realize DC motor speed regulation as well.
Experimental Procedures Step 1: Build the circuit For C language users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_C_code_for_RaspberryPi/07_Motor/ Step 3: Compile gcc motor.c -o motor -lwiringPi Step 4: Run sudo ./motor For Python users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_Python_code_for_RaspberryPi/ Step 3: Run sudo python 07_motor.
Now, you should see the motor blade rotating. Further Exploration You can use buttons to control the clockwise and counterclockwise rotation of the motor blade based on the previous lessons. Also you can apply the PWM technology to control the rotation. Summary Through this lesson, you have learnt the relative principle and driving mode of DC motors, as well as how to drive a motor by Raspberry Pi.
Lesson 8 Rotary Encoder Introduction A rotary encoder is a type of electro-mechanical device that converts the angular position or motion of a shaft or axle to an analog or digital code. In this lesson, we will learn how to use this device. Components - 1 * Raspberry Pi - 1 * Breadboard - 1 * Rotary Encoder Module - Jumper wires Principle A rotary encoder is an electronic switch with a set of regular pulses with strictly timing sequence.
Pin 2: generally connected to ground. Pin 1 & 3: first connected to a pull-up resistor and then to a microprocessor (in this experiment, to GPIO0 and GPIO1 of Raspberry Pi); when you spin the knob of the encoder clockwise and counterclockwise, there will be pulse outputs in pin 1 and pin 3. If both GPIO0 and GPIO1 are at high level, the switch rotates clockwise; if GPIO0 is at high level but GPIO1 is low, the switch rotates counterclockwise.
For C language users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_C_code_for_RaspberryPi/08_RotaryEncoder/ Step 3: Compile gcc rotaryEncoder.c -o rotaryEncoder -lwiringPi Step 4: Run sudo ./rotaryEncoder For Python users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_Python_code_for_RaspberryPi/ Step 3: Run sudo python 08_rotaryEncoder.py Now, gently rotate the encoder to change the value of the variable in the above program, and you will see the value printed on the screen.
Lesson 9 555 Timer Introduction The NE555 Timer, a mixed circuit composed of analog and digital circuits, integrates analog and logical functions into an independent IC, thus tremendously expanding the applications of analog integrated circuits. It is widely used in various timers, pulse generators, and oscillators. In this lesson, we will learn how to use the 555 timer.
Pin 4 (RESET): outputting low level when supplied a low one Pin 5 (CONTROL VOLTAGE): changing the upper and lower level trigger values Pin 6 (THRESHOLD): the input of the upper comparator Pin 7 (DISCHARGE): having two states of suspension and ground connection also decided by the input, and the output of the internal discharge tube Pin 8 (VCC): the power supply The 555 timer can work under three modes. In this experiment, the astable mode is used to generate square waves.
Attach the output pin (e.g. pin 3) of the 555 timer to GPIO0 of the Raspberry Pi, configure GPIO0 as the mode of the rising edge interrupt by programming, and then detect the square wave pulses generated by the 555 timer with interrupt. The work of Interrupt Service Routine (ISR) is to add 1 to a variable.
Experimental Procedures Step1: Build the circuit For C language users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_C_code_for_RaspberryPi/09_Timer555/ Step 3: Compile gcc timer555.c -o timer555 -lwiringPi Step 4: Run sudo ./timer555 For Python users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_Python_code_for_RaspberryPi/ Step 3: Run sudo python 09_timer555.
Now, you should see data printed on the display, which are square waves generated by the 555 timer. The program counts pulses by interrupt as we have learned previously. Further Exploration The above 555 timer circuit outputs square waves with a constant frequency and duty cycle. You can simply change this circuit to adjust the frequency and duty cycle. Thus you can make breathing LED described in Lesson 4 without Raspberry Pi.
Lesson 10 Driving LEDs by 74HC595 Introduction In this lesson, we will learn how to use 74HC595 to make eight LEDs blink regularly. Components - 1 * Raspberry Pi - 1 * Breadboard - 1 * 74HC595 - 8 * LED - 8 * Resistor (220Ω) - Jumper wires Principle 74HC595 The 74HC595 consists of an 8−bit shift register and a storage register with three−state parallel outputs. It converts serial input into parallel output so that you can save IO ports of an MCU.
Q7’: Series output pin, connected to DS of another 74HC595 to connect multiple 74HC595s in series MR: Reset pin, active at low level; here it is directly connected to 5V. SH_CP: Time sequence input of shift register. On the rising edge, the data in shift register moves successively one bit, i.e. data in Q1 moves to Q2, and so forth. While on the falling edge, the data in shift register remain unchanged. ST_CP: Time sequence input of storage register.
Experimental Procedures Step 1: Build the circuit For C language users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_C_code_for_RaspberryPi/10_74HC595_LED/ Step 3: Compile gcc 74HC595_LED.c -o 74HC595_LED -lwiringPi Step 4: Run sudo ./74HC595_LED For Python users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_Python_code_for_RaspberryPi/ Step 3: Run sudo python 10_74HC595_LED.
Here you should see eight LEDs blink regularly. Further Exploration In this experiment, three Raspberry Pi GPIOs are used to separately control 8 LEDs based on 74HC595. In fact, 74HC595 has another powerful function – cascade. With cascade, you can use a microprocessor to control more peripherals. We'll check more details later.
Lesson 11 Driving 7-Segment Display by 74HC595 Introduction Since we've got some knowledge of the 74HC595 in the previous lesson, now let's try to use it and drive a 7-segment display to show a figure from 0 to 9. Components - 1 * Raspberry Pi - 1 * Breadboard - 1 * 74HC595 - 1 * 7-segment display - 1 * Resistor (1KΩ) - Jumper wires Principle 7-Segment Display A 7-segment display is an 8-shaped component which packages 7 LEDs.
Common Cathode (CC) and Common Anode (CA). As the name suggests, a CC display has all the cathodes of the 7 LEDs connected when a CA display has all the anodes of the 7 segments connected. Common Cathode 7-Segment Display In a common cathode display, the cathodes of all the LED segments are connected to the logic "0" or ground. Then an individual segment (a-g) is energized by a "HIGH", or logic "1" signal via a current limiting resistor to forward bias the anode of the segment.
In this experiment, a common cathode 7-segment display is use. It should be connected to ground. When the anode of an LED in a certain segment is at high level, the corresponding segment will light up; when it is at low, the segment will stay dim. Connect pin ST_CP of 74HC595 to Raspberry Pi GPIO1, SH_CP to GPIO2, DS to GPIO0, parallel output ports to 8 segments of the LED segment display.
For C language users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_C_code_for_RaspberryPi/11_Segment/ Step 3: Compile gcc segment1.c -o segment1 -lwiringPi Step 4: Run sudo ./segment1 For Python users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_Python_code_for_RaspberryPi/ Step 3: Run sudo python 11_segment.py You should see the 7-segment display from 0 to 9, and A to F.
58
Further Exploration You can slightly modify the hardware and software based on this experiment to make a dice. For hardware, add a button to the original board. Build the circuit: Next, go to 11_Segment, and compile dice.c gcc dice.c –o dice –lwiringPi Run sudo ./dice Now you should see a number flashing between 0 and 6 quickly on the segment display.
Summary Through this lesson, you may have mastered the basic principle and programming for 7segment display based on Raspberry Pi, as well as more knowledge about using 74HC595.
Lesson 12 Driving Dot-Matrix by 74HC595 Introduction With low-voltage scanning, dot matrix LED displays have advantages such as power saving, long service life, low cost, high brightness, a wide angle of view, long visual range, waterproofness, and so on. They can meet the needs of different applications and thus have a broad development prospect. In this lesson, we will learn how to use 74HC595 to drive an LED dot-matrix.
Pin definition: Define the row and column numbering at first (only for the dot matrix whose model number ends with BS) Pin numbering corresponding to the above rows and columns: COL 1 2 3 4 5 6 7 8 Pin No. 13 3 4 10 6 11 15 16 ROW 1 2 3 4 5 6 7 8 Pin No. 9 14 8 12 1 7 2 5 The 8*8 dot matrix is made up of sixty-four LEDs and each LED is placed at the cross point of a row and a column.
The schematic diagram Experimental Procedures Step 1: Build the circuit 63
For C language users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_C_code_for_RaspberryPi/12_DotMatrix/ Step 3: Compile gcc dotMatrix.c -o dotMatrix -lwiringPi Step 4: Run sudo ./dotMatrix For Python users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_Python_code_for_RaspberryPi/ Step 3: Run sudo python 12_DotMatrix.py You should see LEDs light up as you control.
Lesson 13 LCD1602 Introduction In this lesson, we will learn how to use LCD1602 to display characters and strings. Components - 1 * Raspberry Pi - 1 * Breadboard - 1 * LCD1602 - 1 * Potentiometer - Jumper wires Principle LCD1602, or character type LCD1602, is a dot matrix LCD module specially used to display letters, figures, symbols, and so on. It consists of many 16*2 dot matrixes, and each one is composed of 5*7 or 5*11 character bit. Each character bit can display one character.
Pin 6 (E): An enable pin that, when low-level energy is supplied, causes the LCD module to execute relevant instructions Pin 7 (D0-D7): pins that read and write data A and K: controlling LCD backlight LCD1602 has two operation modes: 4-bit and 8-bit. When the IOs of microprocessor (MCU) are insufficient, you can choose 4-bit mode, under which only pins D4~D7 are used. After connecting the circuit, you can operate LCD1602 by Raspberry Pi.
For C language users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_C_code_for_RaspberryPi/13_LCD1602/ Step 3: Compile gcc lcd1602_2.c -o lcd1602_2 -lwiringPiDev -lwiringPi Step 4: Run sudo ./lcd1602_2 For Python users Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_Python_code_for_RaspberryPi/ Step 3: Run sudo python 13_lcd1602.py You should see two lines of characters displayed on the LCD1602: "SUNFOUNDER" and "Hello World ! :)".
Lesson 14 ADXL345 Introduction In this lesson, we will learn how to use the acceleration sensor ADXL345. Components - 1 * Raspberry Pi - 1 * Breadboard - 1 * ADXL345 module - Jumper wires Principle ADXL345 The ADXL345 is a small, thin, low power, 3-axis accelerometer with high resolution (13-bit) measurement at up to ±16 g. Digital output data is formatted as 16-bit two’s complement and is accessible through either an SPI (3- or 4-wire) or I2C digital interface.
The I2C interface is used in the following program. Before running the program, please make sure the I2C driver module of Raspberry Pi has loaded normally. For C language users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_C_code_for_RaspberryPi/14_ADXL345/ Step 3: Compile gcc adxl345.c -o adxl345 -lwiringPi Step 4: Run sudo ./adxl345 For Python users: Step 2: Change directory cd /home/pi/Sunfounder_SuperKit_Python_code_for_RaspberryPi/ Step 3: Run sudo python Adafruit_ADXL345.
Now, rotate the acceleration sensor, and you should see the values printed on the screen change.
Advanced Lesson – Controlling an LED Based on Web Introduction The reason why Raspberry Pi is so amazing is the networking function and support by numerous open source web applications. With it, your own Internet of Things system can be constructed conveniently. In this lesson, we will learn how to control an LED based on the web with Raspberry Pi. You can use your mobile phone, tablet PC or computer to control the LED too, as long as it is in the same Local Area Network (LAN) with your Raspberry Pi.
2. Install WebIOPi wget http://webiopi.googlecode.com/files/WebIOPi-0.5.3.tar.gz tar xvzf WebIOPi-0.5.3.tar.gz cd WebIOPi-0.5.3 sudo ./setup.sh 3. Set or modify the password of WebIOPi sudo webiopi-passwd Username: webiopi The default password is raspberry. 4. Start WebIOPi sudo python -m webiopi 8000 You can change the port by yourself. The default port is 8000. 5. Run WebIOPi in the back-end system, or it will be killed when you press Ctrl+C sudo /etc/init.d/webiopi start and sudo /etc/init.
6. Set WebIOPi to start with the system sudo update-rc.d webiopi defaults 7. Open the interface of IP address access management with a browser http://192.168.1.106:8000/webiopi/ Control method 1) Click the outside IN/OUT to switch between the input and output modes of GPIOs 2) In the output mode, click the inside figures to switch between high and low outputs.
Copyright Notice All contents including but not limited to texts, images, and code in this manual are owned by the SunFounder Company. You should only use it for personal study, investigation, enjoyment, or other non-commercial or nonprofit purposes, under the related regulations and copyrights laws, without infringing the legal rights of the author and relevant right holders.