Codes for adding letters to 8X5 leds

Codes for Adding letters to 8X5 LEDs

From the last blog we have written codes to On/Off a LED individually. So here I gonna explain how to display letters on leds.
The trick is simple and that is by blinking a LED each time. The speed is so fast that it appears that all LEDs are ON at same time.

I have used the alphabet patterns or you can say fonts as similar to 16x2 LCD display. So letters will be in 7X5 LEDs matrix.

Example:
So you can blink LEDs row wise(rows first) or column wise. here shows how can you blink LEDs one by one.
Code for Writing 'G' is given below:
void Gi()
{
 int a=timel;//duration for which letter will be displayed
 while( a > 0){
 onled(1,2); onled(1,3); onled(1,4);
 onled(2,1); onled(2,5);
 onled(3,1);
 onled(4,1); onled(4,3); onled(4,4); onled(4,5);
 onled(5,1); onled(5,5);
 onled(6,1); onled(6,5);
 onled(7,2); onled(7,3); onled(7,4); onled(7,5);
 a--;
}}
This code can be used in the last blog I posted using as a function.

For the complete code click on link... and thanks for visiting.

DIY 8x5 LED Matrix display

DIY 8x5 LED Matrix display

If you want to make a 8X5 led matrix display without using any other MUX with arduino,then this article is for you.
Things you needed:
1. bunch of LEDs(check before use)
2. PCB Board(Brown board)

3. Jumper Wires(Male to female)

4. Arduino
5. 100 ohms resistors
6. Soldering Instrument and Hot glue gun

Wiring up/ Circuit connections:
Before you start have brief idea about leds:

  • choose healthy LEDs only
  • do check before soldering on the PCB.
  • these needs min 1.5V and a few mA current. So accompany them with 200 or 100 ohm resistance.
All you need is connect all Anode of leds in a row together and connect all cathode of leds in a column together. The circuit diagram will clear your thoughts.

From the above diagram if the row-x is given Low state and column-y is given High state then the LED belongs to (x,y) will glow.
But in programming or using arduino the state of all other leds should be in opposite in order to Switch them off.
So the idea is to ON one led at a time and make all other leds OFF that time.

Here are some pictures while making the circuit:


  •  Do add resistances(100 ohm or 200 ohms) otherwise the leds may damage due to over current flow. Add female header pins for make it arduino friendly.

CODING:

here is the code:

int row=0,col=0;
int time1=5;
int timex=1;
void onled(int x,int y)//PASSING ROW AND COLUMN VARIABLES TO ON THE RESPECTIVE LED
{
 reset();
 if(x==1){row=2;} if(x==2){row=3;} if(x==3){row=4;} if(x==4){row=5;} if(x==5){row=6;} if(x==6){row=7;} if(x==7){row=8;} if(x==8){row=9;}
 if(y==5){col=19;} if(y==4){col=18;} if(y==3){col=17;} if(y==2){col=16;} if(y==1){col=15;}
 digitalWrite(row,LOW);
 digitalWrite(col,HIGH);
 delay(timex);
}
void reset()//THIS FUNCTION USED TO SUPPLY ANODE WITH gnd AND CATHODE WITH +5V
{
 digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,HIGH);digitalWrite(5,HIGH);digitalWrite(6,HIGH);digitalWrite(7,HIGH);digitalWrite(8,HIGH);digitalWrite(9,HIGH);
 digitalWrite(15,LOW);digitalWrite(16,LOW);digitalWrite(17,LOW);digitalWrite(18,LOW);digitalWrite(19,LOW);
}

void setup() {
Serial.begin(9600);  

pinMode(2,OUTPUT);pinMode(3,OUTPUT);pinMode(4,OUTPUT);pinMode(5,OUTPUT);pinMode(6,OUTPUT);pinMode(7,OUTPUT);pinMode(8,OUTPUT);pinMode(9,OUTPUT);
pinMode(16,OUTPUT);pinMode(17,OUTPUT);pinMode(18,OUTPUT);pinMode(19,OUTPUT);pinMode(15,OUTPUT);
}

void loop() {
 onled(1,1);//on led of row-1 col-1    
}
The result will look like this:







Displaying letters on this will be in the next blog,till then you can use loops for different new patterns.

16X2 LCD Interface with Arduino

16x2 LCD Interface with Arduino

Its quite inconvenience to use serial monitor of Arduino IDE to display data or any message when a wireless display is needed. Thus a on-board display will be helpful for solving this issue. 16x2 LCD is one of the simplest & cheapest display one can use for this purpose.

Things needed:
- Arduino
-16x2 lcd 
- Connecting wires

About 16x2 LCD :
The LCDs have a parallel interface, meaning that the microcontroller has to manipulate several interface pins at once to control the display.
The interface consists of the following pins:
·         A register select (RS) pin that controls where in the LCD's memory you're writing data to. You can select either the data register, which holds what goes on the screen, or an instruction register, which is where the LCD's controller looks for instructions on what to do next.
·         A Read/Write (R/W) pin that selects reading mode or writing mode
·         An Enable pin that enables writing to the registers
·         8 data pins (D0 -D7). The states of these pins (high or low) are the bits that you're writing to a register when you write, or the values you're reading when you read.
·         There's also a display constrast pin (Vo), power supply pins (+5V and Gnd) and LED Backlight (Bklt+ and BKlt-) pins that you can use to power the LCD, control the display contrast, and turn on and off the LED backlight, respectively.
The process of controlling the display involves putting the data that form the image of what you want to display into the data registers, then putting instructions in the instruction register. The LiquidCrystal Library simplifies this for you so you don't need to know the low-level instructions.

Circuit Diagram
There are generally 16 pin slots on 16x2 LCD module. Here I have used 12 as shown in the figure. After wiring the module connect it and see if the back light is glowing.

Coding Part:
Write or past this code in arduino IDE

// include the library code:
#include <LiquidCrystal.h>
char str1[]="GaneshGadgets";
char str2[]=".blogspot.com";

LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
}
void loop() {
lcd.setCursor(0, 0);//cursor position
lcd.print("Ganeshgadgets ");
lcd.setCursor(3, 1);
lcd.print(".blogspot.com ");
}
The result will be like this:



Processing + OpenCV + Android IPcam : Detect Face

OpenCV + Processing + Android IPcam : Detect Face

All you need for this project is listed below:
1- Processing 3.3.6
2- openCV library for processing + IP-capture library
3- Ipcam App installed on your android device

Specialty of this project is phone camera is used for live camera detection. So you don't need web-cam for this.
Giving you short brief about the need of this project. 

1- Processing 3.3.6
Processing is an open source computer programming language and integrated development environment (IDE) built for the electronic arts, new media art, and visual design communities with the purpose of teaching the fundamentals of computer programming in a visual context, and to serve as the foundation for electronic sketchbooks.


2- Libraries
  • OpenCV
OpenCV (Open Source Computer Vision) is a library of programming functions mainly aimed at real-time computer vision. Originally developed by Intel, it was later supported by Willow Garage and is now maintained by Itseez. The library is cross-platform and free for use under the open-source BSD license.

OpenCV library can be downloaded from the software itself following
Sketch > Import Library > Add library > openCV Processing
{or}
You can download it from github
  1. Unzip it and paste it to Sketchbook>libraries.
  2. To find Sketchbook Location go to File>preferences>browse location.
  3. After successful installation of library you can find example under "Contributed Libraries."

  • IP Capture Library
Similarly you can download IP_Capture library from Sketch > Import Library > Add library
or you can download from Github

3- Ipcam App installed on your android device

There are many ipcam apps are available in playstore but i recommend this one.


After installing all software, libraries, apps lets get started. If you have some issue regarding installing mention in the comment box.

Procedure
  • First  turn on your  phone WiFi Hotspot and connect your PC to it. It will create a Local Network through which both devices can communicate. If you already have private network,then you can connect both your devices to that network
  • Open the IPcam app then go to the bottom and click on Start server. You will see Ip address to get camera stream like "http://192.168.43.1:8080 " note it down.
  • Now open processing and write the following code. It is bit different code than the code given in the OpenCV Contributed examples.
