Arduino Beginner Series: Project 9: LED voltage indicator

Hello everyone!! Welcome to this post on Arduino LED Projects!!
Need a short introduction to what the Arduino is then click on LINK
Check out the breadboard intro right HERE

So in this project we’ll make use use of LEDs to indicate the voltage which varies with the variable resistance (potentiometer). The Arduino supplies a max of 5 volts. This system turns Red LED on if voltage is above 5 volts, Yellow LED if voltage is between 3 and 4 volts and Green LED if voltage is below 3 volts.

Demo:

Here is what my project looks like:

Things Required:

  1. Arduino UNO
  2. LEDs (1 of green, red, yellow each)
  3. Breadboard
  4. 220 ohm resistor (x3)
  5. Jumper Wires
  6. 10 k potentiometer
  7. Arduino IDE on computer

Functions used:

  1. digitalWrite()
  2. Serial.println()
  3. analogRead()

Reference Material:

Here is a reference video (LINK). My project is a variation of this one.

Here’s just some working (this part is more for my later reference):

Code:

View on/Download from Github: (LINK)

int redled=8;
int yellowled=9;
int greenled=10;
int potpin= A1;
int potval;
float voltage;

void setup(){
  pinMode(redled, OUTPUT);
  pinMode(yellowled, OUTPUT);
  pinMode(greenled, OUTPUT);
  pinMode(potpin, INPUT);
  Serial.begin(9600);
}

void loop(){

  potval= analogRead(potpin);
  voltage=(5.0/1023.0)*potval;
  Serial.println(voltage);

  if(voltage<=3){
    digitalWrite(redled,LOW);
    digitalWrite(yellowled,LOW);
    digitalWrite(greenled,HIGH);
  }

   if(voltage>3 && voltage<=4){
    digitalWrite(redled,LOW);
    digitalWrite(yellowled,HIGH);
    digitalWrite(greenled,LOW);
  }

   if(voltage>4){
    digitalWrite(redled,HIGH);
    digitalWrite(yellowled,LOW);
    digitalWrite(greenled,LOW);
  }
  
  
}

Stay Tuned for upcoming posts on Arduino Projects! We’re on the basic newbie projects right now and slowly, gradually move on to those cool, ultra techy projects!! Want to be the first to know when a new and amazing post comes up?? Then feel free to subscribe!

Happy Learning!!

Leave a Reply

PHP JS HTML CSS BASH PYTHON CODE

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: