Hot answers tagged

6

In your code you would use a 16 bit unsigned integer as your variable. As there is no such thing as a 9 bit type. If the pins correspond to different ports on your micro, you basically do this: Read the pin value from the port register, and bit shift to the right bit position then OR with the variable. Say you had 8 of the LEDS on PORTB (pin 0 - 7 )and ...


6

You can measure a single "pure" frequency by counting the number of times that the pin changes, by using the inbuilt timers. Here is a sketch from my page about timers that accomplishes that: // Timer and Counter example // Author: Nick Gammon // Date: 17th January 2012 // Input: Pin D5 // these are checked for in the main program volatile unsigned long ...


6

You have set Pin 2 to HIGH, which is 5V. You have set Pin 4 to INPUT_PULLUP, which means if no signal is driving it, it will be HIGH. You have connected a button between Pins 2 and 4. So, if you don't press the button, the input is pulled HIGH. And if you do press the button, Pin 2 is driving it HIGH.


5

40.0mA. The Arduino UNO Digital IO pins are connected directly to the IO pins on the ATMEGA328P processor. From page 299 of the data sheet for that processor... Note that there is also a total current limit for all output pins combined, and that the voltage starts to drop as the current goes up.


5

Yes you can use them as ordinary digital io pins. PWM is essentially a normal digital output pin that is repeatedly turned on and off at a high rate. The magic is that the turning off and on is done in the hardware according to the duty cycle (I.e. there is no need for software to perform the on/off operations) . This is why only some pins can do h/w PWM, ...


4

It seems you haven't connected the circuit ground to the Arduino ground. This is essential to complete the circuit between your breadboard and the Arduino. Without the ground connection the electrons that you send to the Arduino have no way of getting back again. Here's a couple of diagrams that I drew for another question which deals with the Arduino ...


4

The standard Arduino way of doing this is to use pinMode(). It's not fast, but it's easy to understand, especially for beginners. And it's portable across architectures. If you want to go fast, then you should skip the Arduino functions and use port manipulation, and avr-libc. The standard avr-libc way of doing what you want is: DDRF = _BV(PF2) // set ...


4

Check the datasheet, probably just search for "internal" or "pullup" I believe there are little more pins/ports as portB, so they should all have internal pull ups.


3

That device (datasheet) puts out 3.3V on the OUT pin, not 5V: ◦ TTL output: 3.3V, 0V The excess cable is most likely picking up EMI and creating spurious pulses on the input. There are two basic ways of combating this: Increase the drive strength (especially the sink capacity) of the output Implement a balanced line communication system You can combine ...


3

If your signal is a pure 1 kHz tone, then you should use Nick Gammon's counting method, as it is the most straight-forward solution. If, however, you are picking the signal through a microphone, chances are you will also get some background noise, and this can make the counting method unreliable. In such a case, you will have to use some kind of ...


3

