Potentiometer

There are lots of analog devices that people are using to build their Arduino projects. One of the most common component is the potentiometer. There are lots of different types potentiometer in the market but all of them serve the same purpose, an adjustable resistor or an adjustable voltage divider.

arduino potentiometer

Various Potentiometer

The schematics diagram below explains how the potentiometer works as the voltage divider, the voltage value changes when adjust the potentiometer.

potentiometer schematic diagram

Potentiometer Schematic Diagram

You can imagine the pencil lead as a potentiometer, a battery cell are hookup on both ends of the pencil lead and you use and voltmeter to measure the voltage value at any point between the both ends of the pencil lead.

demonstrate potentiometer

Demonstrate Potentiometer

I have created 2 Arduino tutorials to demonstrate  how to use the potentiometer as the analog input, the 2 Arduino tutorials are Arduino Analog Input and Arduino PWM.



Sponser Links


If your want to learn more about basic electronics, you can consider this Arduino Mega 2560 Ultimate Complete Starter Kit.

< BACK

Posted in Generals | Tagged , , | 1 Comment

Arduino PWM

PWM stands for Pulse Width Modulation. Arduino uses this powerful PWM technique for controlling analog circuits with its digital outputs. Digital control uses to be only turn on (full 5v) or off (0v) in the binary format, and this on/off pattern can generate a square wave signal. For example if you want a LED to be half bright, you can either reduce the current across the LED into half or using this the more flexible PWM technique by sending 50% duty cycle square wave signal to the LED.

Arduino PWM wave signal

Arduino PWM Wave Signal

This simple Arduino tutorial is created to demonstrate how to dim a LED by using this PWM technique from Arduino. Different model of the Arduino boards have different number of the PWM digital output, if you want to know more about your Arduino board configuration please visit my previous post Which Arduino board is for me?



Sponser Links


What you need for this tutorial?

  • Any of the Arduino Board (Arduino UNO will be used in this example)
  • 1 x Potentiometer,
  • 1 x 220Ω resistor, (or any resistor that suits your LED)
  • 1 x LED (any color based on your mood),
  • 1 x Breadboard.

Connect your circuit as the below diagram.

Arduino PWM Diagram

Arduino PWM Circuit Diagram

I am using digital pin 3 as the PWM output in this example or you can use any pin that marked with PWM (if you are Arduino UNO, PIN 3, 5, 6, 9, 10 and 11 support PWM).

Arduino Code:

int inputPin = A0;  // set input pin for the potentiometer
int inputValue = 0; // potentiometer input variable
int ledPin = 3;     // set output pin for the LED

void setup() {
     // declare the ledPin as an OUTPUT:
     pinMode(ledPin, OUTPUT);
}

void loop() {
     // read the value from the potentiometer:
     inputValue = analogRead(inputPin);

     // send the square wave signal to the LED:
     analogWrite(ledPin, inputValue/4);
}

analogRead() will always return the range between 0 to 1023 from the analog device (the potentiometer in this case), but the analogWrite() function only supports the range from 0 to 255. e.g. analogWrite(127) always send a 50% duty cycle to the LED, analogWrite(255) is a full 100% duty cycle (full brightness) and analogWrite(0) is always off.



Sponser Links


You can test out this tutorial by turning the potentiometer, the brightness of the LED changes ranging from completely off to the full brightness as you turn the potentiometer.

< BACK

Posted in Projects | Tagged , , , | 7 Comments

Arduino Shield

What is the Arduino Shield? A lot of people are saying that the Arduino board is like a mini cpu, if this is the case then the Arduino shields are like the printer, scanner, monitor, mouse and etc to the Arduino boards. Arduino shields are small pieces of PCB boards that expanding the Arduino main board capabilities. Example: An Arduino GPS shield that able to read the GPS coordinate and pass to the Arduino board for action or an Arduino ethernet shield that turn on the network capabilities for your Arduino projects.



Sponser Links


