SunFounder R3 User manual

SunFounder uno-and-mega-kit
www.sunfounder.com
Jan 19, 2022


CONTENTS
1 Components List 3
2 Components Introduction 9
2.1 SunFounder R3 Board .......................................... 9
2.2 SunFounder Mega Board ......................................... 11
2.3 Breadboard ................................................ 13
2.4 Jumper Wires ............................................... 14
2.5 Resistor .................................................. 15
2.6 Transistor ................................................. 18
2.7 Capacitor ................................................. 21
2.8 Diode ................................................... 23
2.9 74HC595 ................................................. 24
2.10 L293D .................................................. 25
2.11 LED ................................................... 26
2.12 RGB LED ................................................ 28
2.13 7-segment Display ............................................ 30
2.14 4-Digit 7-Segment Display ........................................ 32
2.15 LCD1602 ................................................. 33
2.16 Buzzer .................................................. 34
2.17 DC Motor ................................................. 35
2.18 Stepper Motor .............................................. 37
2.19 Servo ................................................... 39
2.20 Relay ................................................... 40
2.21 Power Supply Module .......................................... 42
2.22 Button .................................................. 43
2.23 Potentiometer ............................................... 45
2.24 Joystick Module ............................................. 46
2.25 Photoresistor ............................................... 48
2.26 Thermistor ................................................ 49
2.27 Tilt Switch ................................................ 50
2.28 IR Receiver Module ........................................... 51
2.29 Ultrasonic Module ............................................ 53
2.30 Humiture Sensor Module ........................................ 54
3 Download the Code 57
4 Install and Introduce Arduino IDE 59
4.1 Description ................................................ 59
4.2 Install Arduino IDE ........................................... 59
i

5 Add Libraries 71
5.1 What is Library? ............................................. 71
5.2 Add libraries ............................................... 71
6 For Mega2560 User 77
6.1 Lesson 1 Blinking LED ......................................... 77
6.2 Lesson 2 Flowing LED Lights ...................................... 83
6.3 Lesson 3 Controlling LED by Button .................................. 89
6.4 Lesson 4 Doorbell ............................................ 93
6.5 Lesson 5 Tilt Switch ........................................... 99
6.6 Lesson 6 Relay .............................................. 103
6.7 Lesson 7 RGB LED ........................................... 108
6.8 Lesson 8 Controlling an LED by Potentiometer ............................. 114
6.9 Lesson 9 Photo resistor .......................................... 123
6.10 Lesson 10 Servo ............................................. 128
6.11 Lesson 11 LCD1602 ........................................... 132
6.12 Lesson 12 Thermistor .......................................... 138
6.13 Lesson 13 Ultrasonic ........................................... 144
6.14 Lesson 14 Infrared-Receiver ....................................... 150
6.15 Lesson 15 Humiture Sensor ....................................... 155
6.16 Lesson 16 Joystick PS2 ......................................... 161
6.17 Lesson 17 7-Segment Display ...................................... 165
6.18 Lesson 18 74HC595 ........................................... 171
6.19 Lesson 19 Stepper Motor ......................................... 176
6.20 Lesson 20 Simple Creation-Stopwatch ................................. 182
6.21 Lesson 21 Simple Creation-Answer Machine .............................. 191
6.22 Lesson 22 Simple Creation-Small Fan .................................. 198
6.23 Lesson 23 Simple Creation - Digital Dice ................................ 203
7 For Uno User 209
7.1 Lesson 1 Blinking LED ......................................... 209
7.2 Lesson 2 Flowing LED Lights ...................................... 217
7.3 Lesson 3 Controlling LED by Button .................................. 222
7.4 Lesson 4 Doorbell ............................................ 229
7.5 Lesson 5 Tilt Switch ........................................... 234
7.6 Lesson 6 Relay .............................................. 237
7.7 Lesson 7 RGB LED ........................................... 242
7.8 Lesson 8 Controlling an LED by Potentiometer ............................. 250
7.9 Lesson 9 Photo resistor .......................................... 258
7.10 Lesson 10 Servo ............................................. 264
7.11 Lesson 11 LCD1602 ........................................... 268
7.12 Lesson 12 Thermistor .......................................... 274
7.13 Lesson 13 Ultrasonic ........................................... 280
7.14 Lesson 14 Infrared-Receiver ....................................... 286
7.15 Lesson 15 Humiture Sensor ....................................... 291
7.16 Lesson 16 Joystick PS2 ......................................... 297
7.17 Lesson 17 7-Segment Display ...................................... 301
7.18 Lesson 18 74HC595 ........................................... 306
7.19 Lesson 20 Stepper Motor ......................................... 312
7.20 Lesson 20 Simple Creation-Stopwatch ................................. 317
7.21 Lesson 21 Simple Creation-Answer Machine .............................. 327
7.22 Lesson 22 Simple Creation-Small Fan .................................. 332
7.23 Lesson 23 Simple Creation - Digital Dice ................................ 337
ii

