Electronic Dice Using Arduino

Description

It is Electronic Dice Game Using Arduino. It is basic arduino learning project that shows how we access arduino pins for writing. Like in basic arduino LED flasher

Circuit Diagram

In circuit diagram 7 LEDs are connected each with 220 Ohm resistor in series to arduino.

Detail

It is a game in which we press button connected to pin 6 of arduino. When button is pressed different patterns of dice game are produces in fast speed. And when we release this button a random pattern is selected and shown on LEDs. This is simple example in which we generate random number from 1 to 6 range and display this number on LEDs.

Software

Arduino program is simple but lengthy. It first set pin mode for button/key as input with internal pullup resistor enabled and for LEDs as outputs. Initially displays 1 on LEDs. Calls srand() function for random number generation. This function is called once. Then in loop() function when key is pressed it generates random numbers from 1 to 6 range and display on LEDs. When key is released random number generation is stopped and final number is displayed on LEDs. Here is program


#include <stdlib.h>

// Define macro or formulae for random number
// generation from 1 to 6.
#define GetRandomNumber() ((rand() % 6) + 1)

void Display(char Value);
void turnOffAllLeds();

const int Switch = 6;

const int Led1 = 7;
const int Led2 = 8;
const int Led3 = 9;
const int Led4 = 10;
const int Led5 = 11;
const int Led6 = 12;
const int Led7 = 13;

void setup() {
  // put your setup code here, to run once:
  pinMode(Switch, INPUT_PULLUP);
  pinMode(Led1, OUTPUT);
  pinMode(Led2, OUTPUT);
  pinMode(Led3, OUTPUT);
  pinMode(Led4, OUTPUT);
  pinMode(Led5, OUTPUT);
  pinMode(Led6, OUTPUT);
  pinMode(Led7, OUTPUT);

  // Turn off all Leds.
  //turnOffAllLeds();
  Display(1);
  srand(50);
}

void loop() {
  char randomNumber;
  // put your main code here, to run repeatedly:
  while(digitalRead(Switch));
  while(!digitalRead(Switch))
  {
    // Generate random number.
    randomNumber = GetRandomNumber();

    // Display this random number
    // on Leds.
    Display(randomNumber);
    // Give some delay.
    delay(10);
  }
    // Generate random number last time.
    randomNumber = GetRandomNumber();
    // Finally display this number on LEDs.
    Display(randomNumber);
}

void turnOffAllLeds()
{
  digitalWrite(Led1, HIGH);
  digitalWrite(Led2, HIGH);
  digitalWrite(Led3, HIGH);
  digitalWrite(Led4, HIGH);
  digitalWrite(Led5, HIGH);
  digitalWrite(Led6, HIGH);
  digitalWrite(Led7, HIGH);
}

// This function displays an integer value from
// 0 to 6 on LEDs.
void Display(char Value)
{
  // Switch off all LEDs.
  //Led1 = Led2 = Led3 = Led4 = Led5 = Led6 = Led7 = 1;
  turnOffAllLeds();
  switch(Value)
  {
  case 1:
    digitalWrite(Led4, LOW);
    break;
  case 2:
    digitalWrite(Led1, LOW);
    digitalWrite(Led7, LOW);
    break;
  case 3:
    digitalWrite(Led1, LOW);
    digitalWrite(Led4, LOW);
    digitalWrite(Led7, LOW);
    break;
  case 4:
    digitalWrite(Led1, LOW);
    digitalWrite(Led3, LOW);
    digitalWrite(Led5, LOW);
    digitalWrite(Led7, LOW);
    break;
  case 5:
    digitalWrite(Led1, LOW);
    digitalWrite(Led3, LOW);
    digitalWrite(Led4, LOW);
    digitalWrite(Led5, LOW);
    digitalWrite(Led7, LOW);
    break;
  case 6:
    digitalWrite(Led1, LOW);
    digitalWrite(Led2, LOW);
    digitalWrite(Led3, LOW);
    digitalWrite(Led5, LOW);
    digitalWrite(Led6, LOW);
    digitalWrite(Led7, LOW);
    break;
  }
}


Thermometer Using LM35D Arduino And LCD

Description

It is a LCD Thermometer Using Arduino and LM35D temperature sensor. It shows temperature on 16×2 LCD in degree centigrade.

Circuit Diagram

In circuit diagram 16×2 LCD is connected to arduino. LM35D is connected to analog channel input of arduino.

Detail

LCD is connected in conventional 4 bit mode and LM35D temperature sensor is connected to first analog input channel of arduino. LM35D gives analog output corresponding to temperature. When temperature of environment changes it’s output voltages also changes. It gives 10mv per degree centigrade, means if output of LM35D is 10mv then surrounding temperature will be 1 degree centigrade. If output changes to 100mv then surrounding temperature will be 10 degree centigrade. Our arduino program reads this voltage level and converts it into corresponding temperature value. And then displays this value on 16×2 LCD in centigrade.

Software

#include <LiquidCrystal.h>

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

// Define analog pin where
// LM35D is connected.
const int LM35DPin = A0;

void setup() {
  // put your setup code here, to run once:

  // Setup LCD
  lcd.begin(16, 2);

  lcd.print("Temperature");

}

void loop() {
  // put your main code here, to run repeatedly:
  float temperature = analogRead(LM35DPin);
  temperature = temperature * 5000;
  temperature /= 10240;
  lcd.setCursor(0,1);
  lcd.print(temperature);
  lcd.print((char) 223);
  lcd.print('C');
  delay(300);
}

PC Serial RS232 Interface With Arduino

Description

It is serial RS232 Port interface example with Arduino. Serial Port is a channel for communication with microcontroller/arduino.

Circuit Diagram

Circuit diagram is simple and there is no need of extra component. All hardware interface between arduino microcontroller and PC is already provided in arduino board. Here is simple diagram in proteus to use with serial terminal in proteus.

Detail

Serial port is used to communicate with other devices like microcontrollers and PCs. It is most commonly used method for communication between arduino and computer. In serial RS232 interface all data bits are transmitted and received one bit at a time in a stream. So there is series of bits on single wire/pin. In arduino serial port is implemented over USB. There is USB to serial converter device required between arduino microcontroller and PC that is already implemented in arduino board. So, there is no need to add it additionally. This project is the base for so many other projects.

Software


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.write("Started...");

}

void loop() {
  // put your main code here, to run repeatedly:
  if(Serial.available())
  {
    Serial.write(Serial.read() + 2);
  }

}

In software setup() function we first initialize serial channel at 9600 bits/sec. Then we send “Started…” string towards PC. You can see how this “Started…” string is received in terminal in proteus shown in above diagram. You will also see next in video that how this string “Started…” is received in PC. In loop() function we check that if any received character is available? then read this character add 2 to it and send back towards PC.
Here is video for further clarification.

20170601_161518 from Rashid Mehmood on Vimeo.

16×2 LCD Interface With Arduino

Today I am going to tell you how to interface 16×2 LCD with Arduino.

Circuit Diagram

LCD

Display has very importance in embedded systems. It is used to interact humans with system. Instructions and device function results are shown on displays. Without display we cannot see what operation is being performed inside the arduino/microcontroller. LCDs are most widely used in embedded systems to provide user interface. In this example I am using HD44780 based 16×2 LCD. This LCD can be interfaced using 8 bit or 4 bit mode. In 8 bit mode all 8 data pins are used while in 4 bit mode only 4 pins of LCD are used. In this project I have used 4 bit mode of operation. 16×2 means it has 16 columns and 2 rows. HD44780 controller is installed on other sizes of LCDs like 16×1, 16×4, 20×2, 20×4 etc.

LCD.jpg
Click to Enlarge

Pin-Out

