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.

Arduino UNO
Arduino UNO

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 the 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);
}

view raw
AdjustBrightness.ino
hosted with ❤ by GitHub

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.”

1 Comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.