The following internal modules are the most common peripherals that you will find in many microcontrollers
USART, CCP, Analogue Comparator. MSSP (I2C and SPI)
The CCP module implements three different modules Capture - to capture the arrival time of a signal change. Compare to generate signals at specific times and PWM: a pulse width modulation output.
The Universal Synchronous Asynchronous Receiver Transmitter.
This allows your PC to communicate with your microcontroller. It is such a universal protocol (serial transmit and receive data protocol) that it is used everywhere. Serial ports used to be included as standard on a PC but now only a USB bus is included. However you can buy a USB to seral module for the same result (the USB part becomes invisible) and you use A terminal program such as Tera Term to view and send data to and from the microcontroller.
It allows you to debug programs and can be used to control the operation of
You can make a software USART and even operate one on a 16F84 (it does not have a built in USART) but it saves code space if you use an internal module e.g. on a 16F88 or 16F877(A).
As well as this the module can be started and left to get on with transmitting the data on its own so the microcontroller CPU can get on with doing some other useful task.
As with the timers you can operate the USART in polled or interrupt mode and again the polled mode is easier but the interrupt mode saves processing power.
This is the mode that you need to use for communication with standard RS232
interfaces on PC - it is the normal mode of use for RS232.
All you need to make it work is a transceiver that translates the high voltages required by the RS232 interface from/to digital voltage levels e.g. a MAX232 chip.
This is a mode of the USART that uses an extra signal - a clock to clock in
all data. It allows very fast operation as the USART does not have to figure
out an estimated clock signal position to find the data.
Capture Compare PWM
This module - CCP - operates in one of three modes:
*Pulse Width Modulation.
You will probably find that the PWM mode is the most useful out of the three but that depends on the task you want to solve.
PWM has many uses from controlling the speed of a DC motor to generating an
analogue signal or controlling the brightness of a bulb.
The basic principle is that the output is fully on or off but by varying the percentage of time that the output is on then the average current delivered to the load can be controlled.
You can use Capture mode to capture the time that an event occurs.
When an external event occurs e.g. a signal transition from low to high the value of both Timer1 registers is stored in the CCP registers.
You can then go and look at these stored values to find out when the event occurred.
This mode compares the Timer1 value to the CCP value and generates an output
signal when a match occurs so you can generate an output at a specific time.
One internal use of this mode is to send a 'special event trigger signal' to start an ADC conversion - this would be useful in a datalogger.
The analogue comparator is an underused peripheral
but it is just as capable as the standalone comparator the LM311 (and just as
The advantage of this module is that it generates an interrupt and you can also feed in a separate comparison voltage generated internally in the PIC. This comparison voltage is generated by a DAC and is programmable.
Some PICs have two comparators in them and the other advantage is that they operate much faster than using a software solution so using them saves processing power.
For example you could build a line follower robot with two sensors using two comparators.
If you replace those comparators with the internal PIC comparators you could then add software functionality to make the robot more intelligent.
Another module that deserves a mention is the Master
Slave Synchronous Serial port.
Its implements two high speed serial interfaces I2C or SPI.
Serial Peripheral Interface.
You can buy SPI chips which have many different functions from ADCs to increasing I/O space. SPI is a simpler interface than I2C and runs at very high speed 10MHz.
I2C is more complicated but more flexible and you can use it as a multidrop
interface using only two wires - you can attach up to 128 chips on the two
wires. So it's very useful for for adding functions to a design when you have
run out of microcontroller pins!
Again you can buy many different chips with many different functions.
Note: the MSSP implements a full I2C interface while the SSP does not.
Control your projects using C.
...Programming the microcontroller.
A tutorial on using the ADS1115 precision 16 bit ADC for low power use.
ESP8266 Webserver: This code shows you how to use lua to create a webserver using html button inputs to contrtol an LED on the ESP module.
How to flash nodemcu firmware into a ESP8266 so you can use the LUA scripting language.
Nodemcu examples starting off wioth simple ones and progressing to wifi coding. This is an excellent tutorial to start learning how to use nodeMCU with lua.
Find out how to download the ESPLorer and use it to upload lua scripts
How to use the TCS230 (/TCS3200) Color detector chip and easily add it to any of your projects.