ADEEPT Super Starter User manual


Component List
1x DC Motor
1x Servo
1x L9110 motor driver
1x LCD1602
1x ADC0832
2x 74HC595
1x Dot-matrix Display
1x 7-Segment Display
1x Light Sensor (Photoresistor)
1x 40 pin GPIO Extension Board
1x 40 pin GPIO Cable
1x Breadboard Power Supply Module
1x Active buzzer
1x Tilt Switch
2x Switch
1x RGB LED
8x Red LED
4x Green LED
4x Yellow LED
4x Blue LED
16x Resistor(220Ω)
10x Resistor(1kΩ)
5x Resistor(10kΩ)
5x Capacitor (104)
2x Capacitor (10uF)
4x Button (large)
8x Button (small)
1x Button cap (red)
1x Button cap (white)
2x Button cap (blue)
2x NPN Transistor (8050)
2x PNP Transistor (8550)
2x Potentiometer (10KΩ)
1x Breadboard
40x Male to Male Jumper Wires
20x Male to Female Jumper Wires
1x Header (40pin)
1x Band Resistor Card
1x Project Box

Preface
About this kit
This is an entry-level learning kit for Raspberry Pi. Some common electronic
components and sensors are included. Through the learning, you will get a
better understanding of Raspberry Pi, and be able to make fascinating works
based on Raspberry Pi.
About Adeept
Adeept is a technical service team of open source software and hardware.
Dedicated to applying the Internet and the latest industrial technology in open
source area, we strive to provide best hardware support and software service
for general makers and electronic enthusiasts around the world. We aim to
create infinite possibilities with sharing. No matter what field you are in, we
can lead you into the electronic world and bring your ideas into reality.
If you have any problems for learning, please contact us at support@adeept.com.
We will do our best to help you solve the problem.

Content
About the Raspberry Pi................................................................................................................- 1 -
Raspberry Pi Pin Numbering Introduction...................................................................................- 2 -
Raspberry Pi GPIO Library Introduction.....................................................................................- 4 -
How to use the wiringPi and the RPi.GPIO.................................................................................- 6 -
Lesson 1 Blinking LED..............................................................................................................- 10 -
Lesson 2 Buzzer.........................................................................................................................- 16 -
Lesson 3 Controlling an LED with a button ..............................................................................- 20 -
Lesson 4 Tilt Switch...................................................................................................................- 25 -
Lesson 5 LED Flowing Lights...................................................................................................- 28 -
Lesson 6 Breathing LED............................................................................................................- 31 -
Lesson 7 Controlling a RGB LED with PWM...........................................................................- 35 -
Lesson 8 7-segment display.......................................................................................................- 38 -
Lesson 9 Dot-matrix display......................................................................................................- 42 -
Lesson 10 LCD1602 ..................................................................................................................- 46 -
Lesson 11 Photoresistor .............................................................................................................- 50 -
Lesson 12 Controlling an LED through LAN............................................................................- 53 -
Lesson 13 How to control a servo..............................................................................................- 57 -
Lesson 14 A Simple Voltmeter................................................................................................... - 60 -
Lesson 15 DC motor..................................................................................................................- 63 -

- 1 -
About the Raspberry Pi
The Raspberry Pi is a low cost, credit-card sized computer that plugs into a
computer monitor or TV, and uses a standard keyboard and mouse. It is a
capable little device that enables people of all ages to explore computing, and
to learn how to program in languages like Scratch and Python. It’s capable of
doing everything you’d expect a desktop computer to do, from browsing the
internet and playing high-definition video, to making spreadsheets,
word-processing, and playing games.
What’s more, the Raspberry Pi has the ability to interact with the outside world,
and has been used in a wide array of digital maker projects, from music
machines and parent detectors to weather stations and tweeting birdhouses
with infra-red cameras. We want to see the Raspberry Pi being used by kids all
over the world to learn to program and understand how computers work.
Link:
https://www.raspberrypi.org/help/what-is-a-raspberry-pi/

