Arduino Forum

Using Arduino => LEDs and Multiplexing => Topic started by: Tilemachos on Jan 08, 2013, 08:10 pm

Title: UNO R3 (sda-scl and pins 4-5)
Post by: Tilemachos on Jan 08, 2013, 08:10 pm
Hello everyone.
Can I use sda-scl pins for an lcd and pins 4 and 5 as buttons or sensors, in the same time?
Title: Re: UNO R3 (sda-scl and pins 4-5)
Post by: retrolefty on Jan 08, 2013, 08:15 pm

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
Title: Re: UNO R3 (sda-scl and pins 4-5)
Post by: Tilemachos on Jan 08, 2013, 10:44 pm
Thank you Lefty.
So why is there also sda/scl pins in R3?
Title: Re: UNO R3 (sda-scl and pins 4-5)
Post by: KirAsh4 on Jan 10, 2013, 12:38 am
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 (http://arduino.cc/en/Main/ArduinoBoardUno) to understand why.
Title: Re: UNO R3 (sda-scl and pins 4-5)
Post by: cmagagna on Jan 10, 2013, 08:07 am

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)
Title: Re: UNO R3 (sda-scl and pins 4-5)
Post by: ArduinoGeezer on Oct 01, 2015, 10:19 pm
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.
Title: Re: UNO R3 (sda-scl and pins 4-5)
Post by: PaulRB on Oct 01, 2015, 10:52 pm
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
Title: Re: UNO R3 (sda-scl and pins 4-5)
Post by: Simpson_Jr on Oct 04, 2015, 09:40 pm
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.
Title: Re: UNO R3 (sda-scl and pins 4-5)
Post by: DrAzzy on Oct 05, 2015, 04:34 am
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
Title: Re: UNO R3 (sda-scl and pins 4-5)
Post by: PaulRB on Oct 05, 2015, 07:58 am
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.
Title: Re: UNO R3 (sda-scl and pins 4-5)
Post by: dogoniyat on Aug 05, 2017, 12:39 pm
Hi,

The good news is... yes, of course, you can. The not-so-good news is... no, you can't just throw a switch with its resistor on A4-A5 if you intend to use I2C for something else.
This article: http://hackaday.com/2016/11/07/diy-i2c-devices-with-attiny85/ explains how to make a slave I2C device with an ATTiny85, such as a joystick, buttons and so on.
Now, a LED screen is much more responsive on SPI and, IMHO, single buttons are a waste of analog pins.