CODE:
import ipcapture.*;
import gab.opencv.*;
import java.awt.Rectangle;
OpenCV opencv;
Rectangle[] faces;

IPCapture video;
PImage src; //separate image variable to capture from Ip cam

void setup() {
  size(640,480); // can use full screen instead
  //fullScreen();
  video = new IPCapture(this);
  video.start("http://192.168.43.1:8080/video"," "," ");
}
void opncv() // function openCV
{
  opencv = new OpenCV(this, src);
  opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
  // See library reference to Detect eye,body,nose etc.
  faces = opencv.detect(); 
}
void getlive() {
    if (video.isAvailable()) 
    {
    video.read();
    }
    image(video,0,0); // draw image on screen
    src = get();
    // get what is drawn on screen and paste that to src image
    clear();
  }

void draw() {
  getlive(); //get live image
  opncv();
  image(src, 0, 0);// show live image on screen
  noFill(); // show a rectangle around face
  stroke(0, 255, 0);
  strokeWeight(3);
  for (int i = 0; i < faces.length; i++) {
    rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);   
  }
}
  • This is the result you will get.












Thanks for visiting my blog.
If you face some issue comment.

LINE FOLLOWER Part 4 :Coding and Run

LINE FOLLOWER Part 4 :Coding and Run

Coming to the final blog of Line Follower I have given the code for this,Copy this and directly paste it in Arduino IDE and modify according your needs.
Code is for only 3 sensor input and its good for Beginners.
Here's the Code:
_________________________________________________________________________________
//Code is for 3 sensor input//code by-Https://ganeshgadgets.blogspot.com

int ena = 11;//a-LEFT motor PWM output  
int enb = 10;//b-RIGHT motor PWM output
int ar = 12;//a reverse//
int af = 13;// aforward//
int bf = 9;//b forward//
int br = 8;//b reverse//

int s1 = 14, s2 =15, s3 =16; //3 sensors connected to analog a0,a1,a2 pins(digital equivalent)

void setup() {
  // put your setup code here, to run once:
  // declaring output pins
  pinMode(ena,OUTPUT);// declaring output pins
  pinMode(enb,OUTPUT);
  pinMode(ar,OUTPUT);
  pinMode(af,OUTPUT);
  pinMode(bf,OUTPUT);
  pinMode(br,OUTPUT);
  // declaring input pins
  pinMode(s1,INPUT);
  pinMode(s2,INPUT);
  pinMode(s3,INPUT);
  }