- 2 -
Raspberry Pi Pin Numbering Introduction
There are three methods for numbering Raspberry Pi’s GPIO:
1. Numbering according to the physical location of the pins, from left to right,
top to bottom, the left is odd, the right is even.
2. Numbering according the GPIO registers of BCM2835/2836 SOC.
3. Numbering according the GPIO library wiringPi.

- 3 -

- 4 -
Raspberry Pi GPIO Library Introduction
Currently, there are two major GPIO libraries for Raspberry Pi, RPi.GPIO and
wiringPi.
RPi.GPIO:
RPi.GPIO is a python module to control Raspberry Pi GPIO channels. For more
information about RPi.GPIO, please visit:
https://pypi.python.org/pypi/RPi.GPIO/
For examples and documentation, please visit:
http://sourceforge.net/p/raspberry-gpio-python/wiki/Home/
The RPi.GPIO module is pre-installed in the official Raspbian operating system,
you can use it directly.
wiringPi:
The wiringPi is a GPIO access library written in C for the BCM2835/6 SOC used
in the Raspberry Pi. It’s released under the GNU LGPLv3 license and is usable
from C and C++ and many other languages with suitable wrappers. It’s
designed to be familiar to people who have used the Arduino “wiring” system.
For more information about wiringPi, please visit : http://wiringpi.com/
Install wiringPi:
Step 1 : Get the source code
$ git clone git://git.drogon.net/wiringPi
Step 2 : Compile and install
$ cd wiringPi
$ git pull origin
$ sudo ./build
Press Enter, the script “build” will automatically compile wiringPi source code
and then install it to the Raspberry Pi.

- 5 -
Next, verify whether the wiringPi is installed successfully or not:
wiringPi includes a command-line utility gpio which can be used to program
and setup the GPIO pins. You can use this to read and write the pins and even
use it to control them from shell scripts.
You can verify whether the wiringPi is installed successfully or not by the
following commands:
$ sudo gpio -v
$ sudo gpio readall
If you can see the information shown above, it indicates that the wiringPi has
been installed successfully.

- 6 -
How to use the wiringPi and the RPi.GPIO
Here we take a blinking LED for example to illustrate how to use the wiringPi C
library and the RPi.GPIO Python module.
Step 1 : Build the circuit according to the following schematic diagram
Note : Resistance=220Ω
For Python user:
Step 2 : Create a file named led.py
$ sudo touch led.py
Step 3 : Open the file led.py with vim or nano
$ sudo vim led.py
Write down the following source code, then save and exit.

- 7 -
Step 4 : Run the program
$ sudo python led.py
Press Enter, you should see that the LED is blinking. Press ’Ctrl+C’, the program
execution will be terminated.
For C language user:
Step 2 : Create a file named led.c
$ sudo touch led.c
Step 3 : Open the file led.c with vim or nano

- 8 -
$ sudo vim led.c
Write down the following source code, then save and exit.
Step 4 : Compile the code
$ sudo gcc led.c -lwiringPi
After executing this command, you'll find a file named a.out appear in the
current directory. It is an executable program.
Step 5 : Run the program
$ sudo ./a.out
Press Enter, you should see that the LED is blinking. Press ’Ctrl+C’, the program
execution will be terminated.

- 9 -
Resources :
http://sourceforge.net/p/raspberry-gpio-python/wiki/Examples/
http://wiringpi.com/reference/
NOTE:
Before learning the next courses, please copy the source code we provided to
your Raspberry Pi's /home/ directory, or you can get the source code directly
from our github repository :
C Language Source Code :
$ git clone https://github.com/adeept/Adeept_Starter_Kit_C_Code_for_RPi.git
Python Source Code :
$ git clone https://github.com/adeept/Adeept_Starter_Kit_Python_Code_for_RPi.git

