Hackster is hosting Impact Spotlights: Industrial Automation. Watch the stream live on Thursday!Hackster is hosting Impact Spotlights: Industrial Automation. Stream on Thursday!
InnoVech
Published

Lesson 10 - Voltage Meter

In this lesson, we will be applying what we have learnt and program a system using Arduino.

IntermediateProtip1 hour686
Lesson 10 - Voltage Meter

Things used in this project

Story

Read more

Code

Voltage Meter

Arduino
Lesson 10
//Complete Guide to Arduino
//Created by Zaqyas Mahmood, InnoVech
//Lesson 10 VU METER


#include <TimerOne.h>
#include <MultiFuncShield.h> 

const int H_LED = 13;
const int L_LED = 10;

void setup() {
  pinMode(H_LED, OUTPUT);
  pinMode(L_LED, OUTPUT);
  Timer1.initialize();
  MFS.initialize(&Timer1);  

}

void loop()
{
  int sensorValue = analogRead(A0);
  float voltage = sensorValue * (5.0 / 1023.0);

  if(voltage < 2){
    digitalWrite(L_LED, LOW);
    MFS.write("L");
  }
  else if(voltage > 3){
    digitalWrite(H_LED, LOW);
    MFS.write("H");
  }
  else{
    digitalWrite(L_LED, HIGH);
    digitalWrite(H_LED, HIGH);
    MFS.write(voltage);
  }
}

Credits

InnoVech
11 projects • 8 followers
We strive to share our projects with engineering hobbyists and students who are driven to play their roles in the future of engineering.
Contact

Comments

Please log in or sign up to comment.