Show Posts
Pages: 1 2 [3] 4 5 6
31  Using Arduino / Programming Questions / Re: Accurate voltmeter on: April 27, 2014, 06:54:09 am
Well I'm not sure I did express myself correctly.

In fact I copied/paste the code in my arduino IDE but the code is slightly different from place to place (different links).
I'm using a Mega and I need the code with the
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
    ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
  #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
    ADMUX = _BV(MUX5) | _BV(MUX0);
  #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
    ADMUX = _BV(MUX3) | _BV(MUX2);
    ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);

piece of code to properly configure my own Mega ADMUX.

That is the problem copying code without understanding it ! It can lead to serious mistake !

One more question by now.
What means thix line
result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
I wonder where the "1125300L" come from ?
On an other link, it changes to "1126400L"
I think it has something to do with the real voltage of the internal reference measured with an external Digital multimeter to calibrate a specific Arduino board.
But what would be my personal value to put in ? And what this "L" means ?

Plus what means these different piece of code ?
ADCSRA |= _BV(ADSC); // Start conversion 

  while (bit_is_set(ADCSRA,ADSC)); // measuring

  uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH 
  uint8_t high = ADCH; // unlocks both


  long result = (high<<8) | low;

I really need to dig in these stuff now, otherwise I'm stuck !
32  Using Arduino / Programming Questions / Re: Accurate voltmeter on: April 26, 2014, 05:15:13 pm
Is this Arduino ?

long readVcc() { long result; // Read 1.1V reference against AVcc
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); delay(2); // Wait for Vref to settle
ADCSRA |= _BV(ADSC); // Convert while (bit_is_set(ADCSRA,ADSC));
result = ADCL; result |= ADCH<<8;
result = 1125300L /result; // Back-calculate AVcc in mV return result; }

I know I'm not very good, but these ADMUX and ADSRA stuff have something to do with ATmega register.
I don't understand all these "_BV(MUX3)", "|" and "|=" signs.
I think, they belongs to C language...

I stuck to understand these part of the code.
33  Using Arduino / Programming Questions / Re: Arduino source code. What does the function analogRead() in C ? on: April 26, 2014, 04:36:19 pm
Arduinos use genuine C/C++. The Arduino IDE just hides some of the housekeeping nonsense.

What do you mean by "housekeeping nonsense" ?

The full Arduino source code is included with the IDE.

Sorry but I've no idea how to reach it !
34  Using Arduino / Programming Questions / Arduino source code. What does the function analogRead() in C ? on: April 26, 2014, 04:13:41 pm
Hi guyes.

I'm struggling with some stuff at the moment and the only explanation or example I find are written in C.
As you know Arduino is not  genuine C and I'd like to know where I can find information for instance how Arduino functions are written.

Let say, what an analogRead() do ?
It has to do with some ADMUX and ADCSRA stuff I guess.

Now I've been playing Arduino for a while, I think I need to go deeper and make the link between Arduino and real C language working with port and so on.

Hope I'm going the right direction.

