0

I have two modules where I want to control them through a single Arduino UNO.

I guess Serial.begin(9600) uses serial port and UART. But Im not sure about SPI.

Can I use SPI library hence the SPI communication together with serial communication(serial.begin) at the same time to communicate with two different modules?

3

Yes. UART and SPI are completely different things. One uses pins 0/1, the other uses pins 11/12/13, and they use separate hardware and control registers inside the chip.

  • Thanks is it possible to use some other pin than pin 11 for SPI? Im currently using 8 9 10 and 11 for another module. – atmnt Nov 27 '18 at 11:42
  • 1
    No. 11/12/13 are SPI. That can not be changed. Ever. It's written in stone (well, silicon, which is what most stone is made of). You could bit-bang SPI using shiftIn() and shiftOut() on other pins if you don't need any great speed or full duplex operation if you really want. – Majenko Nov 27 '18 at 11:44
  • I see then I will try to change the other module's pins. – atmnt Nov 27 '18 at 11:45
  • @atomant if you're using a "Software SPI" you can use as default wired of SPI on your module. else if you're using a "Hardware SPI" you can define another pinout as SPI wire!! – abu-ahmed al-khatiri Nov 27 '18 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.