PWM input/output

Hello,

I am going to buy an Arduino Uno board. However I would like to know if the PWM or UART inputs and outputs can be used as simple I/O and not as PWM...
Indeed, I want to connect 2 speed sensors, 2 steppers motors drivers (so 2 step links and 2 dir links), 4 relays...
I have read your helps... but I didn't see any answers to my question... Therefore, can I connect the digital output of a speed sensor to the Arduino Uno with a PWM I/O? same question for both inputs of each motor driver?
Thanks a lot in advance !
Have a nice day ! :slight_smile:

Yes all pins can be used as simple inputs or outputs.
For pins 0&1 you may have to disconnect stuff from them in order to upload code.

Thank for your quick answer, which is a piece of good news for me :slight_smile:
So I can't use pins 0&1 however I believed that uploading code was made thanks to USB, wasn't it?

The Arduino UNO has 20 pins that can be used for digital I/O (digitalRead() and digitalWrite()). These are 0-13 and A0-A5.

  • Pins 0 and 1 are the serial I/O pins that allow uploading from and communication with a PC through the USB-to-TTL Serial chip. Those two pins are best left unused.
  • Pins 10 through 13 are the SPI pins so if you use an SPI device like an Ethernet Shield, WiFi Shield, or SD card you can't use those for digital I/O.
  • Pins A4 and A5 are the I2C/TWI/Wire pins so if you use any I2C/TWI/Wire device you can't use those two for digital I/O (or analogRead()).

You need about 10 pins so you can use 2-9, A0 and A1 and still have all the busses and A2 and A3 unused.

believed that uploading code was made thanks to USB, wasn't it?

No, there is a chip,to convert the USB into serial data and that is fed into the Arduino through pins 0&1.

Thanks Grympy_Mike :slight_smile: I didn't understand this !
I don't have any SPI devices, so those pins will be for me always unused, won't they?
So I can't use an Arduino Uno because I need too I/O :

  • two analogical I for the two rotation sensors => A0 et A1
  • one analogical I for a trigger => A2
  • two digital I for two speed sensors =>pins 2&3
  • four digital O for 4 relays => pins 4 through 7
  • four digital O for 2 steppers motors (2 step links and 2 dir links) => pins 8&9
    So I must buy a board which has got more pins.
    Thank a lot for your replies :slight_smile:

You must understand that the I/O pins are multi-function pins. They can all do simple I/O. But for some special purposes you must use designated pins. If you don't need the special purpose you can use the pin for ordinary I/O.

You should read the Atmel datasheet for the Atmega 328. It has all the details.

...R

So I can't use an Arduino Uno because I need too I/O :.........

I only count 13 pins there. The Uno has 20 pins you can use. So you do not need a bigger board.

I don't have any SPI devices, so those pins will be for me always unused, won't they?

No you can use the SPI pins as normal digital Input / outputs. You can use any of the analogue pins as digital input or output as well. Note they are called analogue or analog NOT analogical.
Are you talking of the pins on the ICSP header? These are just wired to some of the normal I/O pins.

I thank you Robin2 and Grumpy_Mike ! Your replies are very helpful for me. I begin to read the datasheet Robin2! Thank a lot for your posts in another forum!
Grumpy Mike : Thank for the term "analog" and not analogical ^^(What a big shame on me) !
You're very kind both !
Have a nice day !

What a big shame on me) !

No, there is no shame on you for not knowing.
The shame only comes if you have been told and you deliberately ignore it.

That goes the same for anything else you don't know, not knowing is not a reason to be ashamed, glad we could help.

Grumpy_Mike:
not knowing is not a reason to be ashamed, glad we could help.

Think how boring the world would be if everyone knew everything :slight_smile:

...R