void loop() {
  // put your main code here, to run repeatedly:
  //case-1 FORWARD 
  if((digitalRead(s1)==HIGH) && (digitalRead(s2)==LOW) && (digitalRead(s3)==HIGH))
  {
  digitalWrite(ena, HIGH);// BOTH ENABLE PIN WILL BE HIGH FOR ALL CASES
  digitalWrite(enb, HIGH);

  digitalWrite(af, HIGH);
  digitalWrite(ar, LOW);
  digitalWrite(bf, HIGH);
  digitalWrite(br, LOW);
  }
  //case-2 SMOOTH TURN RIGHT  
  if((digitalRead(s1)==HIGH) && (digitalRead(s2)==HIGH) && (digitalRead(s3)==LOW))
  {
  digitalWrite(ena, HIGH);
  digitalWrite(enb, HIGH);

  digitalWrite(af, HIGH);
  digitalWrite(ar, LOW);
  digitalWrite(bf, HIGH);// GIVING BOTH HIGH RESULTS IN STOPPING RIGHT MOTOR
  digitalWrite(br, HIGH);
  }
  //case-3 SMOOTH TURN LEFT   
  if((digitalRead(s1)==LOW) && (digitalRead(s2)==HIGH) && (digitalRead(s3)==HIGH))
  {
  digitalWrite(ena, HIGH);
  digitalWrite(enb, HIGH);

  digitalWrite(af, HIGH);// GIVING BOTH HIGH RESULTS IN STOPPING LEFT MOTOR 
  digitalWrite(ar, HIGH);
  digitalWrite(bf, HIGH);
  digitalWrite(br, LOW);
  }
  //case-4 STOP OR START
  if((digitalRead(s1)==HIGH) && (digitalRead(s2)==HIGH) && (digitalRead(s3)==HIGH))
  {
  digitalWrite(ena, HIGH);
  digitalWrite(enb, HIGH);

  digitalWrite(af, HIGH);// GIVING ALL HIGH BOTH MOTORS WILL BE STOPPED
  digitalWrite(ar, HIGH);
  digitalWrite(bf, HIGH);
  digitalWrite(br, HIGH);
  }
  //case-5 STOP OR START
  if((digitalRead(s1)==LOW) && (digitalRead(s2)==LOW) && (digitalRead(s3)==LOW))
  {
  digitalWrite(ena, HIGH);
  digitalWrite(enb, HIGH);

  digitalWrite(af, HIGH);// GIVING ALL HIGH BOTH MOTORS WILL BE STOPPED
  digitalWrite(ar, HIGH);
  digitalWrite(bf, HIGH);
  digitalWrite(br, HIGH);
  }
  //case-6 SHARP RIGHT TURN
  if((digitalRead(s1)==HIGH) && (digitalRead(s2)==LOW) && (digitalRead(s3)==LOW))
  {
  digitalWrite(ena, HIGH);
  digitalWrite(enb, HIGH);

  digitalWrite(af, HIGH);
  digitalWrite(ar, LOW);
  digitalWrite(bf, LOW);// THIS WILL REVERSE MOTOR B
  digitalWrite(br, HIGH);
  }
  //case-7 SHARP LEFT TURN 
  if((digitalRead(s1)==LOW) && (digitalRead(s2)==LOW) && (digitalRead(s3)==HIGH))
  {
  digitalWrite(ena, HIGH);
  digitalWrite(enb, HIGH);

  digitalWrite(af, LOW);// THIS WILL REVERSE MOTOR A
  digitalWrite(ar, HIGH);
  digitalWrite(bf, HIGH);
  digitalWrite(br, LOW);
  }
  //case-8 ANTINODE DETECT 
  if((digitalRead(s1)==LOW) && (digitalRead(s2)==HIGH) && (digitalRead(s3)==LOW))
  {
  digitalWrite(ena, HIGH);
  digitalWrite(enb, HIGH);

  digitalWrite(af, HIGH);//IGNORING ANTINODE CONDITION AND MOVING FORWARD
  digitalWrite(ar, LOW);
  digitalWrite(bf, HIGH);
  digitalWrite(br, LOW);
  }
}
_________________________________________________________________________________

  • You can use more sensors in If Statement like;
 if((digitalRead(s1)==HIGH) && (digitalRead(s2)==LOW) && (digitalRead(s3)==HIGH) && (digitalRead(s4)==HIGH) && (digitalRead(s5)==HIGH) && (digitalRead(s6)==HIGH))
{........}

  • You can add speed variation in :
  analogWrite(ena, 200);//0-255
  analogWrite(enb, 200);//0-255

This is end of line follower project. For more tech and projects follow me.


LINE FOLLOWER Part 3 : CONNECTING ALL TOGETHER AND CONCEPT

LINE FOLLOWER Part 3 : CONNECTING ALL TOGETHER AND CONCEPT

Coming to the part 3 all you need is- 
  1. Arduino UNO(you can use others also,but I prefer UNO for beginners)
  2. Sensor Array(min 3 to max 5 numbers of ir sensors)
  3. Motor Driver(L298 or any other)
  4. Line follower Chassis
  5. Two DC motors
  6. Jumper Wires(male-female,female-female)
  7. Wheels and an Castro Wheel(Multi directional wheel)

Connect all the Modules According to the diagram given below:-



