In this instructable, I will review some sensors (listed below) and focus on how to use them with an Arduino. laser harps, interactive LED tables, etc.). Furthermore, many tutorials show how to use a single sensor with an Arduino, but it can be unclear how to use lots of them in a project that requires lots of detectors (e.g. Ultrasonic sensor sends the pulse > pulse back > now echo pin is connected to second sensors trig > the Second Ultrasonic sensor sends the pulse then starts listening.There are many types of sensors available that enable you to interact with electronics, and so it can be difficult to decide which one is best to use for a project. The solution is to use one trig for both ultrasonic sensor and two echos. If you want your teacher lose his mind answer his question with this: Into one input, what do you need, and how can you read the input? If you have two sensors from two different outputs but want them to go Read up about voltage dividers and, for both buttons being pressed at the same time, resistors in parallel The results can be used either in a table, with a loop, or in an if/else if statement (I used this technique on a 12-key keypad, so the list was a lot longer). The wire leading off to the right goes to the analog pin on the Arduino. Sort these numerically (which in this case they already are), and work out the values exactly between each pair (up to 0.85 is closest to 0=> no button else up to 2.1=> button A else up to 2.75 is closest to B otherwise, both are pressed. For the resistors above, you should get about: (no button = 0v A=1.7v, B=2.5v, both 3v). Use the ReadAnalogVoltage sketch to measure the voltage with different combinations of button presses (no button pressed, A, B, A+B), then, in your final sketch, you can compare the value read with the values in this table - pick the closest one, because actual readings may vary slightly. They should be pretty close to the same value, and at least 1k each. Where the two switches meet, connect them to an analog pin on your Arduino.įor example, you might use a 20k resistor with button A, and a 10k resistor with button B, and a 10k resistor connected to ground. Connect the loose end of those two switches together, then via another resistor to ground. Connect the loose end of each resistor together to +5V. This solution only actually uses one pin, but only works with simple things like push buttons (which are either open, or closed).Ĭonnect a (different) resistor in series (end-to-end) with each switch. Open Drain is how things like I2C support multiple devices on the same bus without any voltage conflicts. This means that you can only have one sensor active at a time, so they have to be triggered by separate output pins. When one sensor's output activates it turns on the transistor which then pulls the input pin low. When then transistors are off the input pin is pulled up through a pullup resistor (could be internal or external to the IO pin). This means you convert each of the outputs of the sensors into a switch using a transistor (NPN BJT or N-Channel MOSFET) to connect your input pin to ground. The passive solution is called open drain or open collector (if you are using TTL not CMOS terminology). It does mean, though, that both sensors can be active at once and you just select one to read the output from. It requires an extra IO pin, though, so is pretty pointless as you could just use that IO pin as an input from the second sensor. This is basically a switch and it selects one of its inputs to route through to its output, so it can be used to connect your input pin to the output of one of the sensors. The active solution requires a device called a multiplexer. There are two basic solutions to your problem, an active one and a passive one, and which is best (or will even work) depends on the rest of your setup.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |