Latest Entries »

The BTS7960 is a high-current full-bridge motor driver module. The Key features are:

  • Input voltage: 6V to 27V
  • Maximum allowable current: 43 A
  • PWM capability: up to 25 kHz
  • Two PWM output pins for speed control in direct and reverse directions
  • Two EN output pins to control motors
  • Two IS input pins to protect against high current and heat

BTS7960 is a fully integrated high current half bridge for motor drive applications.
This contains one P- channel high side MOSFET and one N channel low side MOSFET with
an integrated driver IC in one package.

This module can be used to drive  2 wire huge current Motors .Not suitable for Stepper Motors .

In this post we will be using a huge current Motor 24v 250Watts like this :

A separate power source is required for this Motor.

24v 10Amp Metal SMPS is used for this source

This module has 12 pins:

Microcontroller pins (Low current):

  • VCC: Module power supply – 5V
  • GND: Ground
  • IS-R: Input signal for detecting high current – Straight rotation
  • IS-L: Input signal for detecting high current – Inverse rotation
  • EN-R: PWM Signal for controlling motor speed – Straight rotation
  • EN-L: PWM Signal for controlling motor speed – Inverse rotation
  • PWM-R: for controlling motor RIGHT direction
  • PWM-L:  for controlling motor LEFT direction. 

Motor pins (High current):

  • M+: Motor Positive
  • M-: Motor negative
  • B+: Battery positive
  • B+: Battery negative
  • You cannot overload the BTN7960B to destruction. It will overheat and safely shut off. Then restart when it cools and the Enable line is pulsed low then high . Under voltage Shut Down: To avoid uncontrolled motion of the driven motor at low voltages the device shuts off . If the Supply voltage  drops below 5.4V , The Motor driver will switched Off , And won’t turned on untill the Supply voltage increased to 5.5V Or more .
  •  Over temperature Protection: The BTS 7960 is protected against over temperature by an integrated temperature sensor. Over temperature leads to a shut down of both output stages.
  • Current Limitation : The current in the bridge is measured in both switches, High and Low side.If the current reaching the limit current  the switch is deactivated and the other switch is activated for a certain time.
  • To get the Motor to move in an H-bridge the Enable inputs should be held high and PWM-A and PWM-B should be different polarity.
  • Don’t pulse the enables and hold the PWM inputs at a DC level. Some old driver chips can do this. The BTN7960B doesn’t work that way.
  • The naming convention is bit confusing.
  • R PWM & L PWM pins can be pulled HIGH or LOW to enable Direction of Rotation.
  • R-EN  & L-EN pins are used for speed control using PWM.Generally , these 2 pins are connected together to a PWM pin of Arduino. AnalogWrite command is used to control speed.

Connect the Motor red wire to M+ and black wire to M-.

Connect B+ of module to positive of 24v 10amp power source . B- to negative of SMPS.

Make use of thick copper wires for power connection as the motor takes high current.

The module has  8 control pins.

Vcc is connected to 5v of Arduino & Gnd to Gnd of Arduino.

R_IS & L_IS are for current limit alarm outputs, which are not used in this demo.

R_EN & L_EN ins are Right,Left speed control pins .Both are connected together to D11 of Arduino. Note that we use a PWM enabled pin of Arduino for this.

L_PWM is connected to D10 ,  R_PWM is connected to D9. These 2 pins decide the direction control of the motor.

Now upload the following code to Arduino.

To run the motor in CW direction we make R_PWM pin High and L_PWM pin Low.

To make the motor run in CCW –   R_PWM pin Low and L_PWM pin HIGH.

To stop the motor both pins are made LOW.

Speed is controlled using ANALOGWRITE function where the PWM pin is given a value from 0 to 255.


#define RPWM 9
#define LPWM 10
#define PWM 11

