Sunday, October 16, 2016

How to test the pf range of a Variable Capacitor with an arduino uno or any atmega328 boards [beginner]

Variable capacitor for a simple loop antenna for receiving
A variable capacitor is useful in various projects like magnetic loop antennae, crystal radio and in making antenna tuners. It is often necessary to know the range (max and minimum pf value) of the capacitor for designing its application and to choose optimal coils for covering the suitable area of the rf spectrum.

The solution is a capacitance meter. But for a pure diy enthusiasist, it may be often useful to measure it with our own tools and i used an arduino uno to do the job. See attached video

The basic circuitry and principles are the same as in my previous post on quick and dirty way to measure inductance and capacitance.

In this article i used a arduino uno hoocked to a i2c lcd and the capacitance measurement happens between pin A0 and A2


Connect the i2c lcd to i2c pins on the uno (A4 (sda) and A5 (clock)) and connect the test capacitor with a small wire to A0 and A2  and load the firmware

Firmware for the capacitance tester  (download)

Source code details (read here)

More on air variable capacitor (toy demo)

A simple video showing some application of the capacitance meter for learning how a split stater capacitor functions. See video

Wednesday, September 21, 2016

Use any infrared remote to control an RGB led with an arduino uno [beginner]

This is a very simple tutorial article for those who want to start using an infrared remote with an arduino for controlling different things. This will cover the basic principles and can be used to perform complicated things as in my previous posts here and here

Things needed

1) An arduino uno or compatible boards (atmega328 based)
2) IR Receiver Module 38 kHz TSOP4838  (ebay)
3) 3 Colour RGB  LED Module
4) A TV remote or any ir remote
5) Connecting wires

Connecting things

Connections are pretty simple, being beginners tutorial i will explain a bit: See the figure below

IR module has a vcc and gnd pin which is connected to 5volt pin and ground pin on the arduino. Similarly there are four connections on the rgb led, the common ground is connected to ground (-ve) pin on arduino and each colour is connected to digital pins (D9, 10 and 11 respectively)

Uploading the firmware

Now connect the usb cable and connect it to the computer with arduino software. It needs a library for infrared remotes which can be downloaded from here. After setting up the library paste the source code below and upload to the arduino.

Now after uploading the code and if you have an nec remote, pressing 7, 8, and 9 will turn on each colors on the rgb led and 4,5,and 6 will turn it off. If nothing happens and probably you have some other remote controls, just open a serial monitor  (it is a window on the arduino software, see here) and set it to 9600 and start pressing the remote buttons to see some numbers appearing over there. Just replace those numbers in the section below ( complete source code at the end of the article)

     if(results.value==3782926367)  // number 7
     digitalWrite(led, HIGH);  
     else if (results.value==3782877407)  //number 4
     digitalWrite(led, LOW);  
     // result  
     if(results.value==3782873327)  //number 8
     digitalWrite(blue, HIGH);  
     else if (results.value==3782910047) //number 5 
     digitalWrite(blue, LOW);  
     // result  
     if(results.value==3782905967)  //number 9
     digitalWrite(green, HIGH);  
     else if (results.value==3782893727)  //number 6
     digitalWrite(green, LOW);  

See the video :

Source code 

 /* Include the IRremote library */  
 #include <IRremote.h>  
 /* Define the DIO pin used for the receiver */  
 #define RECV_PIN 5  
 /* Structure containing received data */  
 decode_results results;  
 /* Used to store the last code received. Used when a repeat code is received */  
 unsigned long LastCode;  
 /* Create an instance of the IRrecv library */  
 IRrecv irrecv(RECV_PIN);  
 int led = 9;  
 int green = 10;  
 int blue = 11;  
 void printHex(int num, int precision) {  
   char tmp[16];  
   char format[128];  
   sprintf(format, "0x%%.%dX", precision);  
   sprintf(tmp, format, num);  
 void setup()  
   /* Configure the serial port to display the received codes */  
   /* Start receiving codes */  
   /* Initialise the variable containing the last code received */  
   LastCode = 0;  
   pinMode(led, OUTPUT);  
   pinMode(blue, OUTPUT);  
   pinMode(green, OUTPUT);  
 /* Main program */  
 void loop()  
   /* Has a new code been received? */  
   if (irrecv.decode(&results))  
     /* If so get the button name for the received code */  
     digitalWrite(led, HIGH);  
     else if (results.value==3782877407)  
     digitalWrite(led, LOW);  
     // result  
     digitalWrite(blue, HIGH);  
     else if (results.value==3782910047)  
     digitalWrite(blue, LOW);  
     // result  
     digitalWrite(green, HIGH);  
     else if (results.value==3782893727)  
     digitalWrite(green, LOW);  
     /* Start receiving codes again*/