Pin Symbol Function
1 Vss ground (0 V)
2 Vdd power (4.5 – 5.5 V)
3 Vo contrast adjustment
4 RS H/L register select signal
5 R/W H/L read/write signal
6 E H/L enable signal
7-14 DB0 – DB7 H/L data bus for 4- or 8-bit mode
15 A (LED+) backlight anode
16 K (LED-) backlight cathode

We can read & write data to LCD but to keep things simple we have hardwired R/W line to ground for only writing. It means we can only print on LCD but cannot read back content written in LCD RAM.

Software

In arduino we use builtin library for LCD interfacing “LiquidCrystal.h”. And this makes LCD interfacing with arduino simple and easy.

#include <LiquidCrystal.h>

// Define object of LiquidCrystal class.
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

void setup() {
  // put your setup code here, to run once:
  lcd.begin(16, 2);

  // Print welcome message
  // to LCD.
  lcd.print("Welcome!");
  
  // Set cursor to next line and 
  // first column.
  lcd.setCursor(0,1);
  
  lcd.print("micro-digital.net");

}

void loop() {
  // put your main code here, to run repeatedly:

}

Led Flasher With Arduino

It is simple and basic arduino project. You can say it welcome/hello world project in arduino programming. In this project I will first blink on board LED of arduino and then will use off board LED.

Blinking On Board Arduino LED

Arduino is a prototyping board for embedded systems development. In this example I am using Arduino UNO board. In this board ATMega328 microcontroller is installed. On board arduino LED is connected to pin number 13. Here is the circuit with off board LED.

What Will You Need

For on board LED you need only

  1. 1 x Arduino Board
  2. 1 x USB Cable
  3. 1 x Computer with Arduino IDE installed

For off board LED you need some more parts

  1. 1 x Bread Board
  2. 1 x LED
  3. 1 x 150 Ω Resistor
  4. 3 x Jumper Wires

Software


// Define pin 13 as LED pin
const int LED = 13;