Since Arduino is an open-source project, there are a lot of third parties Arduino shields in the market. Here are some of the common Arduino shields that you can get from the market, some of them are really cheap:

Arduino LCD Shield LCD Arduino Shield is available in Amazon
Arduino Ethernet Shield Ethernet Arduino Shield is available in Amazon
Arduino GPS Shield GPS Arduino Shield is available in Amazon

Arduino shields are built so that they can easily stack over the Arduino main board to reduce implementation space and wiring works.

arduino shield

Arduino shields stack on top of an Arduino board

< BACK

Posted in Hardware | Tagged , | 1 Comment

Arduino Analog Input

This tutorial will show you how to read data from the Arduino analog input. There are few types of analog I/O components out there, therefore it will be very useful once you have mastermind the Arduino analog input. Some example of the analog components are thermistor (temperature dependent resistor), photo-resistor (light dependent resistor, LDR) and the widely used potentiometer.



Sponser Links


Potentiometer is a simple knob that provides a variable resistance. Therefor you can use the Arduino analog input to read its value. Click here to read more about potentiometer.

potentiometer

Potentiometer

What you need for this tutorial?

  • Any of the Arduino Board, I am using Arduino UNO here,
  • 1 x Potentiometer,
  • 1 x LED (any color based on your mood).

Connect your circuit as below (I am using Fritzing to draw my diagram, you can read my previous article about Fritzing here):

arduino analog input

Arduino Analog Input

Left pin of the potentiometer connects to the 5v, right pin connects to the ground and the middle pin connects to any of the analog in (I am using analog in pin 0 in this example). Connect the long LED pin to the Digital pin 13 and short pin to the ground, you have to ensure that it is in the correct direction as LED is a type of the diode, it only allow current to flow in 1 direction.

Arduino Code:

int inputPin = A0;  // set input pin for the potentiometer
int inputValue = 0; // potentiometer input variable
int ledPin = 13;    // set output pin for the LED

void setup() {
     // declare the ledPin as an OUTPUT:
     pinMode(ledPin, OUTPUT);
}

void loop() {
     // read the value from the potentiometer:
     inputValue = analogRead(inputPin);

     // turn on the LED:
     digitalWrite(ledPin, HIGH);

     // pause the program for  milliseconds:
     delay(inputValue);

     // turn off the LED:
     digitalWrite(ledPin, LOW);

     // pause the program for for  milliseconds:
     delay(inputValue);
}

No mater how you turn the potentiometer, it will always give you the analog voltage value between 0 – 5v, and the Arduino analog input will convert it to the digital value of 0 to 1023 (total of 1024 levels). When you turn the potentiometer to the 0v end, the analogRead() function should return 0 and when you turn the potentiometer to the 5v end, the analogRead() function should return 1023. Then this value will be stored into the  integer variable named inputValue and will be used by the delay() function for the LED blinking duration.

< BACK

Posted in Projects | Tagged | 2 Comments

Arduino Memory

Arduino is a mini computer therefor it needs memory space to store and execute its code. Each Arduino micro controller board is built with 3 types of memory. The 3 types of Arduino memory are as below:

  • EEPROM (Electrically Erasable Programmable Read-Only Memory) is a memory area that used by programmer to store long term information and data.
  • Flash memory is a program memory space to store Arduino code or Arduino sketch.
  • SRAM (static random access memory) is like the runtime memory in the PC, it is used when a Arduino sketch has been executed and this Arduino memory is use to manipulates runtime variables.

EEPROM and Flash memory are non-volatile. These 2 types of Arduino memory will not be lost after the power is turned off. SRAM is different from the other 2 types of Arduino memory, it is volatile and all information in SRAM will be lost when the power is turned off.



Sponser Links


Different Arduino boards are build with different size of the memory. Below are the memory size information for the most common Arduino micro controllers:

  • ATMega168 – 16KB Flash, 1KB SRAM, 512Bytes EEPROM.
  • ATMega328p – 32KB Flash, 2KB SRAM, 1KB EEPROM.
  • ATMega1280 – 128KB Flash, 8KB SRAM, 4KB EEPROM.
  • ATMega2560 – 256KB Flash, 8KB SRAM, 4KB EEPROM.

Below is a summary Arduino boards memory comparison chart:

Arduino memory comparison chart

Normally there are 1 KB of Arduino flash memory is reserved to be used by the bootloader.

< BACK

Posted in Hardware | Tagged , | 1 Comment

Arduino Simulator

Want to try out the Arduino development before spending more money on the Arduino board, Arduino shield and some electronic components? If you are an Apple iOS device owner, you can spend just USD2.99 for a basic software based Arduino simulator. There are some in-app purchases that make your development more interesting (e.g. Arduino and LCD, Arduino and Motors, LED Matrix and etc.)

arduino simulator

Screenshot for the Arduino Simulator

Just drag and place the wires in the correct positions to connect between Arduino and the breadboard. Once satisfied, you can export the tested code and email it. The code can be easily copied and used in an actual project from the email.



Sponser Links


You can purchase or read more about this Arduino simulator from this iTunes link.

Pros:

  • Safe for kids
  • Low cost
  • Environment Friendly

Cons:

  • Limited expandability
  • Not so interesting as real board
  • Only for iOS owner

< BACK

Posted in Software | Tagged , | 1 Comment

What is Arduino?

What is Arduino? What can this tiny board do? These are some of the most popular questions people is asking in the cyber world when they first get in touch with this small yet powerful board.



Sponser Links


There are tons of explanations, descriptions, bla-bla…. in this cyber world regarding Arduino, but mama said picture can tell thousand words :)… and here Jody Culkin come out an awesome comic way by telling you what is the Arduino. You can read it HERE. Enjoy reading.

arduino pdf

Arduino Comic by Jody Culkin

< BACK

Posted in Reading Materials | Tagged , | Leave a comment

Arduino Prototyping Tool, Fritzing

Arduino Prototyping Tools Fritzing

Fritzing is an ultimate tool for document the Arduino-based prototype and create a PCB layout for manufacturing. Similar to Arduino, Fritzing is also an open-source project. There are tons of electrical components library predefined for you or you can create some yourself. It supports breadboard, schematic and PCB views.

fritzing arduino prototype software

Fritzing Arduino Breadboard View

fritzing arduino schematic prototype

Fritzing Arduino Schematic View

Fritzing is a powerful Arduino prototyping software but it is not a Arduino board software simulator.



Sponser Links


Latest version of Fritzing can be downloaded from Fritzing Official Website.

< BACK

Posted in Software | Tagged , , | 4 Comments

Which Arduino board is for me?

There are more than a handful of original Arduino boards and 100% clone Arduino boards in the market, and which one is for me? In fact every Arduino boards are built to suit different need, below are some of them that are more popular:

1. Arduino UNO

Arduino UNO

Arduino UNO

Arduino UNO is one of the most famous board in Arduino family after Arduino Duemilanove. It is the latest design of the basic USB board. It comes with 6 analog inputs, 14 digitals output where 6 of them support PWM, and 16Mhz clock speed. Arduino UNO comes with 6 analog inputs and 14 digital I/O where 6 of them are PWM outputs. It is running on a ATmega328 processor with 32kB flash memory. The clock speed of this Arduino board is 16Mhz with the dimension of 68.6mm x 53.3mm. There are a lot of shields build to expend its functionality.



Sponser Links


You can get the latest Arduino R3 board from Amazon (Official Reseller) for a reasonable price or you can search for previous revision R2 at lower price in the Amazon.

2. Arduino Mega

Arduino Mega2560 Mega

Arduino Mega2560

