Seven segment display counter

A seven segment display is typically used to display numbers from 0-9. It consists of 7 bar segments and a dot( 8 Segments). They are numbered A to F and DP for the dot or decimal place. There are 2 types of 7 Segment display

  • Common anode
  • Common cathode

 

Seven Segments are labelled as below.

For more detail on 7 segment display refer my blog post on it here.

To display number we need to turn on the correct segments as shown below:

0- ABCDEF
1- BC
2- ABGED
3- ABCDG
4- BCFG
5- ACDFG
6- ACDEFG
7- ABC
8- ABCDEFG
9- ABCFG

List of Parts needed

  1. Common cathode seven segment LED display
  2. 470 Ohm resistors – 7 nos
  3. Arduino UNO

Schematic diagram:

Seven Segment counter

 

Below is the code for the one digit counter

//Pins for seven segment
int sega = 1;
int segb = 2;
int segc = 3;
int segd = 4;
int sege = 5;
int segf = 6;
int segg = 7;
int dispa = 8;
int dispb = 9;

void setup() {
 // Setup code to run once
   pinMode(sega,OUTPUT);
   pinMode(segb,OUTPUT);
   pinMode(segc,OUTPUT);
   pinMode(segd,OUTPUT);
   pinMode(sege,OUTPUT);
   pinMode(segf,OUTPUT);
   pinMode(segg,OUTPUT);
   pinMode(dispa,OUTPUT);
   pinMode(dispb,OUTPUT);
}

void loop() {
 // put your main code here, to run repeatedly:
  for(int count=0;count<10;count++)
  {
    digitalWrite(sega,LOW);
    digitalWrite(segb,LOW);
    digitalWrite(segc,LOW);
    digitalWrite(segd,LOW);
    digitalWrite(sege,LOW);
    digitalWrite(segf,LOW);
    digitalWrite(segg,LOW);
    if(count==0){
     digitalWrite(sega,HIGH);
     digitalWrite(segb,HIGH);
     digitalWrite(segc,HIGH);
     digitalWrite(segd,HIGH);
     digitalWrite(sege,HIGH);
     digitalWrite(segf,HIGH);
  }
  if(count==1){
    digitalWrite(segb,HIGH);
    digitalWrite(segc,HIGH);
  }
  if(count==2){
    digitalWrite(sega,HIGH);
    digitalWrite(segb,HIGH);
    digitalWrite(segg,HIGH);
    digitalWrite(sege,HIGH);
    digitalWrite(segd,HIGH);
  }
  if(count==3){
    digitalWrite(sega,HIGH);
    digitalWrite(segb,HIGH);
    digitalWrite(segc,HIGH);
    digitalWrite(segd,HIGH);
    digitalWrite(segg,HIGH);
  }
  if(count==4){
    digitalWrite(segb,HIGH);
    digitalWrite(segc,HIGH);
    digitalWrite(segf,HIGH);
    digitalWrite(segg,HIGH);
  }
  if(count==5){
    digitalWrite(sega,HIGH);
    digitalWrite(segc,HIGH);
    digitalWrite(segd,HIGH);
    digitalWrite(segf,HIGH);
    digitalWrite(segg,HIGH);
  }
  if(count==6){
    digitalWrite(sega,HIGH);
    digitalWrite(segc,HIGH);
    digitalWrite(segd,HIGH);
    digitalWrite(sege,HIGH);
    digitalWrite(segf,HIGH);
    digitalWrite(segg,HIGH);
  }
  if(count==7){
    digitalWrite(sega,HIGH);
    digitalWrite(segb,HIGH);
    digitalWrite(segc,HIGH);
  }
  if(count==8){
    digitalWrite(sega,HIGH);
    digitalWrite(segb,HIGH);
    digitalWrite(segc,HIGH);
    digitalWrite(segd,HIGH);
    digitalWrite(sege,HIGH);
    digitalWrite(segf,HIGH);
    digitalWrite(segg,HIGH);
  }
  if(count==9){
    digitalWrite(sega,HIGH);
    digitalWrite(segb,HIGH);
    digitalWrite(segc,HIGH);
    digitalWrite(segf,HIGH);
    digitalWrite(segg,HIGH);
  } 
  delay(1000);
 }
}

 

Web server on raspberry pi – how to setup?

Introduction

In this post I will let you know how to set up web server on raspberry pi. There are many web servers for raspberry pi. In out example we will be setting up apache web server. Apache is a popular web server application and we will install it on raspberry pi to server web pages

 Step 1 -Install APACHE

First install apache 2 package by using the following command in to the terminal

sudo apt-get install apache2 -y

 Step 2 – Test the Web Server

By default, Apache puts a test HTML file in the web folder. This default web page is served when you browse to http://localhost/ on the Pi itself, or http://192.168.1.9 ( IP address of Pi) from another computer on the network.

Browse to the default web page either on the Pi or from another computer on the network and you should see the following:

default_html_page

This means you have Apache working!

Step 3 – Changing the default Page

