Controlling Servo Motor

Servo Sample Connectivity

In this blog post, I’ll show you how to control a servo motor with a UWP App installed on a Raspberry Pi 2, running Windows 10 IoT Core.

Step One:

You need to connect your Servo Motor to the Raspberry Pi 2 as show in scheme:

Servo Sample Scheme

Step Two:

Now, you should write the code that will control the servo motor, you will find the source code HERE
Clone this code, and you will find two methods: PWM_R() which will make the servo motor rotate to the right and PWM_L() which will make the servo motor rotate to the left.

and you’ll find also the event handler which will be invoked each time you press the push button.

 

And here’s a video of the result you should get:

Windows10 SplitView Control | Hamburger Menu

21In this blog, I’ll be talking about a new Xaml Control in Windows 10 which is “SplitView | Hamburger Menu” Control, and here’s an example in some apps in Windows 10

 

Note: if you didn’t get Windows 10 Developer Tools, you can check this Blog to get you ready.
So, Let’s Start building this in our upcoming Windows 10 Apps 😉 Continue reading

Simple OOP

OOP1What is OOP?

It refers to “Object-Oriented Programming”, OOP is a Design Philosophy/Programming Paradigm/Programming Methodology based on the concept of “objects“.

Before OOP

There was a procedure of programming was known as “Traditional/Procedural Programming“, e.g(C, Pascal, etc).

Traditional/Procedural Programming Disadvantages:

  • Difficult Maintenance
  • Slow Development

That’s why OOP came to us.

OOP Advantages

  • Re-usability
  • Fast Development
  • Organized Code allows Fast and Easy Maintenance

OOP Concepts

  • Objects and Classes
  • Encapsulation
  • Abstraction
  • Inheritance
  • Polymorphism

What is Object and Class?

Object:

An object can be considered a “thing” that can perform a set of related activities. And these activities define the Object’s Behavior.
e.g A hand is object, and it performs some activities like holding.

Class:

A class is a collection of objects of similar type.
Class is composed of three things: (Name, Attributes and Operations).

public class Customer
{
}
/*****************/
Customer object1 = new Customer();

This code demonstrates how to create a class which is Customer, and how to use this class by taking an Object which is object1.

 

Encapsulation

A set of elements have the same Properties and Behaviors collecting them together in one place which is Model.
Properties => Variables
Behaviors => Methods
Model => Class

That idea of encapsulation is to hide how a class does its business, while allowing other classes to make requests of it.

public class Person
{
    // Properties
    public string name;
    public string tall;
    // Method 
    public void Speak()
    {
        //Speaks
    }
}

Abstraction

Abstraction refers to the act of representing essential features without including the background details or explanations.
Classes use the concept of abstraction and are defined as a list of abstract attributes.
Storing data and functions in a single unit (class) is encapsulation.
Data cannot be accessible to the outside world and only those functions which are stored in the class can access it.

Inheritance

The ability of a new class to be created, from an existing class by extending it.
Inheritance provides reusability, like, adding additional features to an existing class without modifying it. This is achieved by deriving a new class from the existing one. The new class will have combined features of both the classes.

public class Vehicle
{
}
public class Car : vehicle
{
}

Car Class inherits from Vehicle Class, Which means that Car class will have all of the public properties and methods of Vehicle class, and also Car class can modify a specific implementation of a certain method in Vehicle class.

Polymorphism

Polymorphism is a generic term that means ‘many shapes’. More precisely Polymorphisms means the ability to request that the same operations be performed by a wide range of different types of things.

Polymorphisms is achieved by using two different techniques named method overloading and method overriding,

Method Overloading

The ability to define several methods all with the same name, but with different signatures.

public class Person
{
public void SetName(string lastName)
{
  //Implementation goes here
}
public string SetName(string firstName, string lastName)
{
  //Implementation goes here
}
}

The two methods here have the same name, but different signatures(No. of Parameters and Return type).

Method Overriding

Method overriding is a language feature that allows a subclass to override a specific implementation of a method that is already provided by one of its super-classes.


public class Person
{
    public virtual void SetName()
    {
        //Print "Person Name"
    }
}
public class Male : Person
{
    public override void SetName()
    {
        // Print "Male Name"
    }
}

To perform method overriding:

  • You have to use Inheritance
  • Method in Super-Class should have the keyword “virtual” to allow overriding

Finally, here’s a code sample demonstrating simply OOP LINK 😀

08 Decision Making

Hello in this post we will know more about Decision Making so let’s get started 🙂

Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.

Following is the general from of a typical decision making structure found in most of the programming languages:
Decision making

 

Continue reading

07 C# Operators

Hello everyone, last time in C# serious for beginners we talked about the Variables, Constants and Literals in C#
So, this time we are going to learn and know the C# Operators.

What is the Operator ?
An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.

What are the types/kinds of these Operators ?

  •  Arithmetic Operators: (+, *, /, -, %)
    Arthimetic
    Arthimetic Ex

  •  Relational Operators: (==, !=, >, >=, <. <=)
    Relational

    and here’s an Example on the Relational Operators:
    Relational Ex
  •  Logical Operators: (&&. ||, !)
    Logical

    and here’s an Example on the Logical Operators:
    Logical Ex
  •  Bitwise Operators: (&, |, ^, <<, >>, ~)
    Bitwise

    and here’s an Example on the Bitwise Operators:
    Bitwise Ex
  •  Assignment Operators: (=, +=, -=, *= … etc)
    Assignment

    and here’s an Example on the Assignment Operators:
    Assignment Ex

Continue reading

Using Bing Maps

Using Bing maps inside your app might be very important and amazing feature that rates up your app in the store so, let’s know how to add Bing Maps to your Windows Store App.

First of all you will need to install “Bing Maps for windows Store C#” from the following URL:
http://visualstudiogallery.msdn.microsoft.com/224eb93a-ebc4-46ba-9be7-90ee777ad9e1

Then, Go to this website and register to get a Bing Maps  Key (You will need it inside your App each time you use bing maps)
http://www.microsoft.com/maps/create-a-bing-maps-key.aspx

Select Basic Key, then click on “Get the Basic Key” (as shown)
b6

Then, follow the steps to register,

Continue reading