35  Using Arduino / Programming Questions / Accurate voltmeter (or could be renamed : uC's ADC ... State of the art) on: April 26, 2014, 02:43:25 pm
Hello everybody.

Since a while I'm struggling with accurate voltmeter.

I first found this witch is absolutely interesting :

But my problem is the guy is programming in C I think, not in ARDUINO.
And I can't understand this hard stuff.

Would be somebody able to explain (put a lot of comment for each line) or do the same but in Arduino instead of raw C.

Any link welcome.

Regards to all !

36  Using Arduino / Installation & Troubleshooting / Re: CP2102 USB to UART Bridge and Pro MINI......DTR does not work on: April 09, 2014, 01:53:42 am
Ok, it works now !

1 - First, DTR has to be pulled HIGH before pulling it low OF COURSE !
So to "manually reboot the ProMini trough DTR, I first had to pull it HIGH with a 10KOhm resistor
2 - The on-board capacitor seems to be a little bet low and it doesn't work all the time. So adding a 2nd 0.1uF capacitor in parallel with the original one make it working any time I pull DTR down.

So, that way, I could verify that my ProMini DTR pin was "manually" able to work. That was the first point at least.

But it still wouldn't work with the "CP2102 USB to UART Bridge".

The thing is that the "CP2102 USB to UART Bridge" is on 3.3V and my ProMini on 5V (The ProMini has an on-board K50 regulator, I checked it). And of course connected together, the DTR pins were hold HIGH at 3.3V, not the 5V requested for a proper pulse.

Fortunately, my  5V ProMini seems to be able to work fine on 3.3V. So I fed it on 3.3V instead of 5V so the DTR pulse would be a nice straightforward .3.V HIGH to LOW level but it WORKED fine any time this way !!!

Any remark welcome.
37  Using Arduino / Installation & Troubleshooting / CP2102 USB to UART Bridge and Pro MINI......DTR does not work on: April 08, 2014, 03:08:51 pm
I've got a CP2102 USB to UART Bridge and a Pro MINI.
They both have DTR pin.
The CP2102 USB to UART Bridge
The Pro Mini I'm using.

But it won't upload sketches if I don't press the reset button.
I've no idea if DTR works on the CP2102 USB to UART Bridge.

But for sure I can't get it working on the Pro Mini.
If I'm right, it should reboot when I pull down DTR to ground as it does when I do pull down RESET to ground.
But it doesn't.
I thought of a bad 0.1uF capacitor between RESET and DTR, but shorting RESET to ground trough an external 0.1uF capacitor doesn't reboot either.

I've read a lot of things about DTR, but it seems it's been hacked from the serial port to be used to reset the Arduino.
So my question is : Does it have just to be grounded or does it have to be applied a specific signal to make DTR working ?
How can I troubleshoot the problem ?

I found this that might and seems to be interesting but my english and electronic skills are to weak to understand.

Thanks for your help.
38  Using Arduino / Displays / Re: LCD Keypad Shield v2.0 only displaying on first left 8 caracters on: March 28, 2014, 06:40:55 am
Thanks for this first reply. I'm having a look and meanwhile I didn't find yet my answer, it's interesting !

What I noticed from my LCD is when I power it up, I can see the caracter on the right hand side  for a very short period. They're dim, but I can notice they would like to appear but go off straight after.
39  Using Arduino / Displays / LCD Keypad Shield v2.0 only displaying on first left 8 caracters on: March 27, 2014, 04:32:11 pm
Hi all.

I'm back playing with my Arduino MEGA 2580 and its "LCD Keypad Shield v2.0" but I'm facing some problem.

It only displays the first left 8 caracters on line 0 and lone 1
The right area stays blind.
The code I'm using :

  LiquidCrystal Library - Serial Input
 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.
 This sketch displays text sent over the serial port
 (e.g. from the Serial Monitor) on an attached LCD.
 The circuit:
 * LCD RS pin to digital pin 12 ==> 8
 * LCD Enable pin to digital pin 11 ==> 9
 * LCD D4 pin to digital pin 5 ==> 4
 * LCD D5 pin to digital pin 4 ==> 5
 * LCD D6 pin to digital pin 3 ==> 6
 * LCD D7 pin to digital pin 2 ==> 7
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe
 This example code is in the public domain.

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup(){
    // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // initialize the serial communications:
  // Print a message to the LCD.
  lcd.setCursor(2, 1);
  lcd.print("hello, world!");

void loop()
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(1, 0);
  // print the number of seconds since reset:
But it does the same problem with different code.

I've got RS, E, D4, D5, D6, D7 respectively on pin 8, 9, 4, 5, 6 and 7.

Any idea what could be wrong ?
Would it be possible something blownup ?
40  Using Arduino / Storage / Re: Problem writting I2C 24Cxx Eeprom on: April 14, 2013, 11:40:14 am
As it's been said earlier, the pull-up resistor are necessary (I'm using 4-5kOhm) despite it can work without because of the Arduino's internal pull-up resistor of I think 40kOHm.
But in case of capacitive line, it would not work properly (longer line or more than 1 I2C device on the same bus)

It seems the  "EEPROM_READ" you're using is to read the Arduino's internal Eeprom.

To read I2C Eeprom, you must use the wire.h library.

The pin 7 (WC) must be HIGH only if you want to be sure not to overwrite the Eeprom by mistake.
I usually put pin 1, 2, 3, 4, and 7 to ground to not let them floating (in case)
41  Using Arduino / Storage / Re: How to read 24Cxx I2C Eprom bigger than 2Kb (ie 4kb) on: April 11, 2013, 04:47:30 pm
It have a configuration so you can run 2 (or more?) eeproms at the same i2c address, so two 24lc32 becomes one 24lc64

Oh nooooo !

You're making things even more complicated now ! Are you sure this is possible that way ?
42  Using Arduino / Storage / Re: How to read 24Cxx I2C Eprom bigger than 2Kb (ie 4kb) on: April 11, 2013, 09:27:44 am
you can use the EEPROM24 library.
I've used it a lot and it's easy to interface with, and doesn't take a lot of space either.
you can download it here:

So I think this library can work only for the 1 Eeprom = 1 device Eeprom style.
No for for the 1 Eeprom = 2 devices Eeprom style.

I'm really confused about this.
43  Using Arduino / Storage / Re: How to read 24Cxx I2C Eprom bigger than 2Kb (ie 4kb) on: April 11, 2013, 04:29:04 am
Would you excuse me for insisting so much, but the 24LC1025 shouldn't it be seen only as 2 devices ?

The 24LC512 is seen as 1 device. Right ?
2 bytes is 16 bits that gives 65536 possibilities for block's address.
and the 24LC512 has 512*1024/8 = 65536 block addresses. right ?

So the 24LC1025 should be seen only as 2 devices. (2 x 24LC512)

Or am I wrong.
44  Using Arduino / Storage / Re: How to read 24Cxx I2C Eprom bigger than 2Kb (ie 4kb) on: April 11, 2013, 03:02:23 am
What makes me mistaken is that I've been using 24c02 and 24C04 that are addressed on only 1byte.

You'll say, the 24C04 can't be addressed on only 1 byte. But it is ! Well not really.

In fact, the address block is on 1byte, the 24C04 is seen as 2 devices (1 on 0x50 and 1 on 0x51), the A0 pin has no function (no connect) and there is a 9th bit somewhere that I can't yet understand how it works and where it is.
This means that a 24C04 is using 2 devices addresses !

Bigger I2C Eeprom have their block address coded on 2 bytes, that mean up to 64kB on the same device I think (24C512)

The link you gave previously talks about a 24LC1025 24LC1026 of 128kB !
Twice more addresses than 2^16 (2 bytes addresses possibilities).

Is it using the same trick as for the 24C04 ?

This is quite confusing to me indeed !
45  Using Arduino / Programming Questions / Is Arduino ANSI compatible ? on: April 08, 2013, 03:47:58 pm

Well, that's my question.

One of the reason I choosed Arduino is that it was programmed in Arduino wich was supposed cloth to C.

But Now I have a doubt whether an Arduino code can easily be put on another uC.

I've read somewhere that the C compiler has to be ANSI compatible to make the move on different uC easy. And it seams that not all C compiler are .
Pages: 1 2 [3] 4 5 6