void motor_cw(){              //CLOCK WISE
  digitalWrite (LPWM, LOW);
  digitalWrite (RPWM, HIGH);
  analogWrite (PWM, 255); // 0- 255  
  Serial.println (“MOTOR RUNS CW”);
void motor_ccw(){              //ANTI CLOCK WISE
  digitalWrite (LPWM, HIGH);
  digitalWrite (RPWM, LOW);
  analogWrite (PWM, 255);
  Serial.println (“MOTOR RUNS CCW”);

void motor_stop(){          //motor stop
  digitalWrite (LPWM, LOW);
  digitalWrite (RPWM, LOW);
  analogWrite (PWM, 0);
  Serial.println (“STOP”);
void setup() {
pinMode (RPWM, OUTPUT);
pinMode (PWM, OUTPUT);
pinMode (LPWM, OUTPUT);

void loop()



The HM-10 BLE Wireless Module-Original is a readily available Bluetooth 4.0 module, which can configure as either Master or slave.

This module is used for establishing wireless data communication. The module is designed by using the Texas Instruments CC2541 Bluetooth low energy(BLE) System on Chip (SoC). You can use it simply for a serial port replacement to establish connection between MCU & your embedded project

It is fully configurable by a rich and well documented AT command-set and allows transparent data communication via serial UART (default baud rate 9600 bps).

The Bluetooth 4.0 HM-10 is basically a breakout board for cc2541, it broke out the LED pins, RX/TX and also adding the voltage regulator that regular 5v to 3.3 v.

Clones available in market have on board only single crystal and the Firmware of clones support limited AT commands.Clones are mostly named as  MLT-BT05

Image 12

Pin Description:

  • STATE: state test pins, connected to an internal LED, generally keep it unconnected.
  • BRK: break connect, it means breaking the Bluetooth connection, generally keep it unconnected.
  • VCC: positive pole of the power source.
  • GND: Ground.
  • TXD: serial interface, transmitting terminal.
  • RXD: serial interface, receiving terminal.
    For testing AT Commands we need an USB-TTL module built on CP2102 ic.
    Connection between HM10 and USB-TTL is shown below :

Image 3

Tx of HM10 can be connected directly to Rx of USB-TTL.

Rx of HM10 to be connected through a level shifter to Tx of USB-TTL. A 1k in series and 2k2 across to Gnd is a simple level shifter.

HM10 can be supplied power 5v , as there is on board 3.3v regulator.

Connect the USB –TTL to PC and note the COM port allotted.

Image 1

We require a TERMINAL software to test AT commands.

The HM10 module do not wait for a Carriage Return .So Putty terminal cannot be used.We use COOLTERM terminal in LINE MODE.

Install COOLTERM software.


Under Serial port select the COM port of USB-TTL , Baud Rate 9600, 8N1

Image 4

Under TERMINAL setting select LINE MODE.

This allows sending AT commands as a single packet.

Image 3

Click on CONNECT.

Typing AT on the line mode gets an OK reply from HM10.

Image 5

To get the MAC address of HM10


Image 6

Notice the usage of ? for a Query command.

For assignment we do not use =

Just feed in the value after AT command.

For e.g to change the password from default 000000


After PASS we do not use = symbol.Just provide the value.

Image 11


Returns the default name of the module as HMSoft.

To change name AT+NAMEmyHM10

ROLE of HM10 by default is SLAVE.

To change to MASTER mode


On Master mode the HM10 will not broadcast its name.Pairing can be initiated only from a MASTER.

Image 7


returns 0.

By default HM10 is in AUTO BAUD mode 0.

You need to set the baud rate by



Returns the transmit power of module which is o dbm by default.

To restart the module


Image 8

There is an LED connected to PIO1 on board whish shows the STATUS.

Default value is 0 which makes LED blink 500ms  ON/OFF when in disconnected mode.

When paired , the LED goes ON steadily.

Image 9

Now let us pair this module from an ANDROID phone which will be Master.

Install the application BLE TERMINAL.

Open the application and Scan for devices.

HM10 appears as HMSoft.

2021_04_07_18.57.27                                    2021_04_07_18.57.39

Touch on this HMSoft and provide the password to pair.

2021_04_07_19.06.11                    2021_04_07_19.06.18

Once paired the LED on HM10 glows steadily.

Now you can type some characters on phone which is received at HM10 Coolterm.

From Coolterm window you can type and receive on phone BLE Terminal.


To DISCONNECT you can touch on the disconnect.



Image 10



ESP32-CAM is a camera module based on ESP32. It comes with an OV2640 2 MP camera and provides onboard SD memory card slot.

It is suitable for home smart devices,  wireless monitoring, and other IoT applications.

ESP32 CAM module has on board PSRAM.

Image 2

The OV2640 camera module on the ESP32 Camera board can support a max resolution of 1600 x 1200 pixels, however without PSRAM the camera frame buffer can only support a max resolution of 800×600 pixels

Boards with PSRAM (typically 4MB) can support the max resolution and also support 2 concurrent frame buffers. This provides for a better streaming experience as while  one frame is being sent , the camera is working on capturing the next frame.


Always Power up the module using 5V .Powering the board with 5V increases stability .

Image 1


The camera module has no USB input.So we need a FTDI programmer or USB-TTL module to upload program.In this testing we make use of an USB-TTL module built on CP2102 IC.

Connection between ESP CAM & USB-TTL is simple.

We make use of the 5v power from USB module itself.

Gnd is connected to Gnd pin of Camera module.

Rx of USB module to Tx (printed as UOT) of Camera module.

Tx of USB module to Rx (printed as UOR) of ESP CAM.


Do not use 3.3 V AS POWER SOURCE .

For PROGRAM Mode the GPIO0 pin must be connected to GND.

Plug in the USB-TTL module to PC and note the COM port allotted under Device Manager.

Image 1

To use Arduino IDE for programming , we need to install the ESP32 boards Manager for Arduino.

From Arduino IDE open File—> Preferences

Image 2

Copy and paste the following json link for additional Boards Manager :

click OK to close the window.

Image 4

Click   Tools  –> Boards –> Boards Manager

Image 5

A separate window opens.

Search for ESP32 and install the latest version.

Image 6

Once the ESP32 Board package is installed , you can select the ESP CAM board under Tools.

Click Tools  –> Board –> ESP32 Arduino

and select AI Thinker ESP32 CAM

Image 7

And then select the COM port.

Image 8

Now open the File –> Examples –> ESP32 –> Camera  –> Camera WebServer

Image 9

It is a sophisticated program.

To start with you need to select camera model .

For this , uncomment CAMERA_MODEL_AI_THINKER and comment all other:

Then enter SSID and PASSWORD for your WiFi router.

Image 10

Click on UPLOAD.

If GPIO0 is not connected to GND , you get a fatal error.

Image 11

Ensure that GPIO0 is connected to GND and click Upload.

While you see Connecting…….. at the bottom of IDE , Press the RESET switch on CAM module.

Image 13

RESET switch has to be pressed at the right time while you see Connecting…….


If RESET is not pressed properly , you get Error : Failed to Connect

Image 14

Image 16

Image 18

Once uploading is successful you see the message


Hard Resetting via RTS pin…

Image 20

Now open the SERIAL monitor of IDE.

Remove the GPIO-GND Jumper.

and press the RESET switch.

WiFi connected message is displayed  and you get an IP address for your Camera module.

This IP address is Dynamic and provided by your Router.

Image 21

Open the WEB Browser and type in the IP address.

Now you can see the DASHBOARD control of Camera.

Image 22

From here you can click on GET STILL button to take pictures.

Quality & Resolution of the picture can be modified by sliding the control bar provided.

Image 23

START STREAM button is provided to start streaming of live video.

Image 24

While you capture Still pictures , JPG picture details are displayed on the serial monitor.

Image 25

Following are some common problems and solutions :

If your power source is not providing enough current,

you get the following error.

Image 26

Always use 5V for supply , as 3.3v often gives problem.

Image 28

Image 29

If CAMERA MODEL is wrongly selected, you get error : Detected Camera not supported.

Always uncomment the correct model in the code and all others must be commented out.

Image 27



Raspberry Pi Pico is a low-cost, high-performance microcontroller board with flexible digital interfaces.

Other Raspberry PI boards are SBC –  Single Board Computer which requires an OS on a SD card.

But PICO is a Microcontroller like Arduino.

RPI boards do not have ANALOG inputs , PICO has 3 ANALOG inputs.

Designed on RP2040 IC (Dual-core Arm Cortex M0+ processor flexible clock running up to 133 MHz)

, this PICO board has 26 GPIO pins including 3 Analog Inputs.

As such RP2040 HAS 30 GPIO pins including 4 Analog inputs, but on board the user is offered with only 26 GPIO pins including  3 Analog Inputs.

  • 264KB of SRAM, and 2MB of on-board Flash memory
  • Castellated module allows soldering direct to carrier boards
  • USB 1.1 with device and host support
  • Low-power sleep and dormant modes
  • Drag-and-drop programming using mass storage over USB
  • 26 × multi-function GPIO pins
  • 2 × SPI, 2 × I2C, 2 × UART, 3 × 12-bit ADC, 16 × controllable PWM channels
  • Accurate clock and timer on-chip
  • Temperature sensor inbuilt
  • Accelerated floating-point libraries on-chip
  • 8 × Programmable I/O (PIO) state machines for custom peripheral support


PICO can be programmed with C / C++ SDK or MicroPython.

In this blog, we work with MicrPython.

To start with Press & Hold the BOOTSEL button on board and connect the USB to Windows PC.


Release the BOOTSEL button to see PICO appear as a mass storage device RPI-RP2.

Image 1

Open the Device Manager , you see PICO under Portable Devices as RPI-RP2.

Image 2

Open the RP2 storage .

Double click on the INDEX.HTM file to visit the official PICO website.

Image 3

Image 4

Scroll down to click Getting started with MicroPython.

Image 5

Here download the UF2 file , which is USB Flashing Format by Microsoft.

UF2 files can be opened and edited using a variety of Microsoft MakeCode editors.

To transfer a UF2 file to a microcontroller, developers plug their microcontroller into their PC’s USB drive. Their PC then recognizes the microcontroller as a FLASH DRIVE, allowing the developer to drag their UF2 file to the microcontroller and install their MakeCode program.

Image 6

Drag and Drop the UF2 file on to RPI-RP2.

Image 7

RPI-RP2 now disappears indicating Micropython installation is complete.

If you open the Device Manager , PICO appears as USB SERIAL DEVICE and a COM port is allotted.

Image 8

For GUI interface we use THONNY PYTHON.

Download and install Thonny Python

Image 9

Open Thonny Python

Under Tools –> Options



Under Interpreter drop down select

MicroPython Raspberry Pi PICO   and select the COM port allotted to PICO.

PICO is listed only in the newer version of Thonny.


Now click on the RED stop button to get the Interpreter CHEVERON 3 greater than symbol at the bottom.

You can try MicroPython commands here.

Image 10

To blink the on board LED let us start the coding under Editor.

First import PIN Class from machine module.

Functions are called modules in Micropython.

Then import sleep class from utime module for delay.

Create an led object which takes 2 parameters.First is the GPIO PIN , which is 25 where the inbuilt led is connected.

Second parameter to declare this pin as OUTPUT.

Then starts the never ending loop

while True:

After the colon you get an indentation space automatically.

This is equal to braces in Micropython.

Here we toggle the led and provide a delay of 1 second.

Image 11

Click File –> Save As

Image 12

You get 2 options to save.

Select Raspberry Pi PICO to save the file.

Image 13

Provide the filename as

Auto execution takes place only if the file name is

So it is a must to provide file name as

Image 14

Click on the green RUN button

Image 15

Now the LED on board blinks according to code.


To RESET the PICO back to factory condition

there is another UF2 file under Resetting Flash memory.

Download this nuke UF2 file.

Image 16

Press hold the BOOTSEL button and connect the USB to pc.


Drag and drop the nuke UF2 file on to RPI-RP2 to erase flash memory back to factory condition.

There is no RESET button on PICO.

You can connect a RESET button between RUN and GND pin as shown below :


video :


The MLX90614 from Melexis is an infrared thermometer for non-contact temperature measurements. Both the IR sensitive thermopile detector chip and the signal conditioning ASIC are integrated in the same TO-39 can.

Integrated into the MLX90614 are a low noise amplifier, 17-bit ADC and powerful DSP unit thus achieving high accuracy and resolution of the thermometer.

Factory calibrated in wide temperature range: -40 to 125°C for sensor temperature and -70 to 380°C for object temperature

SMBus ( I2C based) compatible digital interface for fast temperature readings and building sensor networks.

In this project we shall use the MLX90614 with OLED & ULTRASONIC sensor.Arduino NANO is used as controller.Calibration procedure for correct object temperature reading is also explained.


Before coding , we need to install the required libraries for Arduino.

Open Arduino IDE

Sketch –>  Include Library –>  Manage Libraries

Image 2

Search for MLX and select ADAFRUIT MLX90614 Library to install.

Image 3

Next search for GFX and install ADAFRUIT GFX Library , which is graphic support library for displays.

Image 1

Finally search for SSD1306 and select ADAFRUIT SSD1306 to install.

Image 4

Connection details are as shown in image below.


         TRIG –> D12

         ECHO –> D11


        SDA –> A4

        SCL –> A5


        SDA –> A4

        SCL – A5

A mini buzzer is connected to D3.

Vcc of OLED,MLX & Ultrasonic are connected to 5v of NANO

All GND pins are made common.

If you want you can use an external power source 5V 1 AMP at Vin of NANO.

As power consumption of OLED,MLX is very low , we can source power from NANO itself.

OLED & MLX are I2C devices , so they are connected to I2C pins of NANO ( SCL & SDA).

According to I2C address , respective device can be communicated.



CODE Explanation :

Starting with we include the libraries we installed for  MLX & OLED.

Image 1

An object named mlx is created from class Adafruit_MLX90614 from MLX library.

An object display is created from class Adafruit_SSD1306 from OLED library.Here we pass argument –1 , as there is no Reset pin in OLED.

Image 5

Variables like roomTemp, objectTemp , stemp , threshold are created as Float

Ultrasonic echoPin is defined at D11 , trigPin at D12.

The Maximum & Minimum range of Ultrasonic are initiated as Integer variables.

Ultrasonic will sense the object distance and the Temperature reading from MLX will be initiated only when the Object is in between 15 and 25 cm.

Image 8

Inside void setup()

Trigger pin of Ultrasonic is declared as OUTPUT pin , Echo as INPUT pin.

OLED display is initiated using begin() function and the I2C address of OLED is passed as argument (0x3C).

setTextColor() function is used to pass argument WHITE which enables black background for OLED.

Image 7

Inside loop() we generate a trigger pulse for Ultrasonic to generate a 40kHz burst.

The pulse reflected from object is calculated as width using pulseIn() function of Arduino.

Distance of the object is then calculated.

The object temperature in Celcius is read using MLX library function readObjectTempC()

& room temperature using function readAmbientTempC()

Initially the threshold value is set as 0.

After calibration we shall fix the correct threshold value.

Image 10

Display settings for OLED by using functions setCursor() , display()

At the bottom of OLED we display the distance of target object in cm & then the Room temperature in celcius.

If distance of object is above maximum range  ( we’ve set it as 25cm) , GET CLOSER is printed on display.

If distance of object is below minimum (15 cm) , TOO CLOSE is printed.

Image 11

If the object is between 15 and 25 cm then HOLD ON is printed.

Till readcount is 5 (5 times we take reading and Average it) disptemp() is called.

Finally the object temperature is displayed.

Image 12

If object temperature is above 37.5 celcius  , play_alert() function is called.Here we use the tone()

Image 13

Finally the compiled code is uploaded to NANO.

Image 15

OLED display shows GET CLOSER initially and the object distance is displayed at the bottom along with room temperature.


If the object is near to sensor ( below 15 cm) , TOO CLOSE is displayed.


If the object is between 15cm and 25 cm , HOLD ON is displayed and blinks 5 times.

Reading is taken 5 times and averaged.


Forehead or Wrist is shown in front of sensor for taking reading of temperature.

The display shows 31.2 degree celcius.

Image 3

We use an oral thermometer for calibration purpose.Using this meter under tongue , it shows 98.2 Fahrenheit.

Image 4

Converting F to Celcius , it is 36.8 C

Image 5

36.8 LESS 31.2 (shown by OLED initially) = 5.6

So we need to use this value as THRESHOLD.

Image 14

Update the threshold value and then upload the code.

Now the display shows the correct temperature 36.9 C

Image 7

Video tutorial :


7 HDMI display with capacitive touchscreen is now available with resolution 1024 x 600 pixels.

The touch panel supports up to 5 touch points. And it adopts  free-driver technology, no special requirement of drivers.

There is no need for  external power supply for the screen, it can be powered by USB port and HDMI port from Raspberry PI.

  • Operating Voltage: 5V
  • Operating Current: 160mA
  • Maximum Operating current: 1200mA  (with HDMI connection)
  • Refresh Frequency: 43Hz – 60Hz
  • Screen Resolution: 1024×600
  • Video Interface: HDMI
  • Supports Raspbian,Raspberry PI  OS ,5-points touch, driver free.

Previous models are TFT displays.TFT stands for the thin-film transistor, which is just another kind of liquid crystal display.One of the major shortcomings of using TFT is that it does not offer a good level of visibility.

This new display is IPS . In-Plane Switching

IPS panels seek to solve TFT panels’ issues of poor color reproduction and viewing angles. In this regard, IPS panels have largely succeed. Not only do they offer a higher contrast ratio (superior blacks), high color accuracy , but IPS panels also have very little color shift when changing the viewing angles.

Hence, with this technology, you can view the screen from much wider angles and sides without experiencing unwanted blurriness and grayscale.

The negative point about IPS panel is their poor response rates and lower possible refresh rates, IPS panels are generally not considered for competitive gameplay

WAVESHARE make is original


On the back side left top is the HDMI connector.Below that is the micro USB socket for power and touch.This USB can be connected to one of the USB ports of RPI.

A mini slide switch is there for display ON / OFF.


A HDMI cable , USB to micro usb cable and a HDMI micro converter ( used for RPI 4 models)

are provided with the display.


Clone or Copy models similar to Waveshare are also available in the market.

Clone display has 2 micro usb sockets , one for power & the other for both power & touch.


WaveShare original has EMI and ESD protection near the HDMI socket


Also the original one has USB protocol translator, converting the touch signal into standard multi-points touch protocol to achieve smooth multi-points touch control.


Before connecting the display to Raspberry PI , prepare the Operating System for PI.

Download the latest RASPBERRY PI OS ( previously called Raspbian) from

Use BALENO ETCHER software to write image on to SD card.Always use CLASS10 type micro SD card.

For this you need a card reader to plug SD card on to your PC.

Once the image is written on SD card , if you re plug the card reader to pc, you can see the BOOT partition . The ROOT partition is not visible on Windows machine.

Image 1

Right click on empty space and create a new TEXT document.Name it as ssh.txt

Then delete the .txt extension , so that only a file named ssh exists without any extension.

On next boot on RPI , the SSH is enabled and the file named ssh will be deleted automatically.

Next we need to modify the config.txt file to enable view on display.

Open config.txt file.

Image 2

Scroll to the end of file and add following commands.

Image 3

As we power the display from USB of RPI , we need to boost the current source capacity of USB port of RPI.

This is achieved by


which makes USB current source to maximum of 1.2 amp

Setting a specific HDMI mode is done using the hdmi_group and hdmi_mode config.txt entries.

The group entry selects between CEA or DMT, and the mode selects the resolution and frame rate.



To set a custom display mode we use 87 for mode.

HDMI output group is set to 2 which represents DMT (Display Monitor Timings, the standard typically used by monitors)

Then define a custom CVT  — Coordinated Video Timings

hdmi_cvt= width1024  height 600  framerate 60  aspect 6  margins 0  interlace 0 rb 0

width  1024 pixels

height 600 pixels

framerate 60 Hz

aspect 6 —  ratio  15:9

margins  0
0=margins disabled, 1=margins enabled

interlace  0
0=progressive, 1=interlaced

rb  0
0=normal, 1=reduced blanking


hdmi_ignore_edid to 0xa5000080

enables the ignoring of EDID/display data if your display does not have an accurate EDID. It requires this unusual value to ensure that it is not triggered accidentally.

HDMI_BOOST increases the amplitude and/or pre emphasis of the HDMI signal.
For long HDMI cables use value 7 or 11.

Save the CONFIG.TXT file.

Remove the SD card and plug it to RPI.

Connect HDMI cable between HDMI ports.

Connect the micro usb cable to touch port of display and the other end to one of the USB ports of RPI.

Use a power adapter of 5v and ampere more than 2 amps


Switch on the power to see the display booting up to welcome screen of RPI.

TOUCH functions work without any installation of drivers.

Image 4

You can also set the SD card for auto connect with WIFI , and also you can install Match box keyboard for on screen keyboard.

Watch this video :



PIC 12F675 is 8 bit , 8 pin mini and powerful Microcontroller.

It has 1k Bytes of ROM Flash memory , 64 Bytes of RAM ,  128  Bytes of EEPROM , 4 channels of 10 bit ADC , 2 TIMERS one 8 bit and another 16 bit.A comparator and inbuilt oscillator also are provided.

This chip can be programmed using PICKIT3.

IDE used is MPLAB X and compiler is XC 8.

Connection details as below in image.

An LED is connected to pin 3 (GP4) .Short lead of LED is connected to Gnd through a Resistor 470E.


MPLAB X IDE is the IDE used here for development.Compiler installed is XC8

Image 2

Open MPLABX IDE , File  –> New Project

Select  Standalone Project

Image 3

Under Device select PIC12F675

Against TOOL , tick mark Show All and select PICKIT3 from the dropdown list.

Image 4

Next is the selection of Compiler.

Select XC8 .

If not listed , check the installation of XC8 compiler.

Image 5

Provide a Project name and browse to the location of folder created for project location.

Image 6

Now the project files are created.

Right click on SOURCE FILES and click on New –> main.c

If you want rename the file , leave the extension as .c

Click Next to add the .c file to Source files.

Image 7

Click on .c file to see the skeleton C file.

#include <xc.h>

header file for Compiler is added automatically.

We need to set the configuration bits in the code using

#pragma config

Image 17

Settings like Internal oscillator , Watch Dog OFF , Brownout detect OFF can be

used with a comma separator in a single command line.

Image 16

You can also verify correct settings by clicking on Production –> Set Configuration Bits

Image 9

A new Window opens at the bottom.

Here you can do the needed settings and finally click on Generate code.

You can copy and paste the pragma settings inside the C code.

Or to make it simple make a single command line with comma separator.

As we cannot spare 2 GPIO pins for external crystal oscillator , most of the projects are configured for internal oscillator of 4 MHz.

This is set by

# pragma config FOSC=INTRCIO

Image 10

Next we need to define the crystal frequency

#define _XTAL_FREQ 4000000

Without this command delay function will not work.

Data Direction is set by TRISIO Register.

Making a bit 0 will make the corresponding  GPIO pin OUTPUT

and making a bit 1 will configure GPIO as INPUT.


The above notation can also be used.Here 0 is left shifted 4 times thus making GP4 as OUTPUT.

Under never ending loop we make GP4 initially 0 and after a delay of 1 second we make it 1.

Note the usage of double underscore __ before delay.

Image 11

Before building the project , an important setting to be done to make the Power to Target from PICKIT3.

Click Set Project Configuration and then Customize.

Image 20

Select PICKIT3 and then from the dropdown select POWER.

Image 13

Put a tick mark against Power Target from PICKIT3 and click Apply.

Image 14

Now click on BUILD MAIN PROJECT or F11 Button to Compile.

Image 15

When no errors are found , you can see BUILD SUCCESSFUL.

Image 18

Now click on the DOWN Arrow icon on tool bar to upload the hex file on to chip.

Image 19

Once file is uploaded , you can see the LED connected to GP4 blinking.



ATTINY85 , a 8 bit AVR Microcontroller provides many features in lesser pins.

With program memory of 8Kbytes the controller has satisfying memory for many applications.

With various POWER SAVE modes it can work on battery operated applications.




Number of  Programmable I/O pins   6           Operating Voltage  +2.7 V to +5.5V

Maximum DC Current per I/O Pin 40 mA     Maximum DC Current through VCC and GND Pins 200 mA

Communication Interface

Master/Slave SPI Serial Interface  (5,6,7  PINS)   [Can be used for programming this controller]

I2C or Two-wire Serial Interface  (5,7  PINS)  [Can be used to connect peripheral devices and sensors]

Universal Serial Interface  (5,6,7 PINS)   [Can be used for communicating with other controllers]


UART Interface   Not available        ADC Feature  4channels, 10-bit resolution ADC

Analog Comparators 1                    Timer Module   2 x  8-bit counter

PWM outputs  4                              External Oscillator   0-20MHz for ATTINY85

Internal Oscillator   0-8MHz  Calibrated Internal R-C Oscillator

CPU Speed   1 MIPS @ 1MHz

Program Memory or Flash memory size  8Kbytes

RAM size   512Bytes on Internal SRAM

EEPROM size  512Bytes of In-System Programmable EEPROM

Program Lock   Available          Watchdog Timer  Available

Power Save Modes      Three Modes  [Idle ,  ADC Noise Reduction ,  Power-down ]


Image 2


ATTINY85 can be programmed in many ways.

This post is on programming in AVR mode .

For programming we need an USBASP (also called AVRDUDE)  hardware  which is the same one used for programming 8051 ICs.



Connection between ATTINY85 and USBASP is by SPI pins

MOSI to MOSI (pin5)

MISO to MISO (pin 6)

SCK to  SCK (pin 7)

RST to RST (PIN 1)

Vcc to pin 8 & Gnd to pin 4 of ATTINY.

Image 3

For programming we use WINAVR (Programmers Notepad & MFILE)

usbasp driver and winavr can be downloaded from following link.

download link :

After installing driver for usbasp , open the Device Manager to see USBASP under libusb.


Image 1


Next install WINAVR


Accept default location of installation.

Image 2

Following components must be selected

ADD Directories to PATH

Install Programmers Notepad

Image 3


Otherwise Programmers Notepad (PN) will not work.

MFile which makes RULE for programming also installed automatically.

Image 4

In WIN 8 / 10 you need to replace msys.dll file.

Copy the file from the downloaded folder.

Go to C:\WINAVR\utils\bin

and paste.

Image 5

Confirm Replace file.

Image 6


Image 7

Open Programmers Notepad.

Always create a separate folder to save your project files.


Type in the C code to blink LED connected at  PB3 (pin 2 ) of ATTINY.


Image 9

Save the file with .c extension.

Image 10

Now you have to create the MAKEFILE in the same project folder.

Click on MFile.


Image 12

Select  MCU Type as ATTINY85.

Image 13

Select PORT as usb

Image 14

Programmer to be set as usbasp.

But usbasp is not in Programmer list.

Select any one from the Programmer list and then click on ENABLE EDITING.

Image 15

Change the Programmer as usbasp.

Image 16

Scroll up to find TARGET.

Rename TARGET to the file name of your project.Here it is ledblink.

Do not use the .c extension here.

Image 17

Save the file in the same folder where you stored the .c file.

Image 18


Under Tools  —>  click Make All

Image 11


Image 22


If no error in coding , you get Process Exit Code : 0  and .hex file created in your project folder.

Image 19

Click on Tools  –>  Program


Image 20

The .hex file will be loaded on to the ATTINY successfully.

Image 21

The LED starts blinking now.

WINAVR can be used to write C file and program using USBASP.

video :




Image 4


In these days of Virus spread , automatic hand sanitizer and auto water tap are the need of the hour.

This is a very simple and low cost effective circuit without a Microcontroller.

Water pump or Water Solenoid can be controlled for dispensing sanitizer or water automatically when hand is brought near the sensor.

Sensor used here is an IR MODULE.

Image 3


The IR sensor module is built on  IR Transmitter and Receiver, Opamp, Variable Resistor &  output LED indicator. IR LED Transmitter is white or transparent in colour,and emits infra red light invisible to human eye.IR Receiver is a photo diode black in color to absorb more light.

IR rays reflected from object is sensed by this receiver and current flow is proportional to the amount of Light. This property makes it useful for IR detection.

A LM358 or 386 comparator is on board and gives a LOW signal while detecting IR.

Normally Output pin is HIGH and becomes LOW on any intruder object.The blue trimpot can be adjusted for sensitivity.

The board operates on 5V DC , and we need a 7805 regulator to convert 12v to 5v.

Image 2


The main device in the circuit is the 4 leg IC OPTOCOUPLER PC817.

It is the cheapest IC available and price is less than a 555 IC.


It has inbuilt  Infrared Emitting Diode (IR LED) and a photo transistor . It is Enclosed in a 4 pin package.

The photo transistor’s base becomes activated when LED conducts and throws light on it. When the current flowing through the LED is interrupted, the infra-red emitted light is cut-off, causing the photo-transistor to cease conducting. The photo-transistor can be used to switch current in the output circuit.

The black DOT is pin 1 which is ANODE of Diode.


The output of OPTO drives a Transistor and in turn the solenoid.

The transistor we use is a NPN  BD139.


Image 7

  • Continuous Collector current (IC) is 1.5A
  • Collector-Emitter voltage (VCE) is 80 V
  • Collector-Base voltage (VCB) is 80V
  • Emitter Base Breakdown Voltage (VBE) is 5V
  • DC current gain (hfe) is 40 to 160

To the collector of BD139 is added the load (solenoid or water pump) through supply voltage.

When BD139 conducts , it switches ON the solenoid.

A diode 1n4007 is used across the coil of solenoid.

A    FLY BACK Diode is placed with reverse polarity from the power supply and in parallel to the relay’s inductance coil. The use of a diode in a relay circuit prevents huge voltage spikes from arising when the power supply is disconnected. A flyback diode is sometimes called flywheel diode, relay diode, or snubber diode as a flyback diode circuit is a type of snubber circuit.

The solenoid used for water tap is the one widely used in water coolers.

Normal working voltage is 24v DC , but it works fine on 12v.

Image 5


The valve features a solenoid, which is an electric coil with a movable ferromagnetic core (plunger) in its center. In the rest position, the plunger closes off a small passage. An electric current through the coil creates a magnetic field. The magnetic field exerts an upwards force on the plunger opening the passage.

This is the basic principle that is used to open and close solenoid valves.

The hole size of 1/4 , 1/2 inches available.

Smaller size ones used for sanitizer dispenser and the bigger ones for water tap.

Instead of solenoid you can replace with a pump motor also.

Image 6

This is a low cost, small size Submersible Pump Motor which can be operated from a 2.5 ~ 6V power supply. It can take up to 120 liters per hour with very low current consumption of 220mA. Just connect tube pipe to the motor outlet, submerge it in water and power it. Make sure that the water level is always higher than the motor. Dry run may damage the motor due to heating and it will also produce noise.

The final circuit requires a 12v supply .

The IR module used here is sensitive to Sun Light.So always cover the IR LEDs with a black sleeve or tape and adjust sensitivity by turning the blue trimpot.

When hand is brought near the IR circuit , it sends a LOW signal to OPTO coupler.

This conducts the BD139 and in turn operates the solenoid or pump.






CAN – Controller Area Network bus is widely used in Automobile industry and in other industrial applications.

CAN  is like Nervous system in Human body facilitating communication between all parts of body.

In CARs , NODEs or ECUs – Electronic Control Units are connected via CAN bus which acts as a control nervous system.

ECUs can be Engine control unit, Airbag control, Audi System , Door position,Brake system, Sensors & others.Each and every function can be assigned a NODE or ECU.

A modern CAR has upto 100 ECUs.



CAN allows ECUs to communicate with each other without complex dedicated wiring in between.

Any ECU can communicate with entire system without causing overload to the controller computer.


Image 2


CAN is MULTI MASTER setup.Any Node can be a MASTER.

CAN works on a MESSAGING TYPE SYSTEM & no slave address is used to communicate with a node.

Every Node receives the message and the related data will be conceived by the receiver node.

It is like public announcement system in  an Airport.Only concerned passengers will take the message.

To balance the CAN BUS and for noise reduction a 120E RESISTOR is used as Terminator.This is must for END NODES. Nodes added in between need not use this Resistor.

In this project we make use of a CAN Board CAN2515.

This board has 2 ICs.  One is the CAN Controller MCP2515 , which communicates with Arduino or any MCU by SPI Protocol.

MCP2515 gives SINGLE ENDED DIGITAL signal (High ,Low).



TX-CAN & RX-CAN are at digital levels and are connected to another IC , a TRANSCEIVER.

Here the Transceiver used is TJ1050 . Microchip MCP 2551 is also a transceiver , generally used with Microcontrollers which have inbuilt CAN Controllers.For e.g ESP32 module has in built controller , but it needs TRANSCEIVER like MCP2551 or TJ1050 .Do not confuse with the numbers


TJ1050 receives Digital signal from CAN2515 and converts tp DIFFERENTIAL SIGNAL acceptable on CAN BUS.

Note the connection between TJA1050 and CAN 2515 .

TX-CAN to TXD ,  RX-CAN to RXD ( not reversed).

The module we use has both ICs on board and we need not care about this connection.


Image 4

The CAN Message format is as below :

Image 1

The CAN-ID may be 11 bit or 29 bit.

11 BIT can addresses 2048 nodes ( 2 power 11) hex 0x000 to 0x7FF

29 bit Extended can up to 536 million.

DAT length allowed is max 8 BYTES or 64 bits.

To learn more about CAN Message visit here

Following picture shows the Differential signal level of CAN.



When no information is on BUS , both CAN-H & CAN-L are at half the supply volt  (here 2.5 volt on a 5v system).

This is RECESSIVE State or BIT 1.

When CAN-H goes to 5v and CAN-L to 0 v , it is DOMINANT State or BIT 0.


To start with the project , connect a potentiometer ( center pin) to A0 of Arduino.

One end of pot is connected to 5v and other end to Gnd.

The CAN board connections are as shown SPI connections between Arduino and CAN board.




Before starting we need a good Library for CAN to work with.

SEEED Studio has a Library which works fine with their Shield.

Also a modified version on it is available from Cryjfowler.

I prefer to use one from AUTOWP


which uses STRUCT  for message sending.This is very simple and easy to use.




Please note , the Seed studio library and that of coryjfowler both have the same header file name mcp_can.h. If you install both these libraries , then there is clash on object declarations arising errors.Use any one only.

In this demo we use arduino-mcp2515 library.Download it as ZIP file.

CAN library

From Arduino IDE   Sketch –> Include Library –> Add ZIP Library

and browse to the location of the downloaded library.Select it to install.

It will be copied to Documents/Arduino/Libraries

On the Receiver side we use an I2C LCD.

The library for the same can be downloaded and installed from :

i2c library :


ARDUINO CODE used in this project can be downloaded from :


Following picture shows the Transmitter side connections.

Potentiometer to A0 of Arduino , CAN board to SPI connections.



The code for the Transmitter side is :



Here we include the mcp2515.h header file.

We create an un initialized struct can_frame variable called canMsg.

can_frame is the STRUCT Type name

canMsg is the Variable name.

Data members of struct is assigned using dot operator.

As seen from the library documentation , there are 3 members , can_id , can_dlc & data[].


Image 3

mcp2515 object is initiated from class MCP2515 by passing the CS pin chip select pin 10 , as argument.

MCP2515 mcp2515(10);

Under set up we call the functions of object mcp2515

First reset() function is called.

Then setBitrate()  to set the CAN spped at 500KBPS & frequency 8 MHZ.

setNormalMode() to set the module function in Normal mode.





Using dot operator the members to STRUCT are added.

can_id is HEX ID which is user given.You can provide your own id in HEX.

can_dlc is the length of data.Maximum 8 BYTES allowed.Here we give data length as only one BYTE.

Under loop() , the analog pot value is mapped to value between 0 – 255

and the data sent over CAN bus using sendMessage() function of mcp2515.


Following is the Receiver side connection picture.

I2C LCD has 2 pins apart from Vcc & Gnd

SDA is connected to A4 ,  SCL is connected to A5.




The CAN board of Tx is connected to CAN board of Rx



Generally a twisted pair wire with shield is used.The shield is connected to GND.

Max length of 40 mtrs can be used.


Following is the Receiver side code :



Here we include the I2C LCD header.

While creating lcd object we pass on the I2C address and the size of LCD ( 16 X 2)

To know the I2C address you can use  i2c scanner from here

Under void loop

we use the readMessage() function of mcp2515 to verify the incoming message

& then we compare the id , then extract the message to display on LCD.




More sensors can be added to the project.

A LM35 temperature sensor at A3 and a Door ON/OFF switch can be added at D6.



ARDUINO CODE used in this project can be downloaded from :



video  :