- 10 -
Lesson 1 Blinking LED
Overview
In this tutorial, we will start the journey of learning Raspberry Pi. In the first lesson, we
will learn how to control an LED.
Requirement
- 1* Raspberry Pi
- 1* 220ΩResistor
- 1* LED
- 1* Breadboard
- 2* Jumper Wires
Principle
In this lesson, we will program the Raspberry Pi to output high(+3.3V) and low
level(0V), and then make an LED which is connected to the Raspberry Pi GPIO flicker
with a certain frequency.
1. What is LED ?
The LED is the abbreviation of light emitting diode. It is usually made of gallium
arsenide, gallium phosphide semiconductor materials. The LED has two electrodes, a
positive electrode and a negative electrode, it will light only when a forward current
passes, and it can be red, blue, green or yellow light, etc. The color of light depends on
the materials it was made.
In general, the drive current for LED is 5-20mA. Therefore, in reality it usually needs an
extra resistor for current limitation so as to protect the LED.
2. What is the resistor ?
The main function of the resistor is to limit current. In the circuit, the character ‘R’
represents resistor, and the unit of resistor is ohm(Ω).
The band resistor is used in this experiment. A band resistor is one whose surface is
coated with some particular color through which the resistance can be identified
directly.
There are two methods for connecting an LED with Raspberry Pi GPIO:
①

- 11 -
As shown in the schematic diagram above, the anode of LED is connected to
VCC(+3.3V), and the cathode of LED is connected to the Raspberry Pi GPIO. When the
GPIO output low level, the LED is on; when the GPIO output high level, the LED is off.
②
As shown in the schematic diagram above, the anode of LED is connected to
Raspberry Pi GPIO via a resistor, and the cathode of LED is connected to the ground
(GND). When the GPIO output high level, the LED is on; when the GPIO output low
level, the LED is off.
The size of the current-limiting resistor is calculated as follows : 5~20mA current is
required to make an LED on, and the output voltage of the Raspberry Pi GPIO is 3.3V,
so we can get the resistance:
R = U / I = 3.3V / (5~20mA) = 165Ω~660Ω
In this experiment, we choose a 220ohm resistor.
The experiment is based on method ①, we select pin 11 of Raspberry Pi to control an
LED. When the pin 11 of Raspberry Pi is programmed to output low level, then the LED
will be lit, next delay for the amount of time, and then programmed the pin 11 to high
level to make the LED off. Continue to perform the above process, you can get a
blinking LED.
3. Key functions
C language user:
●int wiringPiSetup (void)
The function must be called at the start of your program or your program will fail to
work correctly. You may experience symptoms from it simply not working to segfaults
and timing issues.
Note
: This function needs to be called with root privileges.
●void pinMode (int pin, int mode)
This sets the mode of a pin to either INPUT, OUTPUT, PWM_OUTPUT or GPIO_CLOCK.
Note that only wiringPi pin 1 (BCM_GPIO 18) supports PWM output and only wiringPi
pin 7 (BCM_GPIO 4) supports CLOCK output modes.
This function has no effect when in Sys mode. If you need to change the pin mode,
then you can do it with the gpio program in a script before you start your program.
●void digitalWrite (int pin, int value)

- 12 -
Writes the value HIGH or LOW (1 or 0) to the given pin which must have been
previously set as an output.
WiringPi
treats any non-zero number as HIGH, however 0
is the only representation of LOW.
●void delay (unsigned int howLong)
This causes program execution to pause for at least howLong milliseconds. Due to the
multi-tasking nature of Linux it could be longer. Note that the maximum delay is an
unsigned 32-bit integer or approximately 49 days.
Python user:
●GPIO.setmode(GPIO.BOARD)
There are two ways of numbering the IO pins on a Raspberry Pi within RPi.GPIO. The
first is using the BOARD numbering system. This refers to the pin numbers on the P1
header of the Raspberry Pi board. The advantage of using this numbering system is
that your hardware will always work, regardless of the board revision of the RPi. You
will not need to rewire your connector or change your code.
The second numbering system is the BCM(GPIO.BCM) numbers. This is a lower level
way of working - it refers to the channel numbers on the Broadcom SOC. You have to
always work with a diagram of which channel number goes to which pin on the RPi
board. Your script could break between revisions of Raspberry Pi boards.
●GPIO.setup(channel, mode)
This sets every channel you are using as an input(GPIO.IN) or an output(GPIO.OUT).
●GPIO.output(channel, state)
This sets the output state of a GPIO pin. Where channel is the channel number based
on the numbering system you have specified (BOARD or BCM). State can be 0 /
GPIO.LOW / False or 1 / GPIO.HIGH / True.
●GPIO.cleanup( )
At the end any program, it is good practice to clean up any resources you might have
used. This is no different with RPi.GPIO. By returning all channels you have used back
to inputs with no pull up/down, you can avoid accidental damage to your RPi by
shorting out the pins. Note that this will only clean up GPIO channels that your script
has used. Note that GPIO.cleanup() also clears the pin numbering system in use.
Procedures
1. Build the circuit

