Make an Arduino Voltmeter
This is a very simple project for microcontroller beginners.
Board I'm using in this tutorial is Arduino Uno (R3), but you can use any board with slight changes in code (or no changes at all!).
Good luck!
Make an Arduino Voltmeter
This is a very simple project for microcontroller beginners.
Board I'm using in this tutorial is Arduino Uno (R3), but you can use any board with slight changes in code (or no changes at all!).
Good luck!
Parts List:
- Arduino Board
- PC with Arduino IDE
- 5 LEDs (Light Emitting Diode)
- 5 resistors (about 300Ω, you don't have to be very accurate here)
- potentiometer (value does't really matter, you will only use it to simulate voltage change)
- some jumper wires
- a breadboard
- and basic programming knowledge
The Logic Behind It:
Each LED represents 1 volt, potentiometer is used as a fake "load", program is very simple simply determine the "space" between each volt and use if loops to make LEDs turn on/off
Connecting Everything Together
Use the picture as a guide (i use pins 2-6 for LEDs and A0 for potentiometer and I use the same in the code so change if necessary)
Don't forget to connect GND to LEDs too!!! (Sorry, I missed that while making this picture)
The Code
//I will just dump the entire code in the section below
//code looks a bit long, but it's not
//enjoy
//check the value with multimeter, pretty accurate huh
//you have the code now play with it, change it, make it better, add buzzer or some sh*t have fun with it.
//this code is open source but please keep the last line of it (the comment) int pot = A0;
int gled0 = 2; //all LEDs are connected with 330Ω resistor int gled1 = 3; int gled2 = 4; int yled0 = 5; int rled0 = 6; void setup(){ Serial.begin(9600); pinMode(pot, INPUT); pinMode(gled0, OUTPUT); pinMode(gled1, OUTPUT); pinMode(gled2, OUTPUT); pinMode(yled0, OUTPUT); pinMode(rled0, OUTPUT); digitalWrite(gled0, LOW); digitalWrite(gled1, LOW); digitalWrite(gled2, LOW); digitalWrite(yled0, LOW); digitalWrite(rled0, LOW); } void loop(){ Serial.println(analogRead(pot)); if(analogRead(pot) >= 205){ // 1V digitalWrite(gled0, HIGH); delay(4); } if(analogRead(pot) >= 410){ // 2V digitalWrite(gled1, HIGH); delay(4); } if(analogRead(pot) >= 615){ // 3V digitalWrite(gled2, HIGH); delay(4); } if(analogRead(pot) >= 820){ // 4V digitalWrite(yled0, HIGH); delay(4); } if(analogRead(pot) >= 1023){ // 5V digitalWrite(gled0, HIGH); digitalWrite(gled1, HIGH); digitalWrite(gled2, HIGH); digitalWrite(yled0, HIGH); digitalWrite(rled0, HIGH); delay(150); digitalWrite(gled0, LOW); digitalWrite(gled1, LOW); digitalWrite(gled2, LOW); digitalWrite(yled0, LOW); digitalWrite(rled0, LOW); delay(150); } else{ // 0V digitalWrite(gled0, LOW); digitalWrite(gled1, LOW); digitalWrite(gled2, LOW); digitalWrite(yled0, LOW); digitalWrite(rled0, LOW); } } //by filip.skalec //\\I hope you liked this tutorial//\\