Tuesday, May 31, 2016

Can you program Arduino 101 with Visual Studio 2015?

The short answer is, Yes you can.

If you rather not use Visual Studio 2015, you could also use the program from Arduino.

But Visual studio does lot more than Arduino Program.

Here is the how and the long answer regarding Arduino with Visual studio..

First thing you need to have is the correct version (if you follow my advice) of Visual Studio. Get the Visual Studio 2015 Community (What I have is the same but with Update 2).

If you do not have, no problem. Read this post.


For Arduino to work with Visual Studio 2015 Community (VS2015C), you need to install the Arduino Extensions for Visual Studio. A default install of VS2015C does not have the 'hooks' to create a Arduino Project. You will not find it in the 'New Project...' templates.

You need to install the Arduino Extension for Visual Studio 2015. You can get an idea how to do it by following this Swaytorial:

Of course you need to buy the Arduino 101. It is available from many sources. Connect it to computer with a USB cable as shown.



With all of the above in place, it is very easy to run the board from Visual Studio 2015 Community.

 Open Tools menu as shown to access the Extensions and Updates... submenu.

arduino101_Vs15C

The extension immediately brings in the support for Arduino 101.


Start a new project as shown here:

arduino101_Vs15C_000

Provide a name for the project (herein OneZeroOne)and click OK. The project with folders will be created for you as shown.

arduino101_Vs15C_00

In the above image click on the OneZeroOne.ino file. This is the 'sketch' that you will using to interact with the board via your USB drive to which the arduino 101 board is connected. It will be a simple, empty template. You can cut and paste any of the relevant sketches. Herein I have used the same sketch I used here to run the 'Blink' project that makes a LED on the arduino 101 board to flash on and off. It is one of the example applications, something akin to a 'Hello World'.

Here is the sketch used in this post:


arduino101_Vs2015C_02

When you compile and run this program you may get a message like this.

arduino101_Vs2015C_02

You may also get the messages from the serial port as shown as you connect/disconnect or run the program:


arduino101_Vs2015C_04

The arduino extension you added will also add a arduino specific toolbar as shown which makes it easy to work with the board.
arduino101_Vs2015C_05

There are couple of ways to build the program and upload it to the board. Here is one way using the main menu.
arduino101_Vs2015C_06

 As soon as you upload the second LED on the board starts blinking.







Friday, May 27, 2016

What is the difference between factorial and lfactorial in R programming?

Factorial computes the factorial of a number. Given a number n it computes n! (n factorial). You can follow this after launching the R Gui. 5! is same as 5x4x3x2x1
---------------
> factorial(5)
[1] 120
---------------
factorial in R programming is also applicable to non-integers.
------
> factorial(5.5)
[1] 287.8853
-------------
How does R programming calculates factorial. It is calculated in the most efficient manner using the Gamma function.
factorial(x)=gamma(x+1)

In implementation to calculate factorial R calculates the gamma
factorial(5)=gamma(5+1)
------
> gamma(5+1)
[1] 120  - This is same as factorial(5)
----
What about lfactorial in R programming?

The definition of lfactorial (http://www.stata.com/manuals13/m-5factorial.pdf) is ;
lfactorial(n) is log(factorial(n))
-----
> lfactorial(5)
[1] 4.787492
> log(factorial(5))
[1] 4.787492
------------
Another interesting tip is you can use factorial function presenting it with a list like factorial(c(5,4,3)) and not a number. It would then compute the factorial for each of the numbers. For example:
----
> factorial(c(5,4,3))
[1] 120  24   6
> factorial(c(5,4.3,2))
[1] 120.00000  38.07798   2.00000
> lfactorial(c(5,4,3))
[1] 4.787492 3.178054 1.791759
----------

Wednesday, May 25, 2016

What is new in Microsoft Edge Windows Build 14342 for developers?

Recently updated the insider's version to 14342 from 14295.

Swipe Navigation is new in Microsoft Edge
Swipe anywhere on the web page left to right or right to left to navigate.

New Extensions in 14342
  • AdBlock
  • AdBlockPlus
  • Pinterest
  • Save to Pocket
Click Ellipsis button and Click Extensions


You need to get extensions from Windows Store


--Install from Windows Store
https://developer.microsoft.com/en-us/microsoft-edge/extensions/


I already had the Microsoft Translator on my previous version but I could not load it. Looks like I need to get the extension again.



In versions earlier to this you could do the following:

Pin/unpin tab. Right click tab to pin the tab. This is quite useful although browser displays some of regularly used pages when you click the + New tab.



You could pin a number of interesting tabs as shown.

Right click the pinned tab and pick Unpin to unpin it. Unpinning windows logo site.




Drag and drop folders to reorder in Favorites Bar.
Of course you can sort the Favorites.



View Source & Inspect Element contextual menu items

Click ellipsis at extreme right end of browser and choose F12 Developer Tools, the first time. Now if you right click on the page you can access View Source and Inspect Element. Of course you can hide it from other users.


The Context menu then shows the View Source and Inspect Element items. If you hide it  you just get Select and Print when the you right click on the web page.

Paste and Go

You could copy a hyperlink from anywhere (for example typed into Notepad or copied from a web page) and then in a new search box right click to get the context menu and pick,  Paste and go to navigate to that page.

These are great features but one of the problems that has not gone away is that the browser hangs when changing tabs. Sometimes you need to get the task manager to get rid of it.

Tuesday, May 24, 2016

How do you get the node.js project templates in Visual Studio 2015?

In a recent post I tried to install Node.js tools that is supposed to help create node.js project types in Visual Studio Community 2015. After installing, I realized that I could not access the node.js templates in Visual Studio. I noted however that the installer version was NTVS 1.1.1 VS2015.msi.

As an after thought I found an easier route to get the node.js support for Visual Studio 2015 Community. This post describes the steps.

After launching Visual Studio 2015 Community ( I have the Update 2, version 14.0.25123.00 Update 2) you can access Extensions and Updates menu item as shown.

NodeJsTools_07.png

Click on the menu item. The Extension and Updates window appears as shown. You need to search for node.js in Visual Studio Gallery. You will find both 1.1 and 1.2 versions.


NodeJSToolsPlug_inVS2015.png

Click Download button for version 2.

The related msi file gets downloaded. The version is


NodeJsTools1point2.png

You may double click the downloaded file to install the plug-in. But first take care of the Apache license.


NodeJsTools_001.png

The extension gets updated as the program installs.


NodeJsTools_001_2.jpg

Once the extension is installed, when you create a New Project... in Visual Studio 2015 Community you should be able to see all the node.js templates as shown in the next image.


NodeJsTools_05.jpg

Monday, May 23, 2016

How can you program IOT controllers using JavaScript?

Arduino boards can be programmed using Arduino software and Intel IOT boards can be programmed using Intel XDK IOT. Using JavaScript to program controllers would be very useful as most browsers are HTMl5 compliant. The Johnny-Five Robotics and IOT program is an interesting option.

Johnny-Five is the JavaScript Robotics & IOT platform released by the Bocoup group. Johnny-Five is maintained by a growing number of talented developers.

What is Bocoup?
Bocoup  is a group that championed the cause of Open tools and Work Flow. They really seems to have people with very varied and diverse talents to tackle web, data, and visualization.

How does Johnny-Five handle the Hello World (or Blink for that matter)?
It looks like 1-2-3 really.

1. Install Node.js(Prefer 4.2.1 LTS)
2. Setup your board
3. Run: npm install johnny-five

What else is needed?

You also need to run the Firmata protocol for the controller board to communicate with the computer.
Interestingly Johnny-Five can handle over 30 different arduino compatible boards from the likes of Raspberry, Intel, Arduino, Sparkfun and many more.

This is very impressive indeed as each of these boards are handled by their vendors like Arduino, Intel and others.

How about non-arduino boards?

There are platform specific IO Plugins (for example, Galileo-IO plugin) .These plugins can speak the language of the platform as they implement Firmata compatible interfaces.

You will be hearing more about Johnny-Five in my blogs, here and here, keep reading....

Thursday, May 19, 2016

How do you connect an Arduino 101 to your computer to check it out?

In this post I discuss a bit about Arduino 101 and describe how different is it from the Arduino UNO. It would be helpful if you would review some previous details here and here.

First of all Arduino 101 has the same kind of peripherals as the Arduino UNO. UNO had an ATmega328 which has been replaced by Intel's Curie(TM). The board has two cores running at 32 MHZ, a x86 (Quark) and an ARC (Argonaut RISC Core). In addition to having low-energy consumption, Arduino has on-board Bluetooth Low Energy and 6-axis accelerometer/gyroscope capability.


These are steps you need to take for checking it out:

Step 1:
Buy the board and it is not very expensive. It is small and looks very much like the Arduino UNO


Lots of places to buy from, http://store-usa.arduino.cc/. I bought mine from Amazon.com as they bring it to my door.

Step 2:
You need to get the Arduino software Arduino IDE 1.6.7.later to program this board.

Review this post to get the download link and some installation information:

http://hodentekhelp.blogspot.com/2016/05/is-there-arduino-program-to-use-with.html



3. After installing Arduino IDE as in 2. above, you should install the Intel Curie Boards using Arduino Boards Manager.

This is after launching the Arduino IDE


Go to the Board Manager. Many different boards work with software and you will be using Arduino 101 which is not present in the default installation of Arduino 1.6.8. That is why you require this step.


Click on the Board Manager... to open the next window. Scroll down to see the Intel boards. Choose the one displaying Arduino 101. Click on the Install button. It begins to download. Quite a big file and can be slow.


Halfway of the installation you will get this Windows Security message. Click install.


You do not get any other message. Click Close on the Board Manager screen. Now in the Board manager screen you should see the board at the very bottom of the drop-down.



Attach the Arduino 101 board using the USB connector as shown. The green light at bottom left shows that the board is powered and ready.


Now you make sure that the Arduino 101 is chosen in the board.

From File choose the Blink example as shown. This Arduino Program (also known as a sketch) will make a LED on the board to blink on and off.

When you choose this the following Sketch will appear in the Arduino IDE as shown (review the title of the next window).


Form the menu Sketch choose Verify and Compile. If there are no errors it should compile.

Now click on Sketch | Upload. The program now goes to the board and get executed. After a slight delay, you will see the LED blinking as shown in the video.





Saturday, May 14, 2016

How do you fix this argument label error in the SWIFT program?

While trying to compile and run the following (see link at the bottom of post) program using SwiftFor Windows,
---
func sayHello(personName: String) -> String {
        let greeting = "Hello, " + personName + "!"
        return greeting
    }

print(sayHello("Jay"))

--------
The SwiftForWindows compiler spit out this error:

SwiftError_00

The compiler did indicate the location and the missing label.  The change was made in the print statement by providing the missing label (personName)

The program was modified as shown:
-------------------
func sayHello(personName: String) -> String {
        let greeting = "Hello, " + personName + "!"
        return greeting
    }

print(sayHello(personName:"Jay"))

---
With this the compiler produced no errors.


SwiftError_01

Now after hiting the Run button, the program produced the following response:


SwiftError_02
This sample was taken from SWIFT ver2.2 documentation:

https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Functions.html#//apple_ref/doc/uid/TP40014097-CH10-ID158Is the error due to differences in the SWIFT compiler version?

Thursday, May 12, 2016

How do you compile and run SWIFT programs on Windows 10?

Presently it is possible to compile and run programs written in SWIFT language on Windows 10. You need to download the program as described in this post.

Programs written in SWIFT has the extension .swift. You can use any text editor and here is a simple program written using Notepad and saved to your hard drive. Note that it has to be in the following directory, C:\SwiftForWindows\Swift

//--Function definition
func sayHello(personName: String) -> String {
        let greeting = "Hello, " + personName + "!"
        return greeting
    }
//Function Call
print(sayHello(personName:"Jay"))
//--

Once you download run the Straightforwards.msi (please see the post at the top) file by double clicking it. There may be warnings from the computer not to run it, but ignore and install it.

This leaves a shortcut on your desktop.

When you click on this shortcut the Swift For Windows window opens as shown.


Swift_02

It is simple to use. Select the file and then hit Compile after choosing your platform. A command-line window opens which you can close if there are no compilation errors.

Swift_03

Close the window and have a look at the Logs. Then hit Run. That's it. Again the comand-line window opens displaying the results of your program.

Swift_04

In summary:
1. Create the Swift program file on a text editor and save it with the extension .swift to a specific directory.
2. Choose the platform you are using
Swift_05

3. Hit Run

That's it.

Tuesday, May 10, 2016

How do you transfer databases between two SQL Servers?

You can do it in a couple of different ways but this post shows you how you may do using the Export/Import Wizard. In particular, the post shows you, step-by-step, Copying the pubs database on a developer's edition of SQL Server 2012 to a developer's edition of SQL Server 2014.





Follow this step-by-step Swaytorial.
http:/sway.com/5HClf1YMOeTAERG9

Monday, May 9, 2016

Is there an Arduino program to use with Arduino 101?

If you intend using the more recent Arduino hardware such as Arduino 101 you better use the more recent Arduino IDE 1.6.8.

In a previous post you reviewed using the Visual Studio 2015 with Arduino Extension. In this post you will learn how to download the latest version and install it on Windows 10 computer.

You download arduino-1.6.8-Windows.exe from here.


You begin installing by double clicking the executable.
Here are some of the installation time screen shots for your reference:



On Windows 10 it also adds a desktop App to the All Apps menu.

You launch it by double clicking the shortcut or the desktop app or the shortcut in the installation folder.
 
Click Tools in the main menu to find the Board Manager link ass shown. In the drop-down you can see the various hardware that can be accessed.

Click Board Manager... to open another drop-down. Scroll down to view the Arduino 101 by Intel.

That's all.