void setup() {
  // put your setup code here, to run once:

  // Set LED pin as output.
  pinMode(LED, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:

  // Set LED pin at high/5V level.
  digitalWrite(LED, HIGH);
  // Delay for 500 ms.
  delay(500);
  // Set LED pin at low/0V level.
  digitalWrite(LED, LOW);
  // Delay for 500 ms.
  delay(500);
}

Transformer Designer


Transformer-Designer
This app is for transformer designing calculations. Transformers are widely used in our electrical applications to step down or step up AC voltage. These are used in power supplies, stabilizers, inverters, converters, UPS and so many other applications. This app is complete solution especially for 2 winding transformer. This app helps transformer designers to find out different transformer parameters. These parameters are

  1. Turn/Volt
  2. Turns for each coil
  3. SWG/AWG Wire for each coil with actual rate (cmils/A)
  4. Core Area for bobbin selection

During transformer design we need to know core area of transformer for the selection of bobbin. We want to calculate turns/volt so that we can calculate total turns for each coil. For each different coil different SWG/AWG wire is needed. We have to decide how much thick wire will be able to carry required amount of charge through it. Wires are divided according to their thickness/area of cross section. Each wire is assigned a number according to Standard Wire Gauge (SWG) or American Wire Gauge (AWG). This number is called SWG or AWG number of that wire. We know, a thick wire will be able to carry more charge than a thin wire. Here, I have considered circular mils (cmils) as unit of cross sectional area measurement.

This app is helpful in transformer winding, power supplies, inverters, converter and UPS development and sales business. Now, if you are a transformer designer/winder this app is for you. You can install it from here.

Transformer-Designer

How It Works?

Let us consider we want a transformer for our LED sign board supply. LED sign board needs almost 12V and 4A supply. Considering other factors like temperature, we decide to design a transformer for 12V and 5A. Now, run this app and first enter 1 number of output coils like shown in the following figure and press “Next”.

transformer-designer-0.png

Now, enter VA, Voltage and/or Current values as shown in the following figure. Here you have to enter first and the only output coil’s power requirement. Enter any two of the values and leave single value empty. If you entered all three values then app will calculate third according to left to right order means it will calculate “Current” value by dividing “VA” by “Voltage”. After this press “Next”.

transformer-designer-1.png

Now, enter number of input coils. Here, in our example this is 1.

transformer-designer-2.png

Here, enter “Voltage” or “Current” value of input coil but not both as total VA of transformer are calculated according to output coils and is shown in the following figure.

transformer-designer-3.png

Now, enter value of Rate. In open air wires remain cool and can pass charge at more rate means with less cross sectional area a wire can pass more charge and so more current. But, when we use same wire in transformer/coil winding where wires are wound in layers, one layer over other and there is no air present between these layers but there is paper between them, so wires fail to get cool due to air, their charge passing capability is reduced and so, can pass charge at lower rates. Usually, we double rate (area) in transformers than in open air. We use 500/530 cmils/Amp value or more for transformers. There are so many other factors that affect this value, some of which are temperature, peak load time, working duration of machine per day etc. So, you have to choose better value of Rate considering all these factors. Here, we enter 530 cmils/A. Enter flux density of core used in weber per square inch. Default value for silicon core is 0.0006 weber per square inch. This app is optimized for silicon core. You can use other cores and do experiment. Finally, enter frequency of input voltage. In my country it is 50 Hz. Press “Next” to continue

transformer-designer-4.png

Now, here results are calculated.

transformer-designer-5.png

Here for each output and input coil following parameters are calculated

  1. VA and/or Voltage and/or Current
  2. Turns for coil
  3. 2 SWG numbers with actual rate (in cmils/A)
  4. 2 AWG numbers with actual rate (in cmils/A)

First SWG is safe SWG and second is calculated for your ease if it is with acceptable rate for you. Because this value also depend some other factors like how long transformer will be operated without resting and surrounding temperature etc. Usually we choose between 500 cmils/A and 530 cmils/A. Similarly, 2 AWG numbers are calculated. First is safe and second may or may not be safe for you. Now, scroll and see other parameters

transformer-designer-6.png

At the end there are some other parameters of transformer like

  1. Total VA of transformer
  2. Turn/Volt
  3. Core Area
  4. Selected Rate value
  5. Frequency and
  6. Flux Density of core
transformer-designer-7.png

Install this app from Google Play. Enjoy! this app.

Transformer-Designer

Disclaimer

We have designed this app at our best. We have tested it so many times but use it at your own risk. We will not responsible for any kind of loss in any form due to this app. If you find any bug or defect then please inform us at udigital.solutions@gmail.com. If you have a mind blowing idea of an app you can also share with us at this email.

Transformer Winding Calculator

Transformer-Winding-Calculator-00.jpg

This app can calculate SWG/AWG wire number for your transformer coil and turns per volt to calculate total turns of coil.

During transformer/ciol design we have to decide how much thick wire will be able to carry required amount of charge through it. Wires are divided according to their thickness/area of cross section. Each wire is assigned a number according to Standard Wire Gauge (SWG) or American Wire Gauge (AWG). This number is called SWG or AWG number of that wire. We know, a thick wire will be able to carry more charge than a thin wire. Here, I have considered circular mils (cmils) as unit of cross sectional area measurement.

Now, there is no need to look up a table/chart against your required value of current for wire selection. This smart app will do this work for you.

How It Works?

SWG/AWG Calculation

It takes two values as input. First is Current that has to be passed through wire, so wire should be able to carry this value of current. Second value is Rate circular mils per ampere.
It generates two output values as well. First and third are SWG and AWG number of wires that are safe for given value of current and it’s actual rate. Second and forth values are the SWG and AWG numbers of next wires that may be or may be not near the required wire with it’s actual rate. You can decide yourself which SWG/AWG wire will be better for your current requirement.

transformer-winding-calculator-0.png

First enter value of Current.

transformer-winding-calculator-1.png

Now, enter value of Rate. In open air wires remain cool and can pass charge at more rate means with less cross sectional area a wire can pass more charge and so more current. But, when we use same wire in transformer/coil winding where wires are wound in layers, one layer over other and there is no air present between these layers but there is paper between them, so wires fail to get cool due to air, their charge passing capability is reduced and so, can pass charge at lower rates. Usually, we double rate (area) in transformers than in open air. We use 500/530 cmils/Amp value or more for transformers. There are so many other factors that affect this value, some of which are temperature, peak load time, working duration of machine per day etc. So, you have to choose better value of Rate considering all these factors.

transformer-winding-calculator-2.png

Now, you press “CALCULATE” button and results will be shown to you as in the following figure.

transformer-winding-calculator-3.png

Turn Per Volt Calculation

First enter area of core in square inches.

transformer-winding-calculator-4.png

Now, enter flux density of core used in weber per square inch. Default value for silicon core is 0.0006 weber per square inch. This app is optimized for silicon core. You can use other cores and do experiment.

transformer-winding-calculator-5.png

Enter value of frequency in hertz. Default value is 50 Hz.

transformer-winding-calculator-6.png

Now, press calculate button below frequency field and app will show result as shown in the following figure.

transformer-winding-calculator-8.png

Download this app from Google Play. Enjoy! this app.

Disclaimer

We have designed this app at our best. We have tested it so many times but use it at your own risk. We will not responsible for any kind of loss in any form due to this app. If you find any bug or defect then please inform us at udigital.solutions@gmail.com. If you have a mind blowing idea of an app you can also share with us at this email.

Wire Gauge Calculator Pro

Wire-Gauge-Calculator-Pro.jpg

During transformer/ciol design we have to decide how much thick wire will be able to carry required amount of charge through it. Wires are divided according to their thickness/area of cross section. Each wire is assigned a number according to Standard Wire Gauge (SWG) or American Wire Gauge (AWG). This number is called SWG or AWG number of that wire. We know, a thick wire will be able to carry more charge than a thin wire. Here, I have considered circular mils (cmils) as unit of cross sectional area measurement.

Now, there is no need to look up a table/chart against your required value of current for wire selection. This smart app will do this work for you.

How It Works?

It takes two values as input. First is Current that has to be passed through wire, so wire should be able to carry this value of current. Second value is Rate circular mils per ampere.
It generates two output values as well. First and third are SWG and AWG number of wires that are safe for given value of current and it’s actual rate. Second and forth values are the SWG and AWG numbers of next wires that may be or may be not near the required wire with it’s actual rate. You can decide yourself which SWG/AWG wire will be better for your current requirement.

wire-gauge-calculator-pro-1.png

First enter value of Current.

wire-gauge-calculator-pro-2.png

Now, enter value of Rate. In open air wires remain cool and can pass charge at more rate means with less cross sectional area a wire can pass more charge and so more current. But, when we use same wire in transformer/coil winding where wires are wound in layers, one layer over other and there is no air present between these layers but there is paper between them, so wires fail to get cool due to air, their charge passing capability is reduced and so, can pass charge at lower rates. Usually, we double rate (area) in transformers than in open air. We use 500/530 cmils/Amp value or more for transformers. There are so many other factors that affect this value, some of which are temperature, peak load time, working duration of machine per day etc. So, you have to choose better value of Rate considering all these factors.

wire-gauge-calculator-pro-3.png

Now, you press “CALCULATE” button and results will be shown to you as in the following figure.

wire-gauge-calculator-pro-4.png

Download this app from Google Play. Enjoy! this app.

Disclaimer

We have designed this app at our best. We have tested it so many times but use it at your own risk. We will not responsible for any kind of loss in any form due to this app. If you find any bug or defect then please inform us at udigital.solutions@gmail.com. If you have a mind blowing idea of an app you can also share with us at this email.

Some of Our Efforts in Traffic Signals and Displays

GSM Based Scrolling Message Display

Following is the video of GSM Based Scrolling Message Display developed by Micro Digital. It was installed in Islamabad at 10 different locations including Zero Point, Shakar Parian and Way To Daman-e-Koh in 2008. This display was operated remotely through SMS and public informational messages/news were played on them.

Some more scrolling message display products with new exiting features are in development process that will be posted on our site in near future.

16×1.5 Inch Display from Rashid Mehmood on Vimeo.

First Traffic Signal Controller By Micro Digital

Here are the videos of our first traffic signal controller. It’s copies were installed at Jehlum Main Chowk on GT-Road, Kohat and some in Peshawar.

Traffic Signal-0 from Rashid Mehmood on Vimeo.

Traffic Signal-1 from Rashid Mehmood on Vimeo.

Pedestrian Road Crossing Signal

Following is an imported Pedestrian Road Crossing Signal.

Pedestarian Road Crossing Signal-0 from Rashid Mehmood on Vimeo.

Pedestarian Road Crossing Signal-1 from Rashid Mehmood on Vimeo.

Large Size Digital Clock For Stadium

Following is the video of large size digital clock to be installed in stadiums/university gates etc. 7 Segment used in this clock is same as we use in traffic signal count down meter.

Stadium Clock from Rashid Mehmood on Vimeo.

Categories Uncategorized

Home Device Control Over Bluetooth Using Android

Home-Device-Control-Over-Bluetooth-01.jpg

Now, control of your appliances will be at your finger tips. Using this app you can control your appliances (lights, fans, heaters etc) from your android phone remotely over bluetooth connection. If your are a professional or a student of electrical/electronics engineering and can develop arduino based circuits then you can use this free app.

You can download this free app from here.

Home Device Control Over Bluetooth-0 from Rashid Mehmood on Vimeo.

Development of Hardware

A hardware developed on arduino open source platform is connected over bluetooth with this app. Hardware has the functionality of switching high voltage devices like fans, energy savers, tube lights and heaters etc. You can change hardware according to your device power consumption requirements. Large size relays will be required for heavy loads. As there are high voltages involved so be careful during development and use of hardware. We will not be responsible for any kind of damage/loss in any form by using this app and hardware.

Hardware is no more complex and you can develop it easily if you have developed basic electronics circuits and can understand electronic schematic diagrams. Here is the schematic diagram of hardware.

Arduino Code (Free Download)

Here is the arduino source for above hardware.

Home_Device_Control_Over_Bluetooth.rar

How It Works?

Here is the main screen of app showing paired devices. Before you connect to remote hardware you have to perform pairing. In this project HC-05 bluetooth module is used. Default pin code for HC-05 bluetooth module is “1234”. This pin will be required during pairing process. Paired devices will be shown in this screen. And then select your hardware from the list. Here “HC-05” is representing our hardware.

Home-Device-Control-Over-Bluetooth-0.png

Now, our app will try to connect to remote arduino hardware and will show connection status and will also show appliances current status (on/off) as in the following figure.

Home-Device-Control-Over-Bluetooth-1.png

Now, we can tap to turn on/off a device. In the following figure we have turned off 2 lights.

Home-Device-Control-Over-Bluetooth-2.png

Following figure is showing status of fans that we can also switch on/off.

Home-Device-Control-Over-Bluetooth-3.png

In the following figure, status of on and off lights is shown.

Home-Device-Control-Over-Bluetooth-4.png

In the following figure, status of on and off fans is shown.

Home-Device-Control-Over-Bluetooth-5.png

Download this app from Google Play. Enjoy! this one more free app.

More Videos

VID-20160224-WA0002 from Rashid Mehmood on Vimeo.

VID-20160224-WA0007 from Rashid Mehmood on Vimeo.

Disclaimer

We have designed this app at our best. We have tested it so many times but use it at your own risk. We will not be responsible for any kind of loss in any form due to this app. If you find any bug or defect then please inform us at udigital.solutions@gmail.com. If you have any suggestions please, email us. We will be happy to hear from you.