Arduino: a revamped tiny Sketch

Couple of days ago I wrote a post about how I got started with an Arduino UNO and wrote my first Sketch (a Sketch is an App written using Arduino IDE and and uploaded to the board via Serial). Click here to read it.

The Starter Kit had an LED attached to a a very small PCB with four pins. Picking it up I realized it was an RGB LED with three resistors printed on it. Neat!

IMG_20151227_085209
RGB LED board

I knew what I wanted to do with it.

Adjust RGB

This sketch is a follow up to my last one ‘AdjustBrightness.ino’ and allows you to pick what colour you want the LED to be! Like this colour (one of my favourites), for example:

IMG_20151227_090442
Turquoise Green LED

What you need:

  • Arduino or Genuino Board
  • 10k ohm potentiometer
  • RGB LED with resistors
  • hook-up wires
  • 4 male to female jumper wires

No need for a breadboard!

IMG_20151226_130208409

Connect the pins on the LED board to the Arduino:

  1. R -> 9
  2. G -> 10
  3. B -> 11
  4. (-) -> GND

Connect three wires from the potentiometer to your board:

  1. to ground from one of the outer pins of the potentiometer
  2. to 5 volts from the other outer pin of the potentiometer
  3. to analog input 0 from the middle pin of the potentiometer

IMG_20151226_130157617

You’re good to go …

What about the code? Since I didn’t want to take up much space here, I put it on a GitHub repo. Find it inside the ‘AdjustRGB‘ folder.

IMG_20151226_125136620
Powering it from batteries

That’s it for now. Hope you find it useful …

Arduino: a tiny Sketch

A friend of mine gifted me an Arduino UNO starter kit a while ago. I didn’t have the time and motivation back then to dabble in it.

Fast forwarding to this day, I watched Massimo Banzi’s TED Talk in the morning, one of the guys who helped invent the Arduino. It was inspiring.

So, what is it anyway? Arduino is a credit-card sized micro-controlled board that can be be used for a whole lot of purposes,  so much that one could dedicate his life on researching the everyday potential of it.

IMG_20151222_243554612

IMG_20151222_243624450

The beautiful thing about this tiny device is that it is so easy to get started once you have the starter kit. In fact, I only started in the morning. Even more beautiful is that the whole project is open-source, from the hardware to software to everything in between. You could even make your own board!

What can you do with it? Like I said, the possibilities are endless. Many tech startups (and older ones) use this as a rapid prototyping tool. Pebble designed their awesome smartwatch using this, for example.

For starters, its good to try out stuff with LEDs. In fact, that’s exactly what I did.

Adjust Brightness

My tiny project is in fact a mashup of two examples that are provided by Arduino themselves. It ‘Works just like the light dimmer at you home!’

This is one of the easiest projects you could find. The reason I am sharing this information with you is to illustrate how simple it is to get started.

What you need:

  • Arduino or Genuino Board
  • 10k ohm potentiometer (that dimmer thing)
  • LED
  • 220 ohm resistor
  • hook-up wires
  • breadboard

Connect three wires from the potentiometer to your board:

  1. to ground from one of the outer pins of the potentiometer
  2. to 5 volts from the other outer pin of the potentiometer
  3. from the middle pin of the potentiometer to analog input 0

Next, you have to connect the anode (the longer leg) of your LED to digital output pin 9 on your board through a 220 ohm resistor. Connect the cathode (the shorter leg) directly to ground.

IMG_20151222_071834837
The whole thing could also be powered by a battery back of six 1.5 V cells.

And here is my AdjustBrightness.ino code:


/*
  Adjust Brightness - Works just like the light dimmer at you home!
  
  A little sketch I came up with after going through a couple of examples.
  This code receives the analog sensor value of the potentiometer from analog pin 0 
  and uses this value to set the brightness of the output of pin 9.

  Based on the following example projects:
  Read Analog Voltage - https://www.arduino.cc/en/Tutorial/ReadAnalogVoltage
  Fade - https://www.arduino.cc/en/Tutorial/Fade

 created  21 Dec 2015
 by Muhammad Muhsin
*/

const int ledPin = 9; //the pin that connects to the LED
int brightness; //stores the brightness level of the LED
int sensorValue; //stores the analog input from the potentiometer