This default web page is just a HTML file on the filesystem. It is located at /var/www/index.html.

Navigate to this directory in the Terminal and have a look at what’s inside:

cd /var/www/html

ls -al

This will show you:

step3_htme_page_location

Step 4- Install Php

To allow your Apache server to process PHP files, you’ll need to install PHP5 and the PHP5 module for Apache. Type the following command to install these:

 sudo apt-get install php5 libapache2-mod-php5 -y

Now remove index.html file and add index.php with following content

<?php echo "hello world"; ?>
<?php echo date('Y-m-d H:i:s'); ?>
<?php phpinfo(); ?>

Now open the index.php page. You will get following:

dynamic_php_page

You are now done setting up web server on raspberry pi which can server dynamic pages.

In the next post we will use this web server to post real time data from arduino/raspberry pi and also control different appliances from the web page.

Plus/minus supply using LMC7660

LM 7660 is a CMOS voltage convertor capable of converting a positive voltage in the range of +1.5 v – 10 v to the corresponding negative voltage of -1.5v to -10v using very few external components. Below is the schematic diagram for the same.

We can use this get +/-5v from different sources like from 9v battery. Adding LM7805 converter to a 9v battery or 9v power supply will reduce it to 5v as shown below.

Components

  • IC1 – LMC7660
  • IC2 – LM7805
  • C1,C2 – 10μF 16V
  • C3 – 470 μF 25V
  • C4 – 2.2μF 16V
  • Battery – 9v

 

Bicycle USB Charger

This circuit has been developed to add a USB charging port to a bicycle for charging a mobile phone. The input supply for the circuit is produced by a dynamo (6V, 3W dynamo) in the bicycle.

The circuit is based on LM2596-5.0. It is a 3A step down voltage regulator. LM 2596 are available in fixed output voltage of 3.3, 5, 12v and an adjustable output version. The LM2596 series operates at a switching frequency of 150 kHz, thus allowing smaller-sized filter components than what would be needed with traditional lower-frequency switching regulators. The IC provides all active functions for a step-down (buck) switching regulator, capable of driving a 3A load with excellent line and load regulation.

Circuit & Part list

  • C1        1000uf
  • C2        470 uf
  • D1-D2        1N5818
  • D5        1N5818
  • J        Dynamo 6v 3W
  • L        33 u
  • LED
  • R          1k
  • SW        1 on/off switch
  • IC        LM2596
  • USB-A Connector

How it Works?

The alternating voltage generated by the dynamo is converted to DC by a full-wave bridge rectifier comprising Schottky barrier rectifier diodes D1 through D4 and a filtering electrolytic capacitor (C1). The output of the bridge rectifier, which is charged to peak value of AC voltage (nearly 10V), is input to switching regulator LM2596-5.0 to provide a regulated 5V (DC) output, which is suitable for charging mobile devices using the USB connector.

The 5mm LED (LED1) in the circuit indicates output status. Feedback connection FB (pin 4 on IC1) is connected directly to output voltage at electrolytic capacitor C2. The 33μH inductor (L1) should be rated for a DC current of at least 1A. The dynamo output is connected to the circuit by switch S1.

Light Sensor using Arduino

Introduction

In this project, a simple light sensor is designed using LDR. The project is built around Arduino.

Components required

  • Arduino UNO
  • Light Dependent Resistor (LDR)
  • 100 KΩ POT
  • Buzzer

Circuit Diagram

Working

A 100 KΩ POT and the LDR form a voltage divider and the output of the voltage divider is given to the analog input A0 of Arduino. A buzzer is connected to pin 11 of Arduino.

When the LDR detects a light over certain intensity, the Arduino will trigger the buzzer. When the intensity of light decreases, the buzzer is turned off.

The 100 KΩ POT used in the voltage divider network can be used to adjust the intensity levels at which the buzzer is triggered.

Code

int sensorPin = A0; // select the input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
Serial.begin(9600);
pinMode(11,OUTPUT);
}
void loop()
{
sensorValue=analogRead(sensorPin);
if(sensorValue <= 14)
digitalWrite(11,HIGH);
else
digitalWrite(11,LOW);
Serial.println(sensorValue);
delay(2);
}

This circuit is similar to dark sensor circuit using BC547 transistor.

What is Omega 2 Board?

Omega 2 board is the development boards from Onion. It comes packed with built-in Wi-Fi and on-board flash storage. You do not have to worry about buying Wi-Fi dongles or installing operating system images onto external SD cards.

Using the Omega2 is just like using a desktop computer. It has built simple and intuitive apps  to interact with the Omega2. It also have an App Store where you can discover even more apps. The Omega2 runs the Linux Embedded Development Environment (LEDE) operating system, a distribution based on OpenWRT.  You can think of the Omega2 as a tiny Linux server with Wi-Fi.

The Omega2 can be easily added to your existing Arduino projects. Another important benefit of running Linux is that the Omega2 can be programmed with whatever language you want.

Omega 2 Specs

