Microcontrollers & Programmer

PIC18F4520 - 8-bit PIC Microcontrollers

Working with digital inputs and outputs is fundamental to circuit design, and PIC microcontrollers add versatility to design by allowing programming and re-programming of the logic associated with input and output pins. In this way, one PIC microcontroller can take the place of many pre-programmed digital logic ICs.



Available Pins

With the exception of the positive voltage supply and ground pins, all pins on the PIC18F4520 can be used as digital I/O, however a few other pins (shown in grey below) are commonly utilized for communication instead of digital I/O. 


Digital Outputs Example

This section uses an example to describe how to setup and write digital outputs using a PIC18F4520.

Sample Code

Program to blink one LED on and off every half second.

First include header file with definitions for specific PIC. Set fuses. HS is type of external clock, low voltage programming (LVP) is off, and the watchdog timer (WDT) is off. External clock frequency of 20 MHz is specified.

  #use delay (clock=20000000)

Define pin names to be used in the main program. See header file for currently defined pin names.

  #define LED_0 PIN_C0

Begin main body of program. Notice main is a function of "void". This is a more explicit way of saying main is a function of nothing. Using main() is equivalent. Every program is required to have a function called "main".

  void main(void) {

Setup an infinite loop, using a while statement.


Turn LED on and off by setting its pin low or high, with a delay between each switching.


Circuit Diagram


Digital Output Ports Example

The PIC18F4520 has digital I/O pins organized into five ports. Ports A-D consist of eight pins each, while Port E has only three, although some of these pins are primarily used for communication. The diagram below shows the layout of the different ports on the PIC18F4520 microcontroller. 


Sample Code

Program to count in binary from 0-7 and display on LEDs.

First include header file with definitions for specific PIC. Set fuses. HS is type of external clock, low voltage programming (LVP) is off, and the watchdog timer (WDT) is off. External clock frequency of 20 MHz is specified.

  #use delay (clock=20000000)

Define variables to be used in main program. Both are defined as 8-bit numbers, with count already being assigned a value while temp is left unassigned.

  int count = 0;
  int temp;

Begin main body of program.

  void main(void) {

Set Port D to be an output (0). The SET_TRIS_X function can also be used to set ports to be inputs (1).


Use while to create an infinite loop.


Assign the value of "count" to Port D, thus displaying it on the LEDs connected to Port D.


Check the value of "count", and either increment it or reset it to zero.

        else {
           count = 0;}

Circuit Diagram


New Original ATMEGA328P-AU Micro-controller SMD QFP-32 Package TQFP32

8-bit Microcontrollers - MCU 32KB In-system Flash 20MHz 1.8V-5.5V
Op.Temperature:-40 ~ 85 degree
Series: ATMega

datasheet: http://www.atmel.com/Images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf



Support all with ISP, PDI interface AVR (mainstream AVR with ISP interface, xmega with PDI interface)

  •          AVR Studio4.1x interface
  •          Supports ISP programming for all AVR chips
  •          Flash and EEPROM can be programmed
  •          Supports programming of capacitive and locked bits
  •          Supports RC oscillator calibration
  •          Can be upgraded to support the latest chips
  •          Can work between 2.7 volts and 5.5 volts
  •          Speed adjustable, support 50hz ~ 8mhz isp clock frequency
  •          Use USB up to 12MHZ full speed communication, compatible with USB2.0
  •          Can be directly used USB or target board power supply without additional power supply
  • Support model list The USB AVR ISP MKII programmer and ATMEL original AT ISP MKII programmer support the same device model, the latest support Xmega full range of PDI interface and the new 6 ATtiny series of TPI interface


    Description This product is domestic USB AVR ISP MKII, 100% compatible with the original AT ISP MKII programmer, support the original firmware automatic upgrade, with ISP, PDI and the latest TPI three download.

STM32 ARM STM32F103C8T6 Minimum System Microcontroller core board


STM32F103C8T6 minimum system core board

Product introduction

This is a based on STM32F103C8T6 ARM chip core chip , has the following characteristics:

1, on board the most basic circuit based on MCU , such as crystal oscillator circuit, USB power management circuit and USB interface.

2, the core board leads to all the I / O port resources.

3, with SWD simulation debug download interface, the interface requires at least 3 lines to complete the debug download task, compared to the traditional JTAG debugging has many benefits, insert a sentence here, JTAG now have a lot to be eliminated trend, For example, ST M0 series of new MCU only retained the SWD debug interface, JTAG was canceled

4, the size is only the size of the traditional DIP40 package (such as AT89S52 ), has not yet found on Taobao smaller than the same specifications of the core board.

5, using the current Mirco USB smart phone interface, easy to use, can do USB communication and power supply.

6. For the problem that the STM32 RTC can not vibrate, we adopt the officially recommended low-load RTC crystal solution and use the Epson brand crystal instead of the cheap cylindrical crystal.

7, with a single row of high quality 1 * 40 / 2.54mm pitch pin to ensure good conductive contact, user-friendly core board placed on the standard board or breadboard. Header default is not welded, the user can choose according to their needs welding direction.

Chip Description: 1, STM32F103C8T6

Package Type: LQFP;

Number of pins: 48;

Kernel: Cortex- M3;

Working frequency: 72MHz;

Storage resources: 64K Byte Flash, 20KByte SRAM;

Interface Resources: 2x SPI, 3x USART, 2x I2C, 1x CAN, 37x I / O,

A / D conversion: 2x ADC (12-bit / 16-channel)

Timer: 3 ordinary timer 1 advanced timer

Debugging Download: support JTAG / SWD interface debug download, support IAP.

2, RT9193: 3.3V voltage regulator chip, the maximum output 300mA.

Other MCU parameters are as follows

 Interface Description: 
1, SWD interface: support for simulation, download and debugging.

2, Mirco USB interface: power supply and USB communication function, does not support download.

3, USART1 interface: USART1 can be used to download program, or use the USART1 for communication.

4, MCU pin interface: leads all I / O port pins, easy to connect with peripherals.

5, 5V and 3.3V power input and output interface: Commonly used in external power supply, or with other modules to deal with 
 other devices Description:

1, Power LED (PWR): power indication status, to determine whether the power is stable.

2, the user LED (PC13): easy I / O output test or indicate the program running status.

3, start jump jump to choose programming: (1, user flash 2, SRAM 3, system memory).

4, reset button: for user reset chip program.

5,8 M Crystal: frequency multiplier can be set so that the system clocked at 72MHz.

6,32.768KHz Crystal: for built-in RTC use, or for calibration.



Product Image:


Atmega2560 16AU TQFP-100 AVR Microcontroller IC Original New SMD

Datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2549-8-bit-AVR-Microcontroller-ATmega640-1280-1281-2560-2561_Summary.pdf 


• High Performance, Low Power Atmel® AVR® 8-Bit Microcontroller 

• Advanced RISC Architecture 

– 135 Powerful Instructions – Most Single Clock Cycle Execution 

– 32 × 8 General Purpose Working Registers 

– Fully Static Operation 

– Up to 16 MIPS Throughput at 16MHz 

– On-Chip 2-cycle Multiplier 

• High Endurance Non-unstable Memory Segments 

– 64K/128K/256KBytes of In-System Self-Programmable Flash 

– 4Kbytes EEPROM 

– 8Kbytes Internal SRAM 

– Write/Erase Cycles:10,000 Flash/100,000 EEPROM 

– Data maintenance: 20 years at 85C/100 years at 25C 

– Optional Boot Code Section with Independent Lock Bits 

• In-System Programming by On-chip Boot Program 

• True Read-While-Write Operation 

– Programming Lock for Software Security 

• Endurance: Up to 64Kbytes Optional External Memory Space 

• Atmel® QTouch® library bolster 

– Capacitive touch catches, sliders and wheels 

– QTouch and QMatrix securing 

– Up to 64 sense channels 

• JTAG (IEEE® sexually transmitted disease. 1149.1 consistent) Interface 

– Boundary-check Capabilities According to the JTAG Standard 

– Extensive On-chip Debug Support 

– Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG Interface 

• Peripheral Features 

– Two 8-bit Timer/Counters with Separate Prescaler and Compare Mode 

– Four 16-bit Timer/Counter with Separate Prescaler, Compare-and Capture Mode 

– Real Time Counter with Separate Oscillator 

– Four 8-bit PWM Channels 

– Six/Twelve PWM Channels with Programmable Resolution from 2 to 16 Bits 

(ATmega1281/2561, ATmega640/1280/2560) 

– Output Compare Modulator 

– 8/16-channel, 10-bit ADC (ATmega1281/2561, ATmega640/1280/2560) 

– Two/Four Programmable Serial USART (ATmega1281/2561, ATmega640/1280/2560) 

– Master/Slave SPI Serial Interface 

– Byte Oriented 2-wire Serial Interface 

– Programmable Watchdog Timer with Separate On-chip Oscillator 

– On-chip Analog Comparator 

– Interrupt and Wake-up on Pin Change 

• Special Microcontroller Features 

– Power-on Reset and Programmable Brown-out Detection 

– Internal Calibrated Oscillator 

– External and Internal Interrupt Sources 

– Six Sleep Modes: Idle, ADC Noise Reduction, Power-spare, Power-down, Standby, 

what's more, Extended Standby 

• I/O and Packages 

– 54/86 Programmable I/O Lines (ATmega1281/2561, ATmega640/1280/2560) 

– 64-cushion QFN/MLF, 64-lead TQFP (ATmega1281/2561) 

– 100-lead TQFP, 100-ball CBGA (ATmega640/1280/2560) 

– RoHS/Fully Green 

• Temperature Range: 

– - 40C to 85C Industrial 

• Ultra-Low Power Consumption 

– Active Mode: 1MHz, 1.8V: 500µA 

– Power-down Mode: 0.1µA at 1.8V 

• Speed Grade: 

– ATmega640V/ATmega1280V/ATmega1281V: 

• 0 - 4MHz @ 1.8V - 5.5V, 0 - 8MHz @ 2.7V - 5.5V 

– ATmega2560V/ATmega2561V: 

• 0 - 2MHz @ 1.8V - 5.5V, 0 - 8MHz @ 2.7V - 5.5V 

– ATmega640/ATmega1280/ATmega1281: 

• 0 - 8MHz @ 2.7V - 5.5V, 0 - 16MHz @ 4.5V - 5.5V 

– ATmega2560/ATmega2561: 

• 0 - 16MHz @ 4.5V - 5.5V

ATMEGA328P-PU DIP-28 with 16MHz Crystals HC-49S 2PCS Ceramic Capacitors 22pf

ATMEGA328P-PU DIP-28+16MHz Crystals HC-49S+2PCS Ceramic Capacitors 22pf

PCF8591 AD and DA Converter Module Analog to Digital and Digital to Analog Conversion Module


1. A module chip using PCF8591
2. module supports external voltage input capture (input voltage range 0-5v)
3. Three modules integrated photoresistor acquisition environment through the AD intensity accurate numerical
4. modules integrated thermistor, can capture the precise value of the ambient temperature through the AD
5. The five-module integrated 1 channel 0-5V voltage input acquisition (blue potentiometer to adjust the input voltage)
6. modules with power indicator light (on the module after power indicator lights)
7. modules with the DA output indicator light board DA output indicator module DA output interface voltage reaches a certain value, the voltage the greater the light brightness is more obvious;
8. module PCB size: 3.6cm * 2.3cm
9. standard double-sided, plate thickness 1.6mm, the layout is nice, surrounded by the through-hole, aperture: 3mm, convenient fixed

Performance indicators:
Single-Supply Operation
PCF8591 operating voltage range of 2.5V to 6V
Low standby current
Through the I2C bus serial input / output
PCF8591 by 3 hardware address pins addressing
Sampling rate PCF8591 I2C bus rate decided
4 analog inputs programmable as single-ended or differential inputs
Automatic incremental channel selection
PCF8591 analog voltage range from VSS to VDD
PCF8591 built-in track and hold circuit
8-bit successive approximation A / D converter
Through an analog output DAC gain

Module interface:

The module's left and right, respectively, the external expansion of 2-way pin interface, respectively, as follows:
Output interface of the left the AOUT chip DA
The AINO chip analog input interface.
AIN1 chip analog input interface
AIN2 chip analog input interface
AIN3 chip analog input interface
The right side of the SCL IIC clock interface to access the microcontroller IO port
The SDA IIC digital interface connected microcontroller IO port
GND module to an external
VCC power supply interface external 3.3v-5v
Module red jumper instructions for use
Module three red short circuit cap, respectively, the role are as follows:
P4 connected to the P4 jumper, select thermistor access circuit
P5 connected to P5 jumper to select the photoresistor access circuit
P6 connected to the P6 jumper, to select 0-5V adjustable voltage access circuit


Package Included:
1 X PCF8591 Module
4 X Dupond Cable

ATMEGA32-16PU - ATmega32 40-Pin 16MHz 32kb 8-bit Microcontroller

In order to make your CPU more versatile use this fantastic ATMEGA32-16PU microcontroller from Atmel. This microcontroller has an operating temperature range of -40 °C to 85 °C. It has a maximum clock speed of 16 MHz. This device has a typical operating supply voltage of 5 V. Its minimum operating supply voltage of...


Datasheet: http://www.mouser.com/ds/2/36/doc2503-48906.pdf

- See more at: http://www.ewallpk.com/avr/1283-atmega32-16-pu.html#sthash.qpr67iix.dpuf

NodeMCU Devkit 2.0 Kit

NodeMCU is an open source IoT platform.It uses the Lua scripting language. It is based on the eLua project, and built on the ESP8266 SDK 0.9.5. It uses many open source projects, such as lua-cjson,and spiffs. It includes firmware which runs on the ESP8266 Wi-Fi SoC, and hardwarewhich is based on the ESP-12 module.

NodeMCU is an open source IoT platform.It uses the Lua scripting language. It is based on the eLua project, and built on the ESP8266 SDK 0.9.5. It uses many open source projects, such as lua-cjson,and spiffs. It includes firmware which runs on the ESP8266 Wi-Fi SoC, and hardwarewhich is based on the ESP-12 module.

It is the 5th design of NodeMCU devkit. It uses CP2102 as UART bridge, and can flash firmware automatically by using nodemcu-flasher. It support apple's MAC OS.

Easy to access wireless router
Based on Lua 5.1.4 (without debug, os module.)
Event-Drive programming preferred.
Build-in json, file, timer, pwm, i2c, spi, 1-wire, net, mqtt, coap, gpio, wifi, adc, uart and system api.
GPIO pin re-mapped, use the index to access gpio, i2c, pwm.
Both Integer(less memory usage) and Float version firmware provided.

Build on ESP8266 sdk 0.9.5
Lua core based on eLua project
cjson based on lua-cjson
File system based on spiffs
Flash the firmware

nodemcu_latest.bin: 0x00000
for most esp8266 modules, just pull GPIO0 down and restart.
You can use the nodemcu-flasher to burn the firmware.

Or, if you build your own bin from source code.
0x00000.bin: 0x00000
0x10000.bin: 0x10000

Better run file.format() after flash

Connect the hardware in serial


Start play

Connect to your ap

ip = wifi.sta.getip()
-- nil
ip = wifi.sta.getip()
Manipulate hardware like a arduino

pin = 1
Write network application in nodejs style

-- A simple http client
conn=net.createConnection(net.TCP, 0)
conn:on("receive", function(conn, payload) print(payload) end )
conn:send("GET / HTTP/1.1rnHost: www.baidu.comrn"
    .."Connection: keep-alivernAccept: */*rnrn")
Or a simple http server

-- A simple http server

Hello, NodeMcu.

  conn:on("sent",function(conn) conn:close() end)
Connect to MQTT Broker

-- init mqtt client with keepalive timer 120sec
m = mqtt.Client("clientid", 120, "user", "password")
-- setup Last Will and Testament (optional)
-- Broker will publish a message with qos = 0, retain = 0, data = "offline"
-- to topic "/lwt" if client don't send keepalive packet
m:lwt("/lwt", "offline", 0, 0)
m:on("connect", function(con) print ("connected") end)
m:on("offline", function(con) print ("offline") end)
-- on publish message receive event
m:on("message", function(conn, topic, data)
  print(topic .. ":" )
  if data ~= nil then
-- for secure: m:connect("", 1880, 1)
m:connect("", 1880, 0, function(conn) print("connected") end)
-- subscribe topic with qos = 0
m:subscribe("/topic",0, function(conn) print("subscribe success") end)
-- or subscribe multiple topic (topic/0, qos = 0; topic/1, qos = 1; topic2 , qos = 2)
-- m:subscribe({["topic/0"]=0,["topic/1"]=1,topic2=2}, function(conn) print("subscribe success") end)
-- publish a message with data = hello, QoS = 0, retain = 0
m:publish("/topic","hello",0,0, function(conn) print("sent") end)
-- you can call m:connect again
UDP client and server

-- a udp server
s:on("receive",function(s,c) print(c) end)
-- a udp client
cu:on("receive",function(cu,c) print(c) end)

Package Included:
1 X NodeMCU Devkit 2.0