Points Worth Noting:-
  • All the modules should have a common ground. Every time you add any module to your project you should add ground of module to the ground pin of Arduino.
  • Connect the enable of motor Driver to any of PWM pins(3,5,6,9,10,11). It will help you to control the speed of Motor.
  • If you don't want speed Control then add enable pin to 5V of motor Driver or Vin, it will then take max speed in default.
  • Put all your sensor input to the analog pins. Its more convenient and gracious. You can use these pins as analog(A0....A5) or as digital pins(14-19). Digital input is better for line follower.
Concept Behind the Line follower Algorithm:
I will discuss the concept or the idea that can you use easily. Suppose you have 3 sensors so there are total of 8 possibilities of sensor values.
" You can use the formula-2^(No. of sensors)"
If you are using 5 sensors then you have 2^5=32 possibilities.
Lets go in detail....
See the figure

  • The sensor give digital HIGH while on white surface and digital LOW on black surface or VICE VERSA if you have sensor of inverting mode(op-amp).
  • Here we are considering following black line on white surface.
  • Going case by case.
CASE
ACTION REQUIRED
LEFT MOTOR
RIGHT MOTOR
1
FORWARD
FORWARD
FORWARD
2
SMOOTH TURN RIGHT  
FORWARD
STOP
3
SMOOTH TURN LEFT  
STOP
FORWARD
4
STOP OR START
STOP OR FORWARD
STOP OR FORWARD
5
STOP OR START
STOP OR FORWARD
STOP OR FORWARD
6
SHARP RIGHT TURN
FORWARD
REVERSE
7
SHARP LEFT TURN
REVERSE
FORWARD
8
ANTINODE DETECT
STOP OR FORWARD
STOP OR FORWARD


  • For simplicity here speed control is not disscussed. You can do that using Enable pin and analogWrite(pin number, 0-255) in arduino codes.
  • Codes to the line follower bot is in next blog.



LINE FOLLOWER PART 2: MOTOR DRIVER

LINE FOLLOWER PART 2: MOTOR DRIVER

Coming to the second part of our discussion and thats the motor driver. So the motor driver is basically an electronic circuit that drives/control the motor by controlling the voltage across the terminal. It can move the motor(DC motors) back and forth with a variable speed range.

TYPES OF MOTOR DRIVER

1. L293D BASED
* It is cheaper,lesser components, does not require a heat sink.
Description
* 600mA OUTPUT CURRENT CAPABILITY PER CHANNEL
* 1.2A PEAK OUTPUT CURRENT (non repetitive) PER
* CHANNEL ENABLE FACILITY
* OVER TEMPERATURE PROTECTION
* LOGICAL "0" INPUT VOLTAGE UP TO 1.5 V (HIGH NOISE IMMUNITY)



2.L298D BASED  
* Its comparatively costlier,needs heat sink, more current carrying capacity.
Description
The LN298 is a high voltage, high current, dual full-bridge motor driver designed to accept standard TTL logic levels and drive inductive loads such as relays, solenoids, DC and stepping motors.
- Operating supply voltage of up to 46V
- 4.5-7VDC logic supply voltage
- Total DC current of up to 4A
- Over-temperature protection
                                                      - Logical ‘0’ input up to 1.5V (high-noise immunity)
PINS LAYOUT IN MOTOR DRIVERS
Power pins- through which power is feeded in. These are VCC+ and GND- . 12V input is given to it.
Motor outputs pins- outputs to the motors are given through this.
ENA, ENB(enable A,B) - It works as enable to circuit and also speed control for the motors. It regulates the voltage from 0-12V with logical signal of 0-5V input from arduino.
Pins A1,A2 and B1,B2- these and used for controlling the direction of the motor.
A1
A2
ACTION
LOW
LOW
NO ACTION
LOW
HIGH
FORWARD
HIGH
LOW
BACKWARD
HIGH
HIGH
STOP

Similar action can be used for motor B.

CHOICE OF MOTOR
BO MOTOR STRAIGHT
BO MOTOR L-SHAPED
Centre shaft DC geared motor or plastic motor (B.O.motor) works fine with line follower.
 THANK YOU FOR READING THE BLOG.....