Memory64MB Memory
Storage16MB Storage
USBUSB 2.0
MicroSD Slot
No
WiFi adapterb/g/n Wi-Fi
GPIOs15
PWM2
UART2
I2C1
SPI1
I2S1

Pin out

Omega2 Accessories

 

Expansion Docs

The Expansion Dock powers the Omega2, it breaks out all of the GPIOs, and allows you to expand your Omega2 with expansion modules. It has a USB-to-serial chip on-board, allowing you to access the Omega2 easily through the serial terminal.

Mini Dock

The Mini Dock provides power to the Omega2, and it allows you to plug in USB devices

 Power Dock

Arduino Dock

 

 

UI Automation using Appium and WinAppDriver

Introduction to Appium

Appium is an open source cross platform test automation framework for use with native, hybrid and mobile web apps. It drives iOS, Android, and Windows apps using the WebDriver protocol. Platforms supported are:

  •  iOS
  • Android
  • Windows
  • FirefoxOS

Step 1: Installing Appium in Windows machine

npm install -g appium  // get appium
npm install wd   // get appium client
appium &         //Start appium

Appium install

Note: Appium will install WindowsAppDriver automatically.

You can explicitly install WindowsAppDriver.exe from 

https://github.com/Microsoft/WinAppDriver/releases

Step 2: Writing your Test code( classic Windows app)

You can use any Selenium supported language and specify the full executable path for the app under test in the app capabilities entry. In my example I will be using C#.

Following is a sample code to create test session for Windows Notepad.

 If you are using Appium as mentioned in Step 1, do not forget to add /wd/hub in ur URL.

You can get the complete sample project at my Github site.

namespace NotepadExample
{
    [TestClass]
    public class NotepadBase
    {
        // Note: append /wd/hub to the URL if you're directing the test at Appium
        protected const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723/wd/hub";
        protected static WindowsDriver<WindowsElement> NotepadSession;

        [ClassInitialize]
        public static void NotepadBaseSetup(TestContext testcontext)
        {
            if (NotepadSession == null)
            {
               //launch the Notepad app
               DesiredCapabilities appCapabilities = new DesiredCapabilities();
               appCapabilities.SetCapability("deviceName", "WindowsPC");
               appCapabilities.SetCapability("app", @"C:\Windows\System32\notepad.exe");
               NotepadSession = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
            }
        }
        [TestMethod]
        public void TestMethod1()
        {
          NotepadSession.FindElementByClassName("Edit").SendKeys("This is an automated text......");
          Assert.IsNotNull(NotepadSession);
        }
        [ClassCleanup]
        public static void NotepadBaseTearDown()
        {
            if (NotepadSession != null)
            {
                NotepadSession.Dispose();
                NotepadSession = null;
            }
        }
    }
}

Using Appium you can write tests with any WebDriver compatible language such as Java, C#, Nodejs, PHP, Phython, Ruby or Perl With the Selenium WebDriver API. It removes limitation of Selenium by providing support to Windows based desktop applications.

Watch the video for easy reference.

 

How to install Linux on Windows 10 machine?

Introduction

This blog will show you how to install Linux on Windows 10 machine without dual boot option and partitioning your hard drive. In this method we will be using a software called Virtualbox from Oracle. It will allow you to run other operating systems on top of your current OS.  You can use any version of Linux. I will be using Ubuntu 16.04.2.

Following are the high level steps required to install Linux on Windows 10.

Steps Required To Install Linux On Windows 10

Step 1 - Downloads

  • Download Oracle Virtualbox and virtual box extension pack and install from here.
  • Download Linux from here

Step 2 - Creating Ubuntu virtual machine within Oracle Virtual box. 

Install Virtualbox and create a Ubuntu virtual machine

  • Click on the "New" option on the toolbar
  • Enter a descriptive name into the "Name" box
    • Select Linux as the "Type"
    • Choose Ubuntu as the "Version".
    • Click "Next" to continue.

Note:
Choose a correct version of UBUNTU i.e 32 or 64 bit.
If VirtualBox is only showing 32 bit versions in the Version list make sure:
▪ Your Host OS is 64-bits
▪ Intel Virtualization Technology and VT-d are both enabled in the BIOS
▪ The Hyper-V platform is disabled in your Windows Feature list.

  • Allocate Memory to the virtual machine. For Ubuntu16.04.2 2 GB is sufficient but you can allocate more if you have sufficient memory.
  • Create a virtual hard drive. Select default VDI as the hard drive type. Also while selecting physical disk, you can select fixed size or dynamically allocated size. Note that there is no partitioning on your actual hard disk. All that happens is that a file is created on your computer which acts as the hard drive.

Step 3 - Install Ubuntu within Virtual box

Start the Virtual Machine. The first boot requires you to select a start-up disk. You can mount the iso file downloaded earlier. Follow step by step process of installing. I will not cover the details of installing here.

Step 4 - Install Vbox Guest edition(optional)
Download and install Virtualbox Guest Additions
Installing guest editions will help you scale Ubuntu properly in full screen mode.