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?

https://gist.github.com/m-muhsin/05db5c39550845677288

I have also put it on a GitHub repo. Find it inside the ‘AdjustRGB‘ folder. Feel free to fork and improve it!

IMG_20151226_125136620
Powering it from batteries

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

2 responses to “Arduino: a revamped tiny Sketch”

  1. Sabri Avatar
    Sabri

    Very nice. Seems like it’s easy to get up to speed with!

    A few highlights from the code would have been interesting for someone like me who likes coding 🙂

    Putting the full code on github is a nice touch. Keep up the good work!

    1. Muhammad Muhsin Avatar

      Thanks for your comment Sabri!

      Exactly! That could be the very reason for its popularity.

      Updated the post with the whole code. Will add code highlights in future if the full code is too big to go in here 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *