Show Posts
Pages: 1 2 [3]
31  Using Arduino / General Electronics / Re: Voltage divider problem on: January 01, 2013, 07:51:49 pm
Why the extra 1K resistor before the A0-pin?
32  Using Arduino / General Electronics / Re: Voltage divider problem on: January 01, 2013, 07:46:22 pm
What are the exact voltages measured at the battery, the Arduino +5V pin and the analog input pin when it's connected up?

The +5 pin is 4.55V and the battery is 11.68V.
33  Using Arduino / General Electronics / Re: Voltage divider problem on: January 01, 2013, 07:04:43 pm
To clarify, this picture shows how I've done.

34  Using Arduino / General Electronics / Voltage divider problem on: January 01, 2013, 06:06:23 pm
My goal is to read voltage from either a 2S or 3S lipo-battery which means that to read it with my arduino I need to reduce the voltage. I had some 100K and 10K resistors at home so I built a voltage divider using these. I measured the resistors to be R1=98700 and R2=9790. As can be seen in the code I use a variable called voltage_divider that has these values which I use when reading the voltage. The voltage is read using the Vin pin, there I connect R1 & R2 then connect to ground. I read the voltage over R2 into the A0-pin.

The problem is that I get a value that's close to the correct value but too far away to be acceptable. For example, a voltage of 4.55V reads 4.35V and 11.68V reads 11.45V.

Can anyone spot an obvious error?

#include <LiquidCrystal.h>

//LCD display pinout - YM2004A & OV1604A
//VSS   LCD pin 1     -  Connect to ground
//VDD   LCD pin 2     -  Connect to +5V
//V0    LCD pin 3     -  Connect to potentiometer
//RS    LCD pin 4     -  Arduino pin D07 
//RW    LCD pin 5     -  Connect to ground
//EN    LCD pin 6     -  Arduino pin D08
//DB4   LCD pin 11    -  Arduino pin D09
//DB5   LCD pin 12    -  Arduino pin D10
//DB6   LCD pin 13    -  Arduino pin D11
//DB7   LCD pin 14    -  Arduino pin D12
//ELA   LCD pin 15    -  Arduino pin D13
//ELK   LCD pin 16    -  Connect to ground
//LiquidCrystal lcd(7, NULL, 8, 9, 10, 11, 12);
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

int screen_backlight = 13;                 //pin D13 will control the backlight
float voltage_battery = 0;                 //pin A0
float voltage_divider = (98700+9790)/9790;    //((R1+R2)/R2)*voltage on A0-pin

void setup() {
  pinMode(screen_backlight, OUTPUT);       //LCD Setup
  digitalWrite(screen_backlight, HIGH);    // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
  lcd.begin(20,4);                         // columns, rows.  use 16,2 for a 16x2 LCD, etc.
  lcd.clear();                             // start with a blank screen
  lcd.setCursor(0,0);                      //LCD text row 1
  lcd.print("Ui      V");

void read_voltage() {
  //Voltage input, U must be lower then 5V, HW-diveded then SW-multiplied
  voltage_battery = analogRead(A0)*voltage_divider*5/1023;

void screen_print() {
//Printing battery voltage level on LCD-screen
  if(voltage_battery<10) {
    lcd.print(" ");

void loop() { 
35  Development / Other Software Development / Re: Arduino simulator. on: December 09, 2012, 06:31:45 am
Hello, I love the GUI of your simulator, IMO the best so far. I've tried the version you've uploded to sourceforge and find it very intuitive to use.

Any plans on making a LCD screen soon, many applications use such screens in various sizes (16x2, 16,4 or 20x4)?
36  Topics / Education and Teaching / Re: Arduino Simulator Open Source in c++ using free CPP Dev Compiler on: December 09, 2012, 06:16:50 am
Interesting project, have you seen the SimulIDE?

Pages: 1 2 [3]