easy question about LCD pin code

Hey guys, I was looking through some code for a regular HD44780 LCD :

LiquidCrystal lcd(8, 7, 5, 4, [color=red]16[/color], 2);

Pin 16? That’s an arduino uno, ATMEGA 328P.

lcd_bkl = pin 6

lcd_d4 = pin 5
lcd_d5 = pin 4
lcd_d6= analog pin 2
lcd_d7= digital pin 2

EN=pin 7
RS=pin 8

Here is the schematic, supposedly it’s correct…

I'm not sure if there is a pin 16 ...

Would you guys help me to see if there is a mistake, or am I missing something?

Pin 16 in an Uno is analog input 2 and that matches the schematic. The analog inputs continue with numbers after the digitial inputs (A0 equals 14).

void setup() {
  Serial.begin(9600);
  Serial.println(A2);
}

Awesome, now I understand ... it's called pin "16" because the code uses digital pin 2 and analog pin 2 at the same time, so pin 16 is the same as pin 2.

I'm also trying to use a dsb18b20 and I would like to hook it up to digital pin 0 or RX, I know that the RX and Tx pins are used to upload sketches. Can I just use a jumper on my pcb to enable the sensor and then remove it if I want to upload the sketch?

Im not going to use "serial begin"..

Thanks for the help!!

it's called pin "16" because the code uses digital pin 2 and analog pin 2 at the same time, so pin 16 is the same as pin 2.

It is so much less confusing to use the A* names for the analogue pins that I don't see any reason to use the actual pin numbers. Using the A* names also means that code is usable on many boards without the need to change the code.

Can I just use a jumper on my pcb to enable the sensor and then remove it if I want to upload the sketch?

One excellent feature of the Arduino is that it is so easy to try things quickly.

Do you really need to use pin D0 ?

Actually those are the only free pins on the schematic...

hmm... I was thinking to add a header jumper on that pin, or maybe I can try to upload the sketch using another arduino that I have laying around the house, then remove the AVR and put it on the new pcb.

Would that work? Am I overthinking? The easiest solution for me is to add a jumper on the pcb and remove it when I want to upload a sketch...

badstraw360:
Awesome, now I understand … it’s called pin “16” because the code uses digital pin 2 and analog pin 2 at the same time, so pin 16 is the same as pin 2.

No !! Pin 16 is analog pin 2

badstraw360:
I’m also trying to use a dsb18b20 and I would like to hook it up to digital pin 0 or RX, I know that the RX and Tx pins are used to upload sketches. Can I just use a jumper on my pcb to enable the sensor and then remove it if I want to upload the sketch?

Serial is the most powerful tool in most Arduinos for debugging; don’t sacrifice it if you don’t have to.

You still have plenty pins available; basically any of them can be used. The only thing that I know about the DS18B20 is that it’s a one-wire device. So pick any of the pins D9 …D12 (D13 might be an option as well, but again the LED can be useful to display some other information) or A0 or A1. The latter two pins can be used as digital pins as well (as is done for your LCD).

Yeah, I'm not actually thinking to replace the serial pin with a DS18B20, instead I would like to keep it deactivated until I need to use the serial connection, and then I can use the jumper to activate the sensor if everything works properly.

This is the schematic, would that do the job?

Im using pins D9-D12 with momentary push buttons, and the rest of the pins for LEDs and the LCD.

Maybe I can use analog pin 3?

Why not? As said, they can also act as digital pins (see hoow the LCD is connected).

Just try it.

badstraw360:
Maybe I can use analog pin 3?

You van even use a single analog input for your four buttons. Pretty clever if if you never thought about it before.