Sunday, 15 June 2014

MVP MSP student mentorship program

The MVP student mentorship program

The Microsoft Most Valuable Professional (MVP) Award is Microsoft's way of saying thank you to exceptional, independent community leaders who share their passion, technical expertise, and real-world knowledge of Microsoft products with others.   

The Microsoft MVP Mentor Program matches these MVPs with students from around the world who want to learn how to use Microsoft technologies through social mentoring, guided webinars, one to one mentoring, and much more.

In this post, I will be discussing about my experience as a MSP in MVP student mentorship program. Firstly, I would like to thank Kari Finn mam for allowing me for this wonderful opportunity. Mayur Tendulkar sir was assigned as my mentor. I would say that I was lucky enough to develop under him. My interests was windows phone and as Mayur sir excels in it, I was assigned with him. It will depend on the Microsoft technology you choose for the program. During my entire course of the program, I have developed 2 apps. I will surely mention about those apps later. You can also check out in the apps section from the tab.

The course of the program was of 3 months. Mayur sir equally divided those months on the basis of "Learning, Development, Corrections". I must say he was an awesome mentor especially when it came to presentation, management and development. It was sorted out that I would be publishing 3 apps in the Windows phone marketplace in due course but I published only 2 because of my exams and slightly ill health.

Talking about Mayur sir, I already mentioned that he was an awesome mentor. He always mentioned one point that I always tried to jump steps which infact was real. He guided me thoroughly through various sessions, meetings, screen casts etc. Every week we used to talk over skype and discuss the progress and also discuss about the future works. It was altogether a properly maintained sequential approach all credits to Mayur sir.

Lastly after the end of 3 months, officially the program was stopped but Mayur sir still guides me in my app development. I bet that once you apply for this program, you won't regret it. Trust me just go and apply. 

Below are the details of my developer account where you can find my apps.

Developer Name:    avirup171
Platform:                 Windows phone marketplace
Developer GUID:     c4c9a4bc-605e-4298-ae19-e276d5495c44

Sunday, 8 June 2014

Serial port communication with Arduino

Serial port communication with Arduino

Type:                Hardware + Software
Difficulty:           Easy
Developed by:    Avirup Basu

Summary:

In this article, I will perform a very basic operation i.e Switch on and off a LED by a c# application. The hardware is an Arduino. As an output unit, I will use a Light emitting diode(LED), as an input source, I will be using a c# application which will communicate with the arduino serially. This micro project is a very basic level for upcoming projects.

Software:

1: Microsoft Visual Studio(I have used VS2013 ultimate)
2: Arduino IDE for Windows

Hardware:

1: Arduino development board(I have used Arduino leonardo)
2: A LED(Light Emitting Diode)

Method:

First I will be discussing about the c# code. The c# code will communicate with the arduino serially. The main purpose of the c# code is to create an interface between the Arduino and the pc. The c# code will serially send information to the arduino and accordingly the arduino will act. It's just like if 'a' is a code for the arduino to switch on the LED, then c# will send 'a' serially and the LED will be on. Yes it's simple. But as we will start with more complex projects, then perhaps it won't be easy.

Step1:  Create a new Windows form project. For this, first open Microsoft Visual Studio and then select new project. After that click the tab "Windows Desktop" and select WPF application. Name the project whatever you desire off.





Step2:  Now you need to design an user interface.  For this, we will be using xaml code. You can simply drag and drop the controls as well. For this project you need 2 buttons only. Drag the buttons to the layout and drop it.






Step4: The previous step was for designing the user interface. Now for the two buttons, we need to create event handler. The event handler of the buttons will handle the events and act accordingly. Another thing that I forgot to mention earlier is that you must assign names to the 2 buttons you just placed. For instance let us consider it start and stop. Now let us get into the backend code in c#. Browse to MainWindow.xaml.cs and paste the following code.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO.Ports;

namespace ArLed
{
    public partial class MainWindow : Window
    {
        int blink = 0;
        SerialPort sp1 = new SerialPort();
        string portName = "COM13";
        int baudeRate = 9600;
        public MainWindow()
        {
            InitializeComponent();
            //portName = "COM13";
            //baudeRate = 9600;
            sp1.PortName = "COM13";
            sp1.BaudRate = 9600;
            sp1.Open();
        }

        private void start_Click(object sender, RoutedEventArgs e)
        {
          //Code for the LED to glow
            sp1.Write("1");
         
        }

        private void stop_Click(object sender, RoutedEventArgs e)
        {
            //Code for LED to stop
            sp1.Write("0");
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            sp1.Close();
        }    
    }
}

In the above code, the library required for the function is  System.IO.Ports. Thus if you are using older versions, make sure you have one.


Step5:: As the UI is created, the above code sends characters to Arduino via serial port. Now  we will concentrate on the Arduino code. Well the arduino code is too simple. For compilation of the code you need the Arduino IDE for Windows. The code is given below.

int led = 13;
int blink=
void setup() {
 
  pinMode(led, OUTPUT);
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
 if(Serial.available())
  {
    char c = Serial.read();
    if (c == '1')
    {  
      digitalWrite(led,HIGH);
    }
    else if (c == '0')
    {
      digitalWrite(led,LOW);
    }
    if(c== 'b')
    {
      digitalWrite(led,LOW);
      delay(blink);
    }
     
  }
}

Step6: Now upload the code from the IDE to the hardware. Don't forget to attach the LED. In case of arduino leonardo, attach the long pin of the LED to pin number 13 and the shorter one to ground. Connect the Arduino to the pc via a USB cable. Deploy the code to the device and run the c# code. The UI will pop up. If you press the "Start" key, the LED will glow. If you press the "Stop" key, the LED will stop glowing.
Schematic for connection




As shown in the figure, you can use the resistor. But it's not mandatory for you to use the resistor. You may experience problem if you are doing it for the first time. In case of any queries, click here to send a mail.