SetNFix
Published © LGPL

Arduino UV Meter with 1530 Levels

LED indicators to show Dark or Light Level

BeginnerFull instructions provided3,439
Arduino UV Meter with 1530 Levels

Things used in this project

Hardware components

LDR, 5 Mohm
LDR, 5 Mohm
×1
Rotary Potentiometer, 1 Mohm
Rotary Potentiometer, 1 Mohm
×1
Arduino UNO
Arduino UNO
×1

Hand tools and fabrication machines

Mastech MS8217 Autorange Digital Multimeter
Digilent Mastech MS8217 Autorange Digital Multimeter
Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

UV level meter

Circuit Diagram

Code

ARduino Code

Arduino
Upload this code
/*
  * Programmed by : BMIAK Basnayaka
  * Youtube Channel : SetNFix
  * Name : Arduino UV Level Meter with 1530 levels
  * Date : 09th May, 2020
  * email : bmiakbasnayaka@gmail.com
  * Blogspot  :https://setnfix.blogspot.com
  * Website : http://www.setnfix.com
  * Arduino : https://create.arduino.cc/projecthub/SetNFix
  * FaceBook : https://www.facebook.com/setnfix
  * Hackster : https://www.hackster.io/SetNFix
 */


// Pins of 6 LEDs
int led1 = 3;
int led2 = 5;
int led3 = 6;
int led4 = 9;
int led5 = 10;
int led6 = 11;

int ldr = A0;//LDR sensor pin
int sen = A1;//10k Potentiometer

//All the bulbs are off at the beginning
int a=0;
int b=0;
int c=0;
int d=0;
int e=0;
int f=0;


int bright = 0; // Analog level is 0 (LED off 0 -255 on)
int ldrlevel = 0; // Analog read of LDR
int senlevel = 0;// Analog Read of potentiometer



void setup() {
  pinMode(led1,OUTPUT);
  pinMode(led2,OUTPUT);
  pinMode(led3,OUTPUT);
  pinMode(led4,OUTPUT);
  pinMode(led5,OUTPUT);
  pinMode(led6,OUTPUT);
  pinMode(ldr,INPUT);
 pinMode(sen,INPUT);
Serial.begin(9600);
Serial.print("SetNFix Youtube Channel");
 
}

void loop() {

ldrlevel = analogRead(ldr);
senlevel = analogRead(sen);
//delay(100);




bright = map(ldrlevel,senlevel,1023,0,1530);

//if (bright<0) bright =0;
Serial.println(bright);
a = bright;
b = bright - 255;
c = bright - 510;
d = bright - 765;
e = bright - 1020;
f = bright - 1275;

if (a >255) a=255;
if (b >255) b=255;
if (c >255) c=255;
if (d >255) d=255;
if (e >255) e=255;
if (f >255) f=255;


if (a < 0) a=0;
if (b < 0) b=0;
if (c < 0) c=0;
if (d < 0) d=0;
if (e < 0) e=0;
if (f < 0) f=0;


analogWrite(led1,a);
analogWrite(led2,b);
analogWrite(led3,c);
analogWrite(led4,d);
analogWrite(led5,e);
analogWrite(led6,f);


}

Credits

SetNFix

SetNFix

17 projects • 35 followers
I am an accountant in profession but, I would more prefer to work with electronics based innovations.

Comments