8 Play with Scratch 345
8.1 Install and Introduce PictoBlox ..................................... 346
8.2 Projects .................................................. 348
9 FAQ 517
9.1 1. the board does not work? ....................................... 517
9.2 2. COM14”: Access is denied? ..................................... 517
9.3 3. How to work in PictoBlox’ Stage Mode? ............................... 517
9.4 4. How to work in PictoBlox’ Upload mode? .............................. 517
10 Thank You 519
11 Copyright Notice 521
iii

iv

SunFounder uno-and-mega-kit
With this kit, we will walk you through the know-how of using the SunFounder board in a hands-on way. Starting
with the basics of electronics, you’ll learn through building several creative projects. Including a selection of the most
common and useful electronic components, this kit will help you “control” the physical world.
If you want to learn another projects which we don’t have, please feel free to send Email and we will update to our
online tutorials as soon as possible, any suggestions are welcomed. Here is the Email: cs@sunfounder.com.
CONTENTS 1

SunFounder uno-and-mega-kit
2 CONTENTS

CHAPTER
ONE
COMPONENTS LIST
3

SunFounder uno-and-mega-kit
4 Chapter 1. Components List

SunFounder uno-and-mega-kit
5

SunFounder uno-and-mega-kit
6 Chapter 1. Components List

SunFounder uno-and-mega-kit
7

SunFounder uno-and-mega-kit
8 Chapter 1. Components List

CHAPTER
TWO
COMPONENTS INTRODUCTION
Below is the introduction to each component, which contains the operating principle of the component and the corre-
sponding projects.
Basic
2.1 SunFounder R3 Board
Note: The SunFounder R3 board is a mainboard with almost the same functions as the Arduino Uno, and the two
9

SunFounder uno-and-mega-kit
boards can be used interchangeably.
SunFounder R3 board is a microcontroller board based on the ATmega328P (datasheet). It has 14 digital input/output
pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator (CSTCE16M0V53-R0),
a USB connection, a power jack, an ICSP header and a reset button. It contains everything needed to support the
microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to
get started.
Technical Parameters
• MICROCONTROLLER: ATmega328P
• OPERATING VOLTAGE: 5V
• INPUT VOLTAGE (RECOMMENDED): 7-12V
• INPUT VOLTAGE (LIMIT): 6-20V
• DIGITAL I/O PINS: 14 (0-13, of which 6 provide PWM output(3, 5, 6, 9-11))
• PWM DIGITAL I/O PINS: 6 (3, 5, 6, 9-11)
• ANALOG INPUT PINS: 6 (A0-A5)
• DC CURRENT PER I/O PIN: 20 mA
• DC CURRENT FOR 3.3V PIN: 50 mA
10 Chapter 2. Components Introduction

SunFounder uno-and-mega-kit
• FLASH MEMORY: 32 KB (ATmega328P) of which 0.5 KB used by bootloader
• SRAM: 2 KB (ATmega328P)
• EEPROM: 1 KB (ATmega328P)
• CLOCK SPEED: 16 MHz
• LED_BUILTIN: 13
• LENGTH: 68.6 mm
• WIDTH: 53.4 mm
• WEIGHT: 25 g
• I2C Port: A4(SDA), A5(SCL)
What’s More
•Arduino IDE
•Arduino Programming Language Reference
•Install and Introduce Arduino IDE
•ATmega328P Datasheet
2.2 SunFounder Mega Board
2.2. SunFounder Mega Board 11

SunFounder uno-and-mega-kit
Note: The SunFounder Mega board is a mainboard with almost the same functions as the Arduino Mega 2560 Rev3,
and the two boards can be used interchangeably.
The SunFounder Mega Board is a microcontroller board based on the ATmega2560 (datasheet). It has 54 digital
input/output pins (of which 15 can be used as PWM outputs), 16 analog inputs, 4 UARTs (hardware serial ports), a
16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything
needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC
adapter or battery to get started. The SunFounder Mega Board board is compatible with most shields designed for the
Uno and the former boards Duemilanove or Diecimila.
Technical Parameters
• MICROCONTROLLER: ATmega2560
• OPERATING VOLTAGE: 5V
• INPUT VOLTAGE (RECOMMENDED): 7-12V
• INPUT VOLTAGE (LIMIT): 6-20V
• DIGITAL I/O PINS: 54 (0-53, of which 15 provide PWM output(2-13, 44-46))
• ANALOG INPUT PINS: 16 (A0-A15)
• DC CURRENT PER I/O PIN: 20 mA
• DC CURRENT FOR 3.3V PIN: 50 mA
• FLASH MEMORY: 256 KB of which 8 KB used by bootloader
• SRAM: 8 KB
12 Chapter 2. Components Introduction

SunFounder uno-and-mega-kit
• EEPROM: 4 KB
• CLOCK SPEED: 16 MHz
• LED_BUILTIN: 13
• LENGTH: 101.52 mm
• WIDTH: 53.3 mm
• WEIGHT: 37 g
• I2C Port: A4(SDA), A5(SCL); 20(SDA), 21(SCL)
What’s More
•Arduino IDE
•Arduino Programming Language Reference
•Install and Introduce Arduino IDE
•ATmega2560 Datasheet
2.3 Breadboard
A breadboard is a construction base for prototyping of electronics. Originally the word referred to a literal bread
board, a polished piece of wood used for slicing bread.[1] In the 1970s the solderless breadboard (a.k.a. plugboard, a
terminal array board) became available and nowadays the term “breadboard” is commonly used to refer to these.
It is used to build and test circuits quickly before finishing any circuit design. And it has many holes into which
components mentioned above can be inserted like ICs and resistors as well as jumper wires. The breadboard allows
you to plug in and remove components easily.
The picture shows the internal structure of a breadboard. Although these holes on the breadboard appear to be inde-
pendent of each other, they are actually connected to each other through metal strips internally.
2.3. Breadboard 13

SunFounder uno-and-mega-kit
If you want to know more about breadboard, refer to: How to Use a Breadboard - Science Buddies
2.4 Jumper Wires
Wires that connect two terminals are called jumper wires. There are various kinds of jumper wires. Here we focus on
those used in breadboard. Among others, they are used to transfer electrical signals from anywhere on the breadboard
to the input/output pins of a microcontroller.
Jump wires are fitted by inserting their “end connectors” into the slots provided in the breadboard, beneath whose
surface there are a few sets of parallel plates that connect the slots in groups of rows or columns depending on the
area. The “end connectors” are inserted into the breadboard, without soldering, in the particular slots that need to be
connected in the specific prototype.
There are three types of jumper wire: Female-to-Female, Male-to-Male, and Male-to-Female. The reason we call it
Male-to-Female is because it has the outstanding tip in one end as well as a sunk female end. Male-to-Male means
both side are male and Female-to-Female means both ends are female.
Note:
• More than one type of them may be used in a project.
• The color of the jump wires is different but it doesn’t mean their function is different accordingly; it’s just
designed so to better identify the connection between each circuit.
14 Chapter 2. Components Introduction
Table of contents
Other SunFounder Computer Hardware manuals
Popular Computer Hardware manuals by other brands

ITOX
ITOX HR900-B user manual

2E
2E GAMING AIR COOL Operation guide

Nortel
Nortel Meridian M3904 installation guide

Renesas
Renesas SuperH HS7339KCU01HE Addendum

Modellbahn Digital Peter Stärz
Modellbahn Digital Peter Stärz BMMiba 3 v6-2010 quick start guide

Flexit
Flexit EcoNordic 117092 installation instructions