Something like this: typedef union NUM_9_BITS_t { unsigned int U; struct NUM_9_BITS_FIELD { unsigned int BIT0 : 1; unsigned int BIT1 : 1; unsigned int BIT2 : 1; unsigned int BIT3 : 1; unsigned int BIT4 : 1; unsigned int BIT5 : 1; unsigned int BIT6 : 1; unsigned int BIT7 : 1; ...


3

I ran across this post and thought that a more in depth explanation should be given on why when using digital inputs that more times than not you will need to use the pull-up resistors. When you define one of the pins to be a input the chip measures the voltage on the pins, if the voltage measures more than half of the VCC voltage the input is off. What ...


3

.parseInt() reads incoming text up until either it times out or until it reads something that isn't a number. You are sending a number, and most likely a line-ending. If that line-ending is a simple \n then that will trigger the "end of number" and will be discarded and the number returned. However, if you are sending \r\n (i.e., CRLF) then you effectively ...


3

My guess would be that you're getting noise interference on the line and it's too much for the Arduino's little internal pullup. Try adding an external pullup resistor - say 5k-10k (exact value is not critical).


3

What will happen is you will damage your LED and/or your Arduino since you haven't mentioned a current-limiting resistor (220 ohms could well be suitable). However the general concept is perfectly sound. You could, for example, have two LEDs, wired in opposite directions. By bringing one pin LOW and the other HIGH, one LED would light up, and by reversing ...


3

You can test it easily by calling the function twice directly after each other. If the first time a true is returned and the second time a false, the state is internally reset. But probably because after you call the fell function, the internal state is reset, so after the call not a new fell has been happened. So store the return value of the fell and ...


3

Solved it, but here is the solution, so there is an answer available for anyone who might encounter the same problem... Quality check your protoboards. This is making me feel stupid. The protoboard I used had a faulty connection on the blue line I was using, causing an inevitable floating input. So relieved I found the problem, and yet so annoyed! Take ...


3

There are to simple options how to connect a simple button. You mixed them. Better option is connect the button between pin with INPUT_PULLUP and ground. The pin is HIGH when the button is open and LOW when the button grounds the pin. This option is better because if you disconnect the button, the pin is still pulled up to HIGH and not floating. If you ...


3

You need to enable the internal pull-up resistors which are designed to prevent undefined input states on unconnected inputs. Change pinMode(5, INPUT); to pinMode(5, INPUT_PULLUP); For more information on this see Arduino digital pins.


3

No. HDMI uses multiple serial data streams at gigabit rates. No Arduino is ever going to do that sort of thing. If you want something programmable to do that kind of thing you need an FPGA.


2

Only the leakage current on the input itself is constantly consumed if there is no external connection. This is usually much less than the waste caused by having the input floating. If a voltage between 0.8 V and 2 V is applied to the input for a prolonged period of time, this situation becomes critical and should not be ignored, especially with higher ...


2

Power is flowing from the analog pin, through the internal clamping diodes, to the Vcc line. Those diodes are however not designed to handle that much current, so don't continue doing this. Either also disconnect the ground wire from the battery, or simply add a resistor between the battery and the analog pin. Something like 10k. That way less than a mA of ...


2

As @KiraSan said, You need something larger than a byte for 9 bits. However: int tally; tally=0; for (char pin=1; pin<=9; pin++) { if (digitalRead(pin)==HIGH) { tally|=1<<(9-pin); } } This is done from memory and is untested, if anyone spots any errors, let me know. Explanation: tally is the sum (you should do something with this ...


2

There are quite a few GPIO expanders available that you could use to increase IO lines in your circuit, mostly running off I2C. Just search "I2C GPIO" on your favorite electronics site/google/ebay Examples: https://www.sparkfun.com/products/8130 [No affiliation] If every sensed key has to be on a GPIO, then this is the way to go. Having said that, with IO ...


2

There is a whole concept you need to learn: Matrix By using a matrix arrangement you can, using (8 + 9 = ) 17 IO pins you can create a grid of 8 × 9 buttons, which is 72 buttons. This method is used all the time for keypads, and you can read more here: http://playground.arduino.cc/Main/KeypadTutorial To further reduce the number of IO pins used you can ...


2

The problem is here: //Check if any pin from Port A has been pressed if (PINA & 0xff){ Since the pullups are enabled, the default state of the pins is high. To detect a "press", they have to be pulled to ground. This changes the test to: //Check if any pin from Port A has been pressed if (~PINA) { And for individual pins: //Check if PA3 has been ...


2

You mentioned 2 items: the supply voltage to the Arduino and scaling up to 24V output. If the supply voltage you have available is 24V, then I would suggest you look for a DC-DC converter that scales down to 12V. Or, if you are looking to design your own PCB then perhaps use a 78xx voltage regulator. The 78xx are 3 pin devices and only require 2 caps to ...


2

Digital pins sink or source current. They don't provide negative voltages. If the pin is set to INPUT then it is high impedance and will not "send out positive voltage". However if you activate the internal pull-ups, as Ignacio said, then effectively the pin is connected to +5V via (approximately) a 50k resistor.


2

When the internal pullups are activated, a small amount of current is sourced by the pin's circuitry whenever the input is low. That means that to drive the signal low, an external driver must not only sink current to discharge the capacitance of the internal and external circuitry, but it must continue doing so to dominate the attempt of the internal ...


2

Yes, it is perfectly do-able through the serial monitor. However the serial monitor is very very basic and you will be able to create a much better user experience using a proper serial terminal emulator (such as TeraTerm, Putty, etc) and using ANSI control codes to lay the screen out as a proper text-based application. A useful resource is on Wikipedia: ...


Only top voted, non community-wiki answers of a minimum length are eligible