A Beginner’s Guide to Android Development

Let’s say you have a stunning idea for an application. You cannot wait to see everyone using it and just the idea of downloads, reviews and comments gets you excited. You’re ready to build the greatest app ever but there’s just one tiny problem: You don’t know where to start Android Development!

Learning to code is easy, it’s the mastery that takes intense practice and experience. Android development can be a bit more complicated. Not only do you need to understand Java, you also need to install all the Android-specific software and learn all of the unique features of Android app development.

In general, creating an Android app requires the SDK (Software Development Kit), an IDE (Integrated Development Environment) like Android Studio or Eclipse, the JDK (Java Software Development Kit) and a virtual device to test on.

Now we know that this may seem a little unnerving at first glance. Our objective is to provide you with a clear guide and to try and make your learning experience simple. And by the end of this article, you should have a basic app that you can start experimenting with. Here at Learn2Create, we will take the Android Studio approach.

You should grab a coffee first though, this may take a while!

Step 1: Download Android Studio

Before you get to that, first you need to install Java on your device. You will find the necessary documents and download links here.

Linux users can check official documentationInstructions to download and Install Java

To program in most languages, you need a piece of software called an IDE or ‘Integrated Development Environment’. The most common IDE for Android development is Android Studio, which comes direct from Google itself. You can get it here.

Android Development
Android Studio: The Official IDE for Android

What’s great about Android Studio is that it is designed specifically for Android development (unlike the second most popular option, Eclipse). This means that when you download the software, you’ll also get a lot of the other bits you need including the Android SDK and the Android Virtual Device, which is an emulator you can test your apps on.

Android Development
Eclipse is a great alternative to Android Studio

As mentioned, there are some alternatives to Android Studio. Eclipse is an older IDE that can be used for Android Development and developing other things too (such as iOS apps) and that is a bit more flexible overall. It’s also a much more fiddly to get started with though and not nearly as beginner-friendly.

Another great alternative for Android Development is Basic4Android. Basic4Android is an IDE that lets you code Android apps with the BASIC programming language. It simplifies many things and is mainly focused on ‘rapid development’. There are other options too, such as Unity3D and numerous app builders, each of which has specific strengths and weaknesses depending on what you’re planning on building.

Step 2: Set Up Android Studio for Android Development

Now that you have Android Studio installed, you are well on your way to Android Development. Before we begin, you need to install Java on your machine to use Android Studio. To be specific, you have to install the Java Development Kit (JDK). Java is the programming language you’re going to be using to build your apps in this instance and you need to install the JDK in order for Android Studio to be able to interpret and compile your code. You’ll find the JDK here. Just download and follow the instructions to install.

Click on Android Studio to begin. A menu with some configurations comes up and select as you wish.

There are three vital things interacting when you use Android Studio to create your apps.

  • Android Studio itself, which is an IDE that provides you with a nice interface for coding.
  • The code you write in Java, which you installed a moment ago…
  • And the Android SDK which you’ll access through your Java code in order to do Android-type things

 

Step 3: Starting a New Project

Once you’ve installed your samples, you can go back to the first page you saw when you loaded up Android Studio. Now you want to choose Start a new Android Studio Project – excited?

Enter the name you want for your application and your ‘company domain’. Together these elements will be used to create your package name with the following format:

com.companyname.appname

Android Development

Eventually, the package will be the APK (‘Android Package File’) that will be compiled. It is this APK that you will later upload to the Google Play Store. There are ways that people can see this, so if you’re planning on making something you’ll eventually release, try to avoid using weird words.

Also, enter the directory where you want to save all the files related to your app. Click Next and yay! More options! Don’t worry, we’re almost there… Next you need to decide what type of device you’re going to be developing for and in this case we’ll start with the Phone and Tablet option. Other options are TV, Wear and Glass.

Step 4: Almost there!

