The current stop at analog input

Hi I'm new here, and I have a little knowledge in electronics and I would be glad to hear where I have a lack of understanding, so feel free to point at my flaws.
now i want to create a matrix of buttons ,that each button will have its own id.
(I would glad to know better/correct ways to achive that )
so i decided, that each led's output (it switches via buttons) would be connected to analog input pin in order to get its voltage as analog value.
but instead of ,my current stopped its flow through the circuit
but i still managed to receive a value from A0 pin

code :

// C++ code
//
int pirIn = 12;
int ledOut = 11 ;
int motionStatus = 0;
int pirIntStaus = 0 ;
void setup()
{
  Serial.begin(9600);
  pinMode(12, INPUT);
  pinMode(A0, INPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(LED_BUILTIN, OUTPUT);

  digitalWrite(ledOut, 0);
  digitalWrite(pirIn, 1);
  digitalWrite(A0, HIGH);
  pinMode(A0, INPUT_PULLUP);
  digitalWrite(10, HIGH);
}

void loop()
{
  
  Serial.println(digitalRead(pirIn));
  motionStatus = digitalRead(pirIn);
  if(motionStatus == 1){
    Serial.println(analogRead(A0));
     if(pirIntStaus == 1){
		Serial.println("motion detecated");
     }else{
		digitalWrite(ledOut, 1);
        pirIntStaus = 1 ;
		Serial.println("motion detecated");
		delay(10000);
  	 }
    
  }else{
        pirIntStaus = 0 ;
		Serial.println("motion end");    
  }
  
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000); // Wait for 1000 millisecond(s)
}

output :
//when there is no motion
motion end
1

// when the motion is detected
1023 -> the analog value of 'analogRead();'
motion detected

You may want to consider using a 4x4 keypad and the keypad library.

You may find wokwi useful for doing simulations. It has many examples for the Uno, not just the ESP

This should get you started:

1 Like

Hi know about 4x4 Membrane Keypad with Arduino, but i need a board 4*8
wokwi.com emullator do you think is better then https://www.tinkercad.com/ ?

I've never used tinkercad.
4*8 will require 32 wires so you will either need to use something with more pins like a Mega2560 port expanders or multiplexer ICs.

If tinkercad has a 4x4 example, I would start with it then expand it to 4x8.

12! :smile:

Duh :flushed:

Yes, the current has no-where to go. An input pin won't let it flow. (Ok, a very, very tiny current will flow, so small it's difficult to measure, and won't light a led, at least not a real led).

That's a surprise, you shouldn't have been able to, because with the switch in the right position, A0 would be "floating" which means it can read any value at random.

I can't understand your circuit diagram at all. You have 2 resistors both called "R1" which is crazy. The point of giving resistors names is to have different names. Your 2 resistors are in series, so could be replaced with one higher value resistor. Although it's possible that the 2K resistor is shorted out by the breadboard and could be completely removed without making any difference.

12! = 479.001.600 :wink:

1 Like

Hi , @jakobsachuk
Welcome to the forum.

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.
Sorry but forget about the Fritzy cut and paste.

Tom... :smiley: :+1: :coffee: :australia:

That would the the ultimate Arduino Mega. With 0.1" pin spacing and a row of pins on each side, the board would need to be almost 2 million feet long. :laughing:

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.