void setup() {
  // initiliaze the PWM pin as an output
  pinMode(ledPin, OUTPUT);

  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

void loop() {
  // read the input on analog pin 0
  sensorValue = analogRead(A0);

  //brightness ranges from 0 - 255, so
  brightness = sensorValue / 4;

  //for monitoring purposes
  Serial.println(brightness);

  //light up the LED
  analogWrite(ledPin, brightness);
}

What I learned

Apart from the obvious knowledge one gains from working with an Arduino, I saw that there is great potential, especially for children! I think this would make for an excellent hobby for anyone with the willingness!

Like Massimo Banzi  says, “You don’t need anyone’s permission to make something great.”

Materialize your site!

I ended my last post saying how awesome the Material Design is, which was revealed along with Android Lollipop a year ago. After writing a few apps on Android Studio I wondered how amazing it would be if we can have this beautiful typography, subtle transitions and animations in more places than just droids…

A few days later, when working on a web project my buddy Hisham mentioned about Materialize CSS.

Simply, this is Material Design to the web!

materialize
Materializecss.com homepage

For those who are already using bootstrap or other similar frameworks, this needs no introduction. Nevertheless, it is

a modern responsive front-end framework based on Material Design

What is the big fuss?

Material Design is based on light, shadows and how paper reacts to touches. Sounds like marketing material, but it is beautiful! The elements on your screen have a 3D perspective where cards are placed on top of one another giving a sense of depth. Labels, text and buttons cannot teleport. They take a physical movement path across your screen. The redesigned Roboto typography is both beautiful and subtle. Looks great on all display sizes and densities.

That was a short introduction. Click on the image below to learn the more in case you want to.

material principles
Material Design Principles

Getting Started

Click here to start materializing your site. The guide may not be as extensive as Bootstrap’s but it is good enough to getting you started.

Thanks to the team: Alvin, Alan, Alex and Kevin for giving us this opportunity.

I have also just begun. If you are already an expert on this area, let us know how we can customize this framework to work better. If you are also a beginner, I hope you find this post helpful!

Android Development – Why and How

Needless to say, Android has become the leader of the mobile platform market. Starting with smartphones and tablets and moving onto TV, wearables and vehicles, Android never seems to stop.

My message here is that there is never a better time to hop into Android Development, in case you are programmer or hoping to be one.

I am not here to undermine other mobile OSes. iOS, WP and BB are great too, but I have always been an android fan and the market too points in its favor.

IDC: Smartphone OS Market Share 2015, 2014, 2013, and 2012 Chart

The OS itself is Open Source and Google provides its developers many tools and services to help the process.

To re-iterate, If you are someone hoping to be an Android Developer but never tried it before, there’s never been a better time.

What do you need?

Simply put, attitude is what matters most. If you are excited about mobile industry and the pace its growing at and want to be a part of it, welcome aboard.

And of course, thirst for knowledge and creativity is also essential. But hey, if you think you are not qualified or don’t have creativity, don’t be put off. Give it your best shot and you will impress yourself. I am pretty much a beginner myself and yeah it is constant struggle. But if you love what you do, then that indeed is good news.

Knowledge and Skills

In terms of skills, you need to have the following:

Java

I think you saw this coming. Java is the world’s most popular language and fortunately for us, it is used in Android Development. If you already know Java, congratulations. If not, then do not fret. Honestly, I wasn’t very confident with my level of Java that I learnt in college despite getting a good grade in my Java projects.

So, I went back and followed John Purcell’s course on Java for beginners. And believe me, it is awesome. John is one of the best teachers you will find and he also has courses on more topics including Android. If you want to boost up your knowledge, then do check out caveofprogramming.com .

XML

Stands for eXtensible Markup Language. Bit like HTML but has custom tags. You don’t need to know a whole bunch. If you are confident with HTML this is not a big deal. If you are interested in learning, then then head over to this popular tutorial. XML is used in designing the layout for your screen (activity) and to describe functionality and requirements.

SQL

Since your app will most probably use a database, you will need to know a bit of SQLite. If you have worked with any databases like MySQL or MS SQL, that will do. Otherwise head over here once again.

Tools and Resources

After you have the above mentioned required skills, you need the following tools to get started:

Android Studio

Android Studio Splash Screen

This will be your IDE (the software used to create software). Eclipse with ADT was used previously but Google’s current recommendation is this awesome tool built on top of IntelliJ IDEA Community Edition (another popular IDE). Head over here to the official download page.

Development Kits

You will need Java Development Kit (JDK) and Android Software Development Kit (SDK). The good news is that the SDK comes built in. If you want to download the JDK, then head over here.

I am currently using the latest JDK 8 but Google recommends JDK 7. Head onto the previously mentioned link and choose the version you want and the platform you want to run it on.

Helpful Material

I have a few recommendations here:

1. Android Documentation – This is tremendously useful if you are capable of reading an implementing the described procedures. Click here for training documentation and here for the API Guides.

2. Video Tutorials – There are a few helpful Android video tutorials that will be very useful for in case you prefer watching videos and learning.

Bucky Roberts is a great teacher and will get you up and running in developing Android apps within a short period. Visit his Android Course on thenewboston.

3. Google – If you are already a programmer, you know how tremendously useful Google can be. If not, you should know it. Whenever you encounter an error/exception just ask Google. You will not be disappointed most of the time.

Get Started!

All the resources/tools that I have mentioned are free of charge and supports most platforms.

If you find this post helpful, then I am happy. Leave your comments below and let me know your suggestions.

One last thing. Android M was announced yesterday. And believe me it’s getting better and better. And the Material Design introduced in Lollipop is pure awesomeness. If you are an Android user, I don’t have to say.

So what are you waiting for?

You will never know if it is difficult if you never tried.

Welcome

Hi there. Welcome to my little blog!

In case you were wondering, mtwo stands for my name: Muhammad Muhsin.

What am I planning to do with this blog?

This will essentially be a personal tech blog. You will mostly find little programming projects and tips, about web development and networking.

My other main interest is mobile phones (or should I say smartphones?). My opinions on tech gadgets and phones will also be here.

I am interested in photography and occasionally take some pictures. You will some of them too.

I am a student following a Software Engineering degree from University of Plymouth, UK in partnership with NSBM, Sri Lanka.

At the end of second year now and one of the most significant lessons I have learnt so far: The Importance of Learning by Yourself.