gaouser
September 6, 2022, 2:29pm
1
if (digitalRead(4) == HIGH)
{
tft.fillRect(analogRead(10),analogRead(6),analogRead(5),analogRead(3),0xFFFF);
Serial.println(analogRead(10));
}
why those pins (10,6,5,3) give me random/floating numbers, theyre on 5V and INPUT_PULLUP, whats the problem here (i check from serial and display)
Which Arduino are you using?
gaouser:
why those pins (10,6,5,3) give me random/floating numbers, theyre on 5V and INPUT_PULLUP, whats the problem here (i check from serial and display)
How would we know that from the code that you have posted ?
gaouser
September 6, 2022, 2:34pm
5
UNO R3. (with more detail)
gaouser:
why those pins (10,6,5,3) give me random/floating numbers, theyre on 5V and INPUT_PULLUP, whats the problem here (i check from serial and display)
Please post your code and explain what you expect to see and what you are actually seeing. Instead of using pin numbers it would be nice to use descriptive constants. A wiring diagram would be helpful.
What does PWM have to do with it? Why do you have have inputs configured with internal pullups when you are using them as analog inputs?
1 Like
gaouser
September 6, 2022, 2:38pm
7
pinMode(10,INPUT_PULLUP);
pinMode(6,INPUT_PULLUP);
pinMode(5,INPUT_PULLUP);
pinMode(3,INPUT_PULLUP);
Why are you using analogRead() on digital pins ?
The OP may find this useful or not,
with locating the Uno's pins and their uses.
The analog read function only works on analog pins (14 and higher). It's clever enough to realize that if you use 3, that you really mean 17 so a couple of those reads did work, just not on the pins you expected, hence the floating results.
gaouser
September 6, 2022, 2:45pm
12
pin 3 is also giving the same results
??? There is NOTHING in your code snippet to convey what you THINK you are reading. Please let us know what you require and we can help.
gaouser
September 6, 2022, 2:47pm
14
i dont have any other single line of code that uses those pins
When you do
analogRead(3);
the code reads pin A3 (ie, pin 17)
What do you have connected to A3, if anything ?
Do you think you are reading a PWM frequency? Do you think you are reading a voltage? Do you think you are reading a digital input?
What does this data REPRESENT???
gaouser
September 6, 2022, 2:49pm
17
Analog IN 3 is empty, i use PWM 3
gaouser:
i use PWM 3
Pin 3 can do PWM output
You cannot read an analogue value from it because it is a purely digital GPIO pin