I have a UNO R3 & a 2.8" TFTLCD that I'm using as a motor controller. The touch screen is used to input a couple of parameters and I use PWM pin 11 to drive the motor circuitry. I have this working and I'm refining the user interface. In that regard I want to display bitmaps on the screen.
My problem is this: pin 11 is the SPI MOSI (master out slave in) pin, used to read bitmaps from an SD card (capability integral to the UNO R3). Pin 11 is also the pin that I'm using as output to the motor.
What I would like to do is use the SPI to read the bitmap from the SD card, then pinMode to set the SPI chip select (pin 10) to output & digitalWrite it high (tells SPI to ignore the MOSI, MISO pins). Then use analogWrite to output to the motor on pin 11. The bitmap display and the motor control are mutually exclusive in time, so there's no conflict.
Will this work? This is my first Arduino project and I won't be surprised if I'm missing something. It's also my first forum post, so if there's a more appropriate category for it, please let me know.
What will the SD module think about seeing PWM on one of it's outputs? I think you end up creating a short there somewhere. I don't think this is a very good idea. Move the motor to another pin.
The TFT LCD uses ALL the pins! Being a noob, I didn't know to confirm that The UNO/TFT configuration wouldn't leave a pin for output. Seems silly that it wouldn't.
Pin 11 is an input pin to the SD controller. Putting the CS high inhibits the SD looking at it. As I understand it(!). All other PWM pins are used by the screen interface.
Is it a TFT display or an LCD display ? They are not the same thing. Which pins exactly does it use and must they all be PWM capable ? Have you used all of the A* pins and if so, what for ?
I didn't know that about the A pins. It appears that A5 is unused by the screen, so I'll look into using it. Thanks - it would be great to not muck around with pin 11.
If you use a TFT with 8bit parallel bus, SdCard and anything else on Uno , it
should be expected that you will faced with lacking of free pins. It is not a good idea using this TFT screen with Uno, it would be better to choose a Mega board.
Yeah, that was a result of my noobi-ness. Although I think most TFT buyers wouldn't think to even check that a shield would use ALL the pins & leave none for I/O to the world. It would have been nice if the seller (Elegoo) had said that the Uno was maxed out using it. Arduino & Adafruit sell the TFT & don't warn about this.
Follow up: that did not work. Writing the chip select (CS, pin 10) high to block the SPI & SD did not allow me to use pin 11. The SD hardware was probably still writing to it.
At any rate, I discovered that the "Analog Input" pins can be used as digital input & output!! That's not part of the Uno documentation, just something that I stumbled upon on the web. It does work - A5 is unused by the TFT shield and I am using it as the output to my motor driver. It is not a PWM pin, though, so I have to do that manually. Not perfect, but good enough.