The other choice you have to make at this stage is the ‘Minimum SDK’. This is the lowest version of Android you want to support. Why not just enter the latest version of Android in here? The best bet at this stage is to go with the default option, so just leave this field as it is.

Android DevelopmentOn the next page, you’ll be given the option to pick the way you want your app to look at the start. This will be the look of your main ‘Activity Module’ which is basically the main page of your app. Think of these like templates; do you want to have the title of your app along the top of the screen, or do you want your UI to fill the whole display?

For your first creation, you’ll probably make something really simple that just displays a single, basic activity. Select ‘Basic Activity’ to keep things simple at the moment and for all practical purposes, this will now be your app. Click Next again you get the last options.

Now you get to pick the name for your activity and the layout name (if you chose ‘Basic Activity’ you’ll also have the title option and the ‘menu_resource’ name). The activity name is how you’ll refer to your activities in your code, so call it something logical like ‘MainActivity’. Can’t screw that up eh?

Lastly, choose a name for the menu and for the title. Pick something neat for the title, as your users will be able to see this at some point. Click next and finally you can see the app you created!

Basic Steps to start Android Development:

  • Download and install Android Studio, making sure to include the Android SDK
  • Install Java SDK
  • Start a new project and select the basic details

Just a reminder: When you’ve done all this once, you can forget about it forever and focus on the cool stuff: creating apps!

 

That’s it from us at Learn2Create! We will provide you with further reference links that we found to be great resources to learn Android Development. Adios!

YouTube Channel : Android Developers

Tutorials : Tutorials point

Official Documentation: Getting Started: Android Studio

Read More News on Learn2Create – News Category

 

How to turn on led light on raspberry pi

How to turn on led raspberry pi

This post only covers the simple step to turn ON a LED accessing the GPIO pins using the python GPIO library. To learn how to turn ON/OFF a LED using a web interface follow the link present at the bottom of the post.

How to turn on led raspberry pi

Prerequisites:-

  1. A Raspberry pi, obviously. We are using the raspberry pi 3 model B
  2. A Breadboard. What is it?
  3. A LED
  4. A 330 ohm resistor
  5. Two Male-Female jumper wires

You can buy points 2-5 from a local electric shop. It cost me $1.50.

Setup:-

  • Boot up the Raspberry pi.
  • Create a file on your raspberry pi and name it led.py (for now). If you are connected to raspberry pi via SSH then nano led.py
  • Copy the below code and paste it to the led.py file. We will be using the GPIO pin #17 since it’s common in all raspberry pis. Read the comments to know what each line does.
    import RPi.GPIO as GPIO
    #importing GPIO module from RPi library
    import time
    #to stop execution after some seconds
    GPIO.setmode(GPIO.BCM)
    #setting the naming convention to address the GPIO pins
    GPIO.setwarnings(False)
    #instructs python stop printing warning to the console
    GPIO.setup(17,GPIO.OUT)
    #this is necesary as it tells python that pin 17 is going to be used
    print "LED on" #to notify that the GPIO pin is going to output
    GPIO.output(17,GPIO.HIGH)
    #turns ON outputting in GPIO pin no.17
    time.sleep(1)
    #stop any further execution of the program for one second
    print "LED off"
    #to notify that the GPIO pin is about to stop outputting
    GPIO.output(17,GPIO.LOW)
    #turns OFF outputting in GPIO pin no.17
    
  • Connect jumper wire to GRND and #17 GPIO pin.

    Refer to image below

    How to turn on led light raspberry pi

  • Build the circuit.

    Follow the circuit diagram to complete the connection

    how to turn on led raspberry pi
    This is how the final circuit should look like with a breadboard

Running the code

  • To run this code type: sudo python led.py
  • You’ll see “LED on” printed in the console then stop after one second printing “LED off

Now that you have learned how to turn ON/OFF a LED on a raspberry pi, time for you to move on and build a custom interface to turn ON/OFF the LED.

Read more such articles on Learn2Create.

Video Tutorial And Code For Object Avoiding Robot

Here is the code for object avoiding robot that uses one HC-SR04 Ultrasonic Object Detector.

int trigPin = 2;   
int echoPin = 3;   
long duration, inches;
void setup() {
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
 pinMode(4,OUTPUT);
 pinMode(7,OUTPUT);
}
void loop()
{
 digitalWrite(trigPin, LOW);
 delayMicroseconds(5);
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10);
 digitalWrite(trigPin, LOW);
 pinMode(echoPin, INPUT);
 duration = pulseIn(echoPin, HIGH);
 inches = (duration/2) / 74;
 delay(100);
 if(inches<=10){
   analogWrite(6,127);
   analogWrite(5,127);
   digitalWrite(4,HIGH);
   digitalWrite(7,LOW);
 }
 if(inches>10){
   analogWrite(6,127);
   analogWrite(5,127);
   digitalWrite(4,HIGH);
   digitalWrite(7,HIGH);
 }
}

Learn how to set up a headless raspberry pi (needs to connected to the display for the one-time setup)
Check out other articles from learn2create.

Arduino Controlled Floating Magnet Switch

The Floating Magnet Switch

Another option for building the switch is to use magnets to control the switch. This is more for adding that “cool factor” to the project than function.

The Parts

A Shoe Box

Magnets

String or Wire

 

Building The Frame

Attach your magnets to your string or wire. I used wire because I didn’t have any string lying around. Poke a hole in the top and the bottom of the shoe box so you can run the strings or wires through. Tie them off on the outside of the box.

 

Make sure the magnets aren’t too far apart. If the magnets are too close, all you have to do is tie knots onto the string or wire on the inside of the box to pull the magnets further apart.

 

Once the magnets are attached to the box properly, stand the box up and hang the bottom magnet from the top one. Poke a hole in the side of the box at about the height of the top magnet. Run the wires for the ultrasonic object detector through this hole and then attach the sensor to the wires. Position the sensor so it is aiming at the bottom magnet.

Afterwards, follow the steps above to upload code to the board, but use this code instead:

int trigPin = 2;    
int echoPin = 3;    
long duration, inches;
int switchState = 0;
void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(7, OUTPUT);
  pinMode(13,OUTPUT);
}
void loop() {
    digitalWrite(trigPin, LOW);
    delayMicroseconds(5);
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW);
    pinMode(echoPin, INPUT);
    duration = pulseIn(echoPin, HIGH);
    inches = (duration/2) / 74; 
    delay(200);
    while(switchState==0) {
      if(inches>5){
        break;
      }
      if(inches<=5) {
          switchState=1;
        analogWrite(6,127);
        digitalWrite(13,HIGH);
        digitalWrite(7,HIGH);
        delay(100);
        analogWrite(6,0);
        delay(100);   
        break;
      }
    }
    while(switchState==1) {
      if(inches<=5) {
        break;
      }
      if(inches>5) {
        switchState=0;
        analogWrite(6,127);
        digitalWrite(13,LOW);
        digitalWrite(7,LOW);
        delay(100);
        analogWrite(6,0);
        delay(100);
        break;
      }
    }
}

This is a Modified version of the Touchless Lightswitch.
Click here to see the full build article!

Programming An Arduino With A Raspberry Pi

Program arduino using raspberry pi

The Raspberry Pi is an extremely useful mini computer. The one I have (The Raspberry Pi 3 Model B) has 4 USB ports, an ethernet port, built in wifi, and HDMI out. It may not be the fastest computer around, but it’s definitely small and versatile. Today, I’ll show you how to use a cheap Raspberry Pi as a simple desktop computer to program an Arduino for robotics and other tech projects!

 

The Parts I Used

Monitor/TV not shown

1 x DFRobot Romeo V1 (Arduino Uno with built in motor drivers)

1 x Raspberry Pi 3 Model B and 16gb micro SD with NOOBS os preloaded.