Arduino Mega is a larger and more powerful Arduino board. There are 2 types of Arduino Mega in the market, both of them are having the same dimension of 101.6mm x53.3mm, having 16 analog inputs and 54 digitals I/O (14 that support PWM). Even though both of the Arduino Mega and Mega256 are running on the same clock speed of 16Mhz but in reality they are built with 2 different processors, Mega is built on ATmega1280 processor with 128kB flash and Mega256 is built on ATmega2560 processor with 256kB flash. These Arduino boards is suitable for those projects that need more inputs and outputs.

Arduino Official Reseller is selling the original R3 version of Arduino Mega in Amazon and you can get even cheaper from other reseller for a R3 or non-R3 version.

3. Lilypad Arduino

LilyPad Arduino

LilyPad Arduino

Lilypad Arduino is famous of its design, it is different from other boards, it is not in rectangle shape but in a round shape of 50mm diameter. It is designed for flexibility so that it is easier to wear, you can stitch it on any fabric.

LilyPad Arduino Flexibility

LilyPad Arduino is designed for Flexibility

It is running on either ATmega168V or ATmega328V processor which is low power version of ATmega168 and ATmega328. It has 16kB of flash memory, 14 digitals I/O with 6 that support PWM, 6 analog inputs and with the clock speed of 16Mhz.

You can get this flexible Lilypad Arduino from Amazon or if you want the kit that comes with more components you can order the Lilypad Pro Kits from Amazon.

4. Arduino Nano 3.0

Arduino Nano 3

Arduino Nano 3

As its name, Arduino Nano is a compact and breadboard-friendly version board based on ATmega328 processor. It is more or less same functionality as the Arduino UNO but in different package. Instead of using the standard USB to connect to the computer, it uses the mini usb but without the power plug for external power source that built on Arduino UNO. The dimension of Arduino Nano is only 43mm x 18mm, it comes with 6 PWM I/O from the total of 14 digitals I/O, 8 analog inputs, 16Mhz clock speed and 32kB of flash memory.

The Arduino Official Shop at Amazon is selling this original tiny Arduino board, Arduino Nano 3.0 (packaging as the photo below) and it is the latest version 3 model.

Arduino Boards Comparison Chart

Arduino board comparison chart



Sponser Links


Summary

In summary, for those hobbyists that new to Arduino, it is highly recommended to go for Arduino UNO because of its expandability, price and ease of use where you can easily connect to any computer through its USB port. For those that need more I/O and larger program, Arduino Mega2560 might be you choice. LilyPad Arduino is targeted for special project where you need to stitch it on any cloths.

You can checkout the some newer board like Arduino Due article here.

< BACK

Posted in Hardware | Tagged , , , , , | 4 Comments

Arduino Programming Software

In order to start writing code for your Arduino board you need to download Arduino Development Environment (IDE), this official Arduino programming software. This piece of software contains a text editor for code writing, a series of function buttons and menus. This Arduino programming software is able to communicate and upload programs to the any Arduino hardware.



Sponser Links


Sketches are the programs that written for Arduino hardware. All sketches are save in the .ino file extension (versions of the IDE prior to 1.0 saved sketches with the extension .pde). The Arduino IDE is similar to any text editor that supports text copy, cut, paste, search and replace. There is a console or message are at the button of the window, it will display error messages, sketches upload status and etc.

arduino programming software

Arduino IDE Toolbar Buttons

There are 6 buttons in the Arduino IDE. The 1st button is the verify button, it will verify and check your code for errors. The 2nd button is the upload button, it is used to compile and upload your code into the Arduino micro-contoller. The 3rd button is the new button, it will create an empty new sketch when pressed. The 4th button is to open a  previous saved sketch. The 5th button is to save the existing sketch. The last button, Serial Monitor is used to display the data that send from Arduino board back to the computer via the serial port or USB.



Sponser Links


You can download the latest version of the official Arduino programming software from the Arduino official website. There are Windows, Mac OSX and both Linux (32/64 bits) versions.

< BACK

Posted in Software | Tagged , | 1 Comment