- 13 -
2. Program
C user:
2.1 Edit and save the code with vim or nano.
(Code path: /home/Adeept_Starter_Kit_C_Code_for_RPi/01_blinkingLed/blinkingLed.c)
#include <wiringPi.h>
#include <stdio.h>
#define LedPin 0
int main(void)
{
if(wiringPiSetup() == -1){ //when initialize wiringPi failed, print message to screen
printf("setup wiringPi failed !\n");
return -1;
}
pinMode(LedPin,OUTPUT);
while(1){
digitalWrite(LedPin,LOW); //led on
printf("led on...\n");
delay(500);
digitalWrite(LedPin,HIGH); //led off
printf("...led off\n");
delay(500);
}
return 0;
}
2.2 Compile the program
$ gcc blinkingLed.c -o led -lwiringPi

- 14 -
Note
: The parameter ‘-o’ is to specify a file name for the compiled executable
program. If you do not use this parameter, the default file name is a.out.
2.3 Run the program
$ sudo ./led
Python user:
2.1 Edit and save the code with vim or nano.
(Code path: /home/Adeept_Starter_Kit_Python_Code_for_RPi/01_blinkingLed_1.py)
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
LedPin =11 # pin11
def setup():
GPIO.setmode(GPIO.BOARD)# Numbers GPIOs by physical location
GPIO.setup(LedPin,GPIO.OUT)# Set LedPin's mode is output
GPIO.output(LedPin,GPIO.HIGH)# Set LedPin high(+3.3V) to off led
def loop():
while True:
print '...led on'
GPIO.output(LedPin,GPIO.LOW)# led on
time.sleep(0.5)
print 'led off...'
GPIO.output(LedPin,GPIO.HIGH)# led off
time.sleep(0.5)
def destroy():
GPIO.output(LedPin,GPIO.HIGH)# led off
GPIO.cleanup() # Release resource
if __name__ == '__main__':# Program start from here
setup()
try:
loop()
except KeyboardInterrupt:# When 'Ctrl+C' is pressed, the child program destroy() will
be executed.
destroy()
2.2 Run the program
$ sudo python 01_blinkingLed_1.py
Press Enter, and then you can see the LED is blinking.

- 15 -

- 16 -
Lesson 2 Buzzer
Overview
In this lesson, we will learn how to program the Raspberry Pi to make an active buzzer
sound.
Requirement
- 1* Raspberry Pi
- 1* Active buzzer
- 1* 1 kΩResistor
- 1* NPN Transistor (S8050)
- 1* Breadboard
- Several Jumper wires
Principle
A buzzer or beeper is an audio signaling device. As a type of electronic buzzer with
integrated structure, which use DC power supply, are widely used in computers,
printers, photocopiers, alarms, electronic toys, automotive electronic equipments,
telephones, timers and other electronic products for voice devices. Buzzers can be
categorized as active and passive buzzers (See the following pictures).
When you place the pins of buzzers upward, you can see that two buzzers are
different, the buzzer that green circuit board exposed is the passive buzzer.
In this study, the buzzer we used is active buzzer. Active buzzer will sound as long as
the power supply. We can program to make the Raspberry Pi output alternating high
and low level, so that the buzzer sounds.
A slightly larger current is needed to make a buzzer sound. However, the output
current of Raspberry Pi GPIO is weak, so we need a transistor to drive the buzzer.
The main function of transistor is blowing up the voltage or current. The transistor can
also be used to control the circuit conduction or deadline. And the transistor is divided
into two kinds, one kind is NPN, for instance, the S8050 we provided; another kind is
PNP transistor such as the S8550 we provided. The transistor we used is as shown in
Other manuals for Super Starter
2
Table of contents