To learn how to setup a raspberry pi read this article – Setting up a raspberry pi for the first time.

1 x USB keyboard and mouse

1 x HDMI compatible monitor or tv

1 x HDMI Cable

1 x USB “A” To “B” Cable

1 x 5.25v 2.4amp micro USB power adapter

 

The Process

  1. Insert the micro SD card into it’s slot on the bottom of the Raspberry Pi. The metal on the card should be face the Raspberry Pi.

 

2. Insert the bluetooth receiver or USB cables for the keyboard and mouse.

 

3. Insert the HDMI cable into the Raspberry Pi and the monitor or tv.

[vc_row][td_block_ad_box spot_id=”custom_ad_1″ spot_title=”- Advertisement -“][/vc_row]

4. Plug in the power adapter and the chip will start up.

 

5. To program an Arduino with the Raspberry Pi, you will need to download the Arduino IDE so you can upload code to the Arduino. Read this article to learn in-depth how to install Arduino IDE on raspberry pi and connecting various arduino devices to it.

You'll need internet connection to download the IDE

 

6. Click the terminal button to open the terminal. This is where you will type in the commands for downloading and installing the Arduino IDE.

 

7. Type “sudo apt-get install arduino” and press enter. Eventually, you will need to learn the commands used in the Terminal.


[vc_row][td_block_ad_box spot_id=”custom_ad_1″ spot_title=”- Advertisement -“][/vc_row]
8. Type “y” and then hit enter. You have plenty of space on the Raspberry Pi right now so this isn’t something you need to worry about yet.

9. Once that finishes, you are ready to upload code to the Arduino! Connect the Arduino and the Raspberry Pi together with the USB “A” to “B” cable.

 

 

10. Open Menu -> Programming -> Arduino IDE

11. Once the program has opened, go to Tools -> Serial Port -> and select what is there. There should be only one option right now. If there are multiple options, trial and error is ok.

[vc_row][td_block_ad_box spot_id=”custom_ad_1″ spot_title=”- Advertisement -“][/vc_row]

12. Next, go to Tools -> Board -> Arduino Uno. The DFRobot Romeo board I used is based on the Arduino Uno.

 

13. You can now upload code to the Arduino and test it out! I used the “Blink” example that came with the Arduino IDE.

 

14. If the code compiles, uploads, and works correctly then you are finished!

 

You don’t need much to make awesome stuff. With a few essential components on hand, you can create an infinite number of devices for various uses.

Go build something cool!

To learn how to setup a raspberry pi without a monitor. Read our article – Setting up a headless raspberry pi.

A Beginner’s Guide to Programming

Beginners Guide Programming – A simplistic approach towards self-learning

One of the most frequent questions I get asked by my non-programmer friends is ‘How would you recommend a total beginner to start with programming’.

This is particularly a tough question because, we all are different and have different ways of learning. But I can tell you how I did it.

Disclaimer: I know I’m not the best programmer/coder there is, but I learned to code on my own. So, this is to all you guys who are interested in self-learning.

In this Beginners Guide Programming I will be trying to quickly clear a few misconceptions and introduce a some habits that can help you become an excellent programmer.

This technique is not confined for the art of coding, it serves as an excellent case study to learn any technical skill.

I won’t be talking much about any particular programming language here. Just the art of computer programming in whole.

I hope this will inspire a few to start coding; it’s a very interesting hobby and who knows it may one day earn you a living.

First things first:

Don’t Be Afraid of the Syntax

A major reason many people are scared off from trying to learn to code is well… the syntax. Syntax is the grammar for any programming language, there are a set of rules to how it is written. You don’t ask questions here, it is like that because of the way it is designed.

But that apart, the basic concept remains the same irrespective of the language. Syntax is just a way to express those ideas in the given programming language.

As an example, a commonly used concept in programming is a loop. A loop does exactly what it says; it loops through a set of instruction until a certain condition is met with. Once you understand how loops works and different types of loops then all that you need to do is google, “How do I use loop in <Insert your programming language here>” and you’ll get thousands of examples right away.

I personally think syntax are overrated. People whom I meet at work worry too much about trying out new languages, the reason? Syntax! And, this fear is being monetized by training center who do nothing more than teaching the syntax, I don’t think they even teach the basic concepts of programming. It’s just a waste of time and money.

Online courses at Codecademy are very good when it comes learning syntaxes and to some extend also helps in understanding the basic concepts.

Beginners Guide Programming
This image will help you understand the popular languages used in each of these fields

Start with a Tutorial Book

The best place to start is always with a careful walkthrough. For programming, I like O’Reilly or Balguruswamy

as a guide to learn the core concepts of any language.They are very well written keeping in mind all the different readers that may use them. There are no assumptions made at programming skills that you have, so a great way to start.

If you’re learning your first language, you may want to take an intro class on programming which can teach the basic concepts. Semantics are more important than syntax, so understanding the basic ideas is essential, while memorizing the exact spelling of a command usually isn’t (if you’re wrong, you’ll get an error and a quick Google search will inform you of your mistake).

Take up an online course

If you’re learning your first language then, taking an online course will help a lot.

Here’s some free courses which cover the basics:

The goal in the initial phase should be to get something working. Like, creating a basic hello world app will teach you all that you need to set up the environment. Once you get that started, it usually isn’t hard to modify these boiler plates to make something of your own.

As mentioned above, sites like Codecademy helps in learning the syntax and getting you started with a language.

Which Language Should You Start With?

There is no specific language that you should start with. Some say its:- C or C++, but I started with python, a much more abstract language which hides a lot of complexities from the user(programmer) and lets them focus on building the logic.

Beginners Guide Programming
Popular Programming languages with respect to the number of on-going projects.

For first languages, my personal suggestion is to  avoid C++ and C, because they tend to be a little less forgiving than Python and deal with a lot of code. I would also avoid web languages like PHP because they can be tricky to set up and require you to learn more at once (HTML, SQL).

The first language you should use, should be the one you want to use. So overrule my suggestions if you have something else is mind.

Learning by Project

This by far has been my best way to learn a new language. Create something(anything that interest you) could be something as trivial as ‘hello world’ or ‘a basic calculator’. Just make!

You can also download some done projects from the net and try to read through them. My friend used to always tell me ‘Break it to make it’, I feel the urge to tell you the same.

Fiddling around is the only way to truly learn.

The things to keep in mind when trying to learn by doing a project:-

  1. It should be short,
  2. It should force you to learn something new all the time,
  3. It should be fun!

 

Summarizing the post:-

  • Don’t fret too much about the syntax
  • Start with a tutorial book, learn the concepts
  • Take up an online course
  • Learn by doing projects

Programming has to be one of the best skills I’ve learned, not only because it’s fun and rewarding, but because it teaches a lot of life lessons as well. It taught me how to build things, organize projects and set goals for myself. And, as computers become more integrated into our lives, it’s nice to be able to communicate with them.

And, always remember ‘Break it to make it!’ 🙂

Let me know your views and suggestions on this article – The Beginners Guide Programming in the comment section below!

 

Check out the Code Category for code related articles in – Code Category.

Developing Beautiful Front-end

Have you ever looked at your favorite website and wondered exactly what made it tick? Have you looked at the way it was laid out, the way the buttons acted when you clicked them, or any other part and thought, “I wonder how complicated that is?” or, “I wish I could do that”?

All of those things are front end development. While web design is the way a website looks, front end development is how that design actually gets implemented on the web.

Front end developers use HTML, CSS, and JavaScript to code the website and web app designs created by web designers. The code they write runs inside the user’s browser (as opposed to a back end developer, whose code runs on the web server). Think of it a little like this: the back end developer is like the engineer who designs and creates the systems that make a city work (electricity, water and sewer, zoning, etc.), while the front end developer is the one who lays out the streets and makes sure everything is connected properly so people can live their lives (a simplified analogy, but you get the rough idea). They’re also in charge of making sure that there are no errors or bugs on the front end, as well as making sure that the design appears as it’s supposed to across various platforms and browsers.

