Tutorials with Arduino: UV meter via Headphones out and #arduino (updated)

Screen shot 2014-03-25 at 5.15.13 AM

Here is my third proyect, it´s an level meter with led via the Headphone out of my mixing console with the Arduino UNO.

Here is the device working on video (updated video in english using the Iphone Photostudio for arduino stand):

Very simple, you read the voltage from the headphone output trough an analogic input in the arduino, and assign it to a variable

Parts List

  • Arduino UNO
  • 6 leds
  • 6 resist 220 ohm
  • 1 conector audio (audio connector)
  • 2 resistencias 2,2k


We use the 220ohm resistors for the leds, and the 2,2k for the audio input.

The code was made from some examples, the knight rider and the piezo example. I´m sure it can be optimized but i was more aware of making it work than optimizing code.

The code:

/* UV Meter (via Headphone Output)
 * --------------
 * @author: Javier Lander
 * @hardware: Javier Lander
 * www.mrlndr.com
 * twitter: @mrlndr

int pinArray[] = {2, 3, 4, 5, 6, 7};
int count = 0;
int timer = 10;
int sensorValue = 0;
int countmax;
int knockSensor = 5;
int val = 0;
int statePin = LOW;
int THRESHOLD = 100;

void setup(){
  for (count=0;count<6;count++) {
    pinMode(pinArray[count], OUTPUT);
void loop() {
  sensorValue = analogRead(knockSensor);
  if (sensorValue < 100) {
  else if (sensorValue < 300) {
  countmax = 2;
  else if (sensorValue < 350) {
  countmax = 3;
  else if (sensorValue < 400) {
  countmax = 4;
  else if (sensorValue < 450) {
  countmax = 5;
  else if (sensorValue < 500) {
  countmax = 6;
  for (count=0;count <= countmax;count++) {
   digitalWrite(pinArray[count-1], HIGH);
  for (count=6;count > countmax;count--) {
   digitalWrite(pinArray[count-1], LOW);


Related Posts

  • A very dumb and simple, but really good looking example of the Arduino UNO and LEDS. The effect of the Knight Rider Car. The idea with this example is to learn how to work with arrays on the code. (see the code below) Here is the project working on video: http://www.youtube.com/watch?v=vFqCYGdtPyY…
    Tags: the, count, arduino, for, int, tutorial, led, diy
  • Controlling Leds by the Apple Remote (video updated using the Iphone Photostudio for Arduino Stand) http://www.youtube.com/watch?v=vjnOvdJrHMo The idea originated because i´m learning a lot on Led driven home applications for lighting, and the first project i´m doing is led lighting for the kitchen (indirect). The commercial systems are very expensive,…
    Tags: the, and, led, if, tutorial, diy, arduino
  • This is a very simple proyect too. We are measuring the ambient temperature with a Thermistor (4,7k) and showing the results by an RGB Led. We are assuming the cool temperature is Blue and the hot is Red. You can see it working in this video: http://www.youtube.com/watch?v=uouKAKhgowQ The part list…
    Tags: the, led, and, tutorial, diy, arduino