Go Down

Topic: 4” display on arduino uno (Read 1 time) previous topic - next topic


Hi guys,
I have an arduino uno r3 with 4" display from waveshare (they have skematics on the website) I need one analog pin for a pressure sensor and 2 digital for 2 solenoid actuators. The analogs are not used by the display, but it seems all digital ones are used.

Obviously I'm new, and I try to learn while doing. I hope to find someone who can help me.
All the best!


Nov 30, 2019, 06:06 am Last Edit: Nov 30, 2019, 06:08 am by 6v6gt
You can use spare analog pins as digital pins (but not the other way round and not A6 or A7 on the Nano).
It is also not advisable to use D0 or D1 which are used by the serial port.
Post a link to the display you have purchased.


Thank you for helping!


Should I try to use d1 d2 for the solenoids and a1 for pressure?

I got a sketch with pressure and I want to display the value and status of each solenoid. For the solenoids I did a 12v circuit to power on proper voltage.


It is a bit difficult to be completely sure from all the scraps of documentation referred to by the link you supplied:

However, it looks like the display has two modes of operation, a parallel mode (uses lots of pins) or a Serial mode (uses only the standard SPI pins - Miso, mosi, clock and chip_select)

Anyway, you should divide the problem in two parts. Part 1 to get the display (and touch screen if you are using that) working. Aim to use SPI mode because it minimizes pin usage. Part 2 is getting the solenoid working.

Your schematic for the solenoids is drawn in a rather unconventional manner so I have only glanced over it. But in principle, you are controlling two 12 volt solenoids with 2 arduino digital pins and that is a straightforward task. Which software did you use, incidentally, to create the schematic ?:


Dec 01, 2019, 08:48 pm Last Edit: Dec 01, 2019, 08:49 pm by horyup Reason: Adding pic
Everycircuit on iPad. It doesn't know mosfet (or I didn't find it), therefore I detail the equivalent circuit.

Ok so what are you saying is that by properly selecting the dip switches I can free some pins. :) I have no clue how to do that and I hope the examples work in that mode. I'll try to get some sketches and see if is doable.
Thanks a lot again.


Dec 01, 2019, 10:04 pm Last Edit: Dec 01, 2019, 10:06 pm by horyup
The dip switches are to the right at icsp I guess this means I only use the 6 icsp pins?


I don't see the DIP switches marked in the schematic, if this is the correct schematic, that is :


Can you find any more documentation ?


Dec 02, 2019, 12:06 am Last Edit: Dec 02, 2019, 12:12 am by horyup
Pic is too big 2.3mb wait please



Waveshare 4" in arduino forum I'll do some reading of that.


The picture makes it clearer. I was wrong about the parallel mode of operation. You don't have access to that. The dip switches appear to be marked on the schematic as Header3x2. If the socket marked icsp on the screen matches up with the icsp header on the uno when the screen is plugged into the uno headers, then I don't understand the purpose of dip switches.

You can see which pins are in use by matching connectors cn2,cn3,cn4 and cn5 to an Arduino Uno pinout. You can use the spare analog pins as digital pins as I said earlier. From a quick glance, it appears that all the analog pins and d0, D1 and d2 are free, which is as you said.

If you are not using the sd card or touch screen, you can free some more pins.

Step is to get the screen working with the supplied library. Can you provide a link to the solenoids?



I will send you the code too if you can help me. I modify lcd_show example from the display website.
Unfortunately for number display it shows integer only converted to a string. I wanted one digit too :(. Also I connected to A1 for a pressure sensor (5v 3 wires) and it doesn't show the updates as it should) I will waste more time on this myself, if I can't make it work I'll ask for help :).


Post the code here, either between code tags or, if it is too big, as a file attachment.

The solenoid is 12v 14watt. You simply need an n-channel logic level mosfet e.g. FQP30N06L and a fly back diode e.g. 1n4007, a say 10k gate pull down resistor and a say 220 ohm gate series resistor. Also, of course, an adequate 12 volt power supply.

Show how you have wired the pressure sensor. You probably need 1 resistor for it so the pressure sensor and resistor form a potential divider with the analog pin at the mid point.


For pressure transducer I connected to A1, 5V, GRND, directly. Practically splitting those pins.
In the code I read the A1 then in loop I post the value calculated with an eq. From a webpage for similar sensor. The number display only show the integer part. I'll send you the files and draw a diagram.
The solenoids should never work (open) at same time. Practically out-solenoid closed, pressurize up to a level then close in-solenoid, keep for 10 min, then out-solenoid open, keep for 10 min and repeat this cycle a number of times.
On the display I need pressure level, in- and out- solenoid status, cycle count i/n.



I try to write this. 3 lines for pressure, solenoid-in, solenoid-out.
it runs but it shows only the integer part of the pressure. I don't think its sensing the pressure.
I connected, as I wrote before, 5v, grnd (next to the 5v), A1 to the pressure transducer. but I guess the display also use the 5 v.
when I run a test code with that equation (without display) I noted some changes in pressure, but not now.

beside this 3 lines, I want to be able to cycle few times (5) pressurizing, wait, depressurizing, wait and repeat.

I hope I get some guidance. thanks a lot.


Dec 08, 2019, 05:46 am Last Edit: Dec 08, 2019, 05:47 am by horyup
The display content:
Current pressure: +8.    Bar
In-solenoid:         CLOSED
Out-solenoid:       CLOSED

Go Up