Arduino - LCD1602 Home Made DIY VOLTMETER

Toon hier Uw afgeronde projecten aan anderen.
Berichten: 9
Geregistreerd: 12 Mei 2016, 01:43

Arduino - LCD1602 Home Made DIY VOLTMETER

Berichtdoor arduinosensorsNL » 21 Okt 2016, 00:05

Een zelfgemaakt simpele voltmeter, erg goedkoop om te maken!

bekijk de video hier:https://youtu.be/1caf1NXiPmo

Schema:
Afbeelding

Onderdelenlijst:
Arduino uno, i used the RobotDyn Uno. (has 8 analog pins)
LCD 1602
Breadboard or a PCB ProtoType Board.
10k Potentiometer.
5x 10k Resistor
2x 2.2k Resistor
Jumper wire set MM/FF/FM


De Code:
Code: Alles selecteren
/*
Author: Danny van den Brande. Bluecore Tech, Arduinosensors.nl
This is a simple voltmeter.
 */
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// variables for input pin and control LED
  int analogInput = 1;
  float vout = 0.0;
  float vin = 0.0;
  float R1 = 50000.0;    // !! resistance of R1 !!
  float R2 = 4400.0;     // !! resistance of R2 !!

  int value = 0;

void setup(){
  pinMode(analogInput, INPUT);
  lcd.begin(16, 2);
  lcd.setCursor(1, 0);
  lcd.print("BlueCore Tech");
  delay(2000);
  lcd.clear();
  lcd.print("Volt=");
}

void loop(){
  value = analogRead(analogInput);

  vout = (value * 5.0) / 1024.0;
  vin = vout / (R2/(R1+R2)); 

  lcd.setCursor(6, 0);
  lcd.print(vin);
  lcd.print("V");

  delay(500);
}


Volgende code is nodig als je een lcd hebt met I2C.

Code: Alles selecteren
/*
Author: Danny van den Brande. Bluecore Tech, Arduinosensors.nl
This is a simple voltmeter.
 */
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

// initialize the library with the numbers of the interface pins
//Most common adresses PCF8574 = 0x20, PCF8574A = 0x38,PCF8574AT = 0x3F
//PCF8574T = 0x27   
#define I2C_ADDR          0x27   
#define BACKLIGHT_PIN      3
#define En_pin             2
#define Rw_pin             1
#define Rs_pin             0
#define D4_pin             4
#define D5_pin             5
#define D6_pin             6
#define D7_pin             7

// variables for input pin and control LED
  int analogInput = 1;
  float vout = 0.0;
  float vin = 0.0;
  float R1 = 50000.0;    // !! resistance of R1 !!
  float R2 = 4400.0;     // !! resistance of R2 !!

  int value = 0;
LiquidCrystal_I2C      lcd(I2C_ADDR, En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
void setup(){
  pinMode(analogInput, INPUT);
  lcd.begin(16, 2);
  lcd.setCursor(1, 0);
  lcd.print("BlueCore Tech");
  delay(2000);
  lcd.clear();
  lcd.print("Volt=");
}

void loop(){
  value = analogRead(analogInput);

  vout = (value * 5.0) / 1024.0;
  vin = vout / (R2/(R1+R2)); 

  lcd.setCursor(6, 0);
  lcd.print(vin);
  lcd.print("V");

  delay(500);
}


Ga hier naar de instructable! http://www.instructables.com/id/Arduino-Home-Made-DIY-VOLTMETER/
Sensors voor arduino! http://arduinosensors.nl

Advertisement

Terug naar Afgeronde projecten

Wie is er online?

Gebruikers in dit forum: Geen geregistreerde gebruikers en 5 gasten