[vc_row][vc_column][td_block_ad_box spot_id=”custom_ad_4″][/vc_column][/vc_row]

I’ve combed through dozens of front end developer job listings to see which skills are the most in-demand right now. These are the things that real employers are looking for in job applicants today (and will still be looking for in the near future). Master these things and you’re certain to land an awesome front end dev job!

[vc_row][vc_column][td_block_ad_box spot_id=”custom_ad_2″][/vc_column][/vc_row]

HTML & CSS

HTML (Hyper Text Markup Language) and CSS (Cascading Style Sheets) are the most basic building blocks of web coding. Without these two things, you can’t create a website design, and all you’ll end up with is unformatted plain text on the screen. You can’t even add images to a page without HTML!

Before you get started on any web development career path, you’ll have to master coding with HTML and CSS. The good news is that getting a solid working knowledge of either of these can be done in just a few weeks.

The best part: HTML and CSS knowledge alone will let you build basic websites.

JavaScript

JavaScript lets you add a ton more functionality to your websites. You can even create a lot of basic web applications using nothing more than HTML, CSS, and JavaScript (JS for short). On the most basic level, JS lets you add a lot of interactive elements to your websites. Use it to create things like maps that update in real time, interactive films, and online games. Sites like Pinterest use JavaScript heavily to make their user interface so easy to use (the fact that the page doesn’t reload whenever you pin something is thanks to JavaScript!).

It’s also the most popular programming language in the world, so regardless of your dev career plans, it’s a super valuable thing to learn.

jQuery

jQuery is a JavaScript library: a collection of plugins and extensions that makes developing with JavaScript faster and easier. Rather than having to code everything from scratch, jQuery lets you add ready-made elements to your projects, that you can then customize as necessary (one reason why knowing JavaScript is so important). You can use jQuery for things like countdown timers, search form autocomplete, and even automatically-rearranging and resizing grid layouts.

JavaScript Frameworks

JS frameworks (including AngularJS, Backbone, Ember, and ReactJS) give a ready-made structure to your JavaScript code. There are different types of frameworks for different needs, though the four mentioned are the most popular in actual job listings. These frameworks really speed up development by giving you a jumpstart, and can be used with libraries like jQuery to minimize how much from-scratch coding you have to do.

[vc_row][vc_column][td_block_ad_box spot_id=”custom_ad_2″][/vc_column][/vc_row]

Front End Frameworks

CSS and front end frameworks (the most popular front end framework is Bootstrap) do for CSS what JS Frameworks do for JavaScript: they give you a jumping-off point for faster coding. Since so much CSS starts with exactly the same elements from project to project, a framework that defines all of these for you upfront is super valuable. Most front end developer job listings expect you to be familiar with how these frameworks work and how to use them.

[vc_row][vc_column][td_block_ad_box spot_id=”custom_ad_4″][/vc_column][/vc_row]

Responsive and Mobile Design

Responsive and mobile design skills are super important to employers. Responsive design means that the site’s layout (and sometimes functionality and content) change based on the screen size and device someone is using.

For example, when a website is visited from a desktop computer with a big monitor, a user would get multiple columns, big graphics, and interaction created specifically for mouse and keyboard users. On a mobile device, the same website would appear as a single column optimized for touch interaction, but using the same base files.

Mobile design can include responsive design, but also includes creating separate mobile-specific designs. Sometimes the experience you want a user to have when visiting your site on a desktop computer is entirely different than what you want them to see when visiting from their smartphone, and in those cases it makes sense for the mobile site to be completely different. A bank website with online banking, for example, would benefit from a separate mobile site that lets users view things like the closest bank location and a simplified account view (since mobile screens are smaller).