Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I want to be able to check if some pieces of a puzzle is placed or not. To do this as easy as possible, I've set up 5 digital pins to output HIGH with digitalWrite(). The wires from the digital pins is connected to one analog pin each. Instead of a closed circuit, I have a gap for each piece of puzzle which is covered in aluminium foil.
The logic is that when the puzzle piece is placed, the circuit will be complete - and the Arduino will give some sort of output. Since I have a lot of pieces, I need some logic to test if each specific piece is placed or not.
I've tried to read the output from the digitalWrite() with analogRead() and map the values of 0-1023 on a 0-100 scale. This gives me a high variation in readings, and sometimes a reading of 100 (1023) even though the circuit is not closed by the puzzle piece.
Is it possible to get a more precise reading that doesn't vary so much? So far I haven't used any resistance between the different pins.
Why are you connecting to an analog pin?
Go digital all the way. Connect the digital pin to another digital pin, enable the pull-up resistors and then do a digitalRead on that pin.
You should get 1 if it's on and 0 if it's off.
Pretty simple, no?
I hope I helped.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this question
While i was making a little project with Arduino Uno, i noticed, that Arduino doesn't show me the real voltage. Because, when I checked the voltage with my multimeter, it showed me the value as i supposed, and it was different from value Arduino showed. Maybe, I did something wrong. So, i'd like to know the principle of Arduino measuring voltage.
Could anyone help me understand this? Thanks!
P.S. the voltage i measured is lower that 5v
Arduino compares the input voltage via GPIO pins with its own 5V DC power supply and maps the input voltage accordingly. Suppose if Arduino is given 4 volts dc power supply then its ADC will give output of 1024 to 4V input via any analog pin. So in your case your reading might be different because of your input power supply.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 3 years ago.
Improve this question
I am currently using an Arduino Mega 2560 and before I tried hooking it up with a big speaker to play sounds and I want to connect the arduino to a smaller one and I have a spare 4 ohm 3 watt speaker that I don't use.
Can you hook it up? Well technically you also could stick a fork into a power socket. Either of which is ill advised.
No, you can't drive a 4 ohm speaker with an Arduino directly.
An Arduino can deliver 20mA of current top; or rather, that's the maximum amount of current the output drivers of the used microcontroller are rated for. At 4V of voltage a 4 ohms load will draw a current of 1A = 1000mA so 50 times the current capability of the Arduino.
Furthermore, since the output drivers of the micro are not designed to drive such low impedance loads, due to the bad impedance mismatch, it will not be able to deliver any substancial amount of power in the first place. All it will see is essentially a short circuit, that will blow that poor circuit.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Hello and in advance thank you for reading my post,
I am working on a project which is controlled by a stepper motor which also includes an encoder. I have made the motor running and now I want to proceed to the next step and include the functions of the encoder. I know that the encoder tells me the actual position travelled by the motor, however, as I am still quite a newbie, I have unfortunately no idea how to include the information of my encoder into my code (which library? which variables). Both motor and encoder are connected to my Arduino Uno and I have also attached a photo with the corresponding pins for the encoder.
Thank you for any much required help
Here's a huge list of resources and libraries, that should get you started: http://playground.arduino.cc/Main/RotaryEncoders
I'd recommend using this library as it automatically takes advantage of the interrupt capabilities, if you connect the encoder to the correct pins (2 & 3 on the Uno). You might need this in order to still get precise measurements even at high rpm.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have the Arduino Mega,
i need more than the 40mA supplied by the pins to power up my dc-motors,
Is there a way to increase those 40mA to more like 100mA or so?
thanks
This isn't an SO question since it doesn't have anything to do with programming ... but anyway: You don't want to be driving a motor directly from an Arduino. Aside from the lack of adequate power, the motor will also generate spikes and electronic noise which will affect the Ardunio.
There are loads of tutorials on the web here's one. If you want to be able to reverse direction then you would use what is called an H-Bridge.
You can instead of connecting the dc motor with 1 pin to each terminal (+ve, -ve)
you can connect 2 or more (to add-up the current)
assuming a pin gives 40mA and you need 100mA, then you can connect each terminal from the dc-motor to 3 pins from the arduino providing 120mA
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I've connected my LCD to different set of pins. It worked well with default pins, which LCDLirary use. But now it shows weird characters when i programmed to show something meaning full. How to solve this? (Rx pin is one of my new set of pins. But I disconnect the LCD when programming and connect only after uploading is finished. But that may not be related to the issue)
Well, THAT IS THE ISSUE!!! (if what I'm thinking is correct)
As you said you are disconnecting the LCD while programming, the LCD will not be connected at the time when the LCD unit is initialized by the board. (Initialization begins soon after the programming, eh?). So how can the LCD show correct values without getting properly initialized??
Just reset the board after connecting the LCD. You'll have to do this in other cases also, if you are hoping to use Rx (and probably Tx) pin for some other purposes other than communicating via USB.