Go Down

Topic: UNO R3 (sda-scl and pins 4-5) (Read 6936 times) previous topic - next topic

Tilemachos

Hello everyone.
Can I use sda-scl pins for an lcd and pins 4 and 5 as buttons or sensors, in the same time?

retrolefty


Hello everyone.
Can I use sda-scl pins for an lcd and pins 4 and 5 as buttons or sensors, in the same time?


on a Uno type board SDA & SCL are on analog input pins A4 and A5. If you are going to use the I2C functions then you must not use those same pins for buttons and sensors.

Lefty

Tilemachos

Thank you Lefty.
So why is there also sda/scl pins in R3?

KirAsh4

They're just broken out and labeled as SCL/SDA.  It's still the same A4 and A5 pins.  They brought out the TWI pins next to the AREF pin for a reason.  Read the documentation online to understand why.

magagna


So why is there also sda/scl pins in R3?


The ATMega328 used on the Uno uses A4 & A5 for I2C, so for the Uno they're the same pins.

On the Leonardo, however, the ATMega32U4 uses pins D2 and D3 for I2C. The Due also uses something other than A4/A5.

If a shield needs I2C connectivity and uses A4/A5 it will only work with a Uno (and the older 328/168 boards). If a shield uses the SCL/SDA pins, however, it should work with all the Arduinos (except the old ones, which don't have those pins)
http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

ArduinoGeezer

How does Uno know I want to use A4 & A5 as SDA/SCL and not as analog inputs?  Do I need to include the Wire library?

My chinese Uno has D16 & D17 labeled as SDA/SCL.  I guess I'll toggle the  various SCL pins to see what I have.

Thanks for your interest.

PaulRB

#6
Oct 01, 2015, 10:52 pm Last Edit: Oct 01, 2015, 10:53 pm by PaulRB
If you use Wire.begin() it knows you want to use sda & scl. If you use analogRead(A4) or analogRead(A5) it knows you want analog. Yes, you must include the Wire library to use sda/scl.

I never heard of an Uno with D16/17 pins. Uno clones normally have the same pins as a genuine Uno, otherwise they can't sell themselves as clones.

Paul

Simpson_Jr

Can I use sda-scl pins for an lcd and pins 4 and 5 as buttons or sensors, in the same time?
Not directly. You can connect multiple chips/devices using I2C though. If one is an LCD and another is a port-expander, you can display your info and read buttons using the expander and just use 2 arduino-pins.
There are quite a lot of devices working with I2C by the way.

DrAzzy

You can use digitalWrite(17,1) to write to A3... (not A5!)
It's:

A0: 14
A1: 15
A2: 16
A3: 17
A4: 18
A5: 19
ATtiny core for 841+1634+828 and x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny 841/1634/828/88/861/167 breakouts, mosfets, touch sensors and prototyping board in my store http://tindie.com/stores/DrAzzy

PaulRB

You can use digitalWrite(17,1) to write to A3... (not A5!)
It's:

A0: 14
A1: 15
A2: 16
A3: 17
A4: 18
A5: 19
Oh, yes, i had forgotten. Thanks for the reminder, Doc. Why not A5? I knew A6 & A7 are analog only on Nano.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy