text:
Anyone have the Maplin N97DG bluetooth shield working?
I went & impulse-bought a Maplin Bluetooth shield yesterday.
It comes with a little tiny book containing examples, and uses the softwareserial library in these; I can load them, and get the Arduino <-> PC communication going OK, however there appears not to be a response from the bluetooth part of the device. The LED lights much as the booklet says it should. I did see it return some odd characters one time, just the once..
Given that the system appears to be alive, I don't want to give up & take it back; however the output from Google is not promising, and my trial to date isn't either - so I'm looking for positive news that this product does actually work for someone somewhere?
I'm using the built-in serial in the IDE to talk to it, not X-CTU as they suggest (as they don't do a Linux version).

I've just got mine working, in about 3 hours.
The first example I've never got working. The SAT+RESET worked first time... and I was then able to pair.
An easier module is the HC-05. That by default goes straight to discovery mode, and makes things alot easier.
I have more success with the serial monitor in Arduino studio, rather than X-CTU.
The point of the sheild is to prototype, or the shield you have to use in your production project. If you are doing the former, then there is little point in using the shield as you would have to change the code to fit the hardware.
It seems a thorough product, probably too involved.

Which Arduino board worked?

I have them both working on the Uno. Would you like me to put together my steps?

Actually, yes please, that would be useful - if I can have it working I may go re-purchase one!


text:
Connect multiple RFID-RC522 cards?
I have a project that requires 4 different RFID-RC522 readers.  The RFID-RC522 has the following pins:

SDA
SCK
MOSI
MISO
IRQ
GND
RST
3.3V

I have read that the SDA pin is used for selecting the active device, So I'm thinking that these devices can share data pins.  Is it possible to connect multiple RFID-RC522 readers to the same 3.3V, RST, GND, IRQ, MISO, MOSI and SCK pins if you use a different pin for each SDA?  If so, this would save me a lot of pins.  So far, I have only seen direction on how to connect one RFID-RC522 to an Arduino.
I'm using the MFRC522 library.  It appears to only support one reader because it only allows one SS pin to be identified in the constructor, and offers no way to change it later.  An I missing something or do I need another library?

possible duplicate of Use RFID-RC522 with other Pins

I am not asking how to redefine pins, I want to use one set of pins for multiple RFID cards.

The answer is still there.

@Magic-Mouse no, it is not. That doesn't state how to create different objects with different pins. To the OP: I'd suggest editing the library to replace the macro with a variable inside the class and just pass that in the class constructor. You're on the right track with the different chip select pins, but it seems like you might need to have an independent RST pin for each one, too. All of the SPI pins (SDA/SCK/MISO/MOSI) and power (3.3V/GND) 100% can be shared as long as the chip has a select pin.

@AnnonomusPenguin SDA is the SS/CS pin

Connect everyone to the MOSI / MISO / SCK and ground, then define every SDA all the way around. and set respectively high low depending on where you want to write.
How ever im not sure if you need to set high or low if you want to read. But since you got multiple you can play around with that your self. Feel free to add to this question with the result for future googlers.
#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN           7          // Configurable, see typical pin layout above
#define RST_PIN2           8          // Configurable, see typical pin layout above
#define SS_PIN           9          // Configurable, see typical pin layout above
#define SS_PIN2          10          // Configurable, see typical pin layout above

....

MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
MFRC522 mfrc522_2(SS_PIN2, RST_PIN2);   // Create MFRC522 instance.

....

void setup() {
  Serial.begin(9600); // Initialize serial communications with the PC
  SPI.begin();        // Init SPI bus
  mfrc522.PCD_Init(); // Init MFRC522 card
  mfrc522_2.PCD_Init(); // Init MFRC522 card

I'm using the MFRC522 library.  It appears to only support one reader because it only allows one SS pin to be identified in the constructor, and offers no way to change it later.  An I missing something or do I need another library?

@Hoytman  works fine for me, though i only have one that i can test on but it compiles.

On my first couple of attempts, I could not get this to work.  Might have been my own code mistakes though.

I just saw that i made a copy paste error, try and set the variables as the corrected code.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Why does my servo twitch and turn on its own?
I've been trying to write a very simple program using Arduino to tell a servo to go to a specific angle when a button is pressed, and to another specific angle when it is released. I find that, even though my sketch is but the simplest possible if then else statement without anything added to it, the servo goes to the right angle when the button is pressed, but when it is released, the servo oscillates between the two specified angles at a regular rate (about once every second). What's even stranger is that when i add delay time to the end of the loop in my sketch, the oscillation becomes more like twitching, and the more delay i add the weirder and less predictable the twitching becomes.
added info
#include <Servo.h>
Servo Servo1;
int const switchPin = 4;
int switchState = 0;
void setup()
{
    Servo1.attach(11);
}

void loop()
{
    switchState = digitalRead(switchPin);
    if (switchState == HIGH) {
        Servo1.write(40);
    } else {
        Servo1.write(70);
        delay(39);
    }
}

the power supply is the regular usb connector plugged from the board to my computer. The circuit is virtually similar to the "mood cue" project on the arduino projects book, except there is a button connected to digital pin 4 instead of a potentiometer.

If you want some help, please post your code, even if it is that simple. A description of your wiring, along with information on power supply, may be useful too.

@jfpoilpret here is the code: #include <Servo.h>
Servo Servo1;
int const switchPin = 4;
int switchState = 0;
void setup() {
Servo1.attach(11);
}
void loop() {
switchState = digitalRead(switchPin);
if (switchState == HIGH) {
Servo1.write(40);
}
else {
Servo1.write(70);
delay(39);
}
} the power supply is the regular usb connector plugged from the board to my computer. The circuit is virtually similar to the "mood cue" project on the arduino projects book, except there is a button connected to digital pin 4 instead of a potentiometer.

If it does what you expect when the button is pressed, but behaves unpredictably when released, you almost certainly have a floating input.
See Switches tutorial.
In particular, this is a no-no:

Random fluctuations in voltages will make the switch read HIGH and then LOW, and your servo will chase around trying to change positions.
The simplest fix (without changing anything else) is to add a pull-down resistor between the pin and ground, so now the pin reliably reads LOW when not pressed.

Other methods are discussed on that page, including debouncing.

I'm assuming you do not have a potentiometer hanging out of the servo motor its self.
2 things i could see here, without seeing the actual circuit itself.
1- The inputs are left floating therefore the input is thinking it sees a high state when you never push the button due to electrical noise. To fix this add a 10k Resister to ground on pin 4 while the switch is wired to 5v/3.3v on one side and the other side going into pin 4. This will fix noise going into pin 4.
2- Power supply on board is overheating or lack of power since computer usb port has a max power of 500mA. Use an external power supply to the servo and connect power supply ground to the board's ground to have a common ground.

I see two potential issues in your code.

There is no button debouncing in your code: this means everytime you push the button down or up, the digitalRead() call will return HIGH and LOW several times until the signal is stabilized; that could make the servo twitch as you observed.
For any call to servo.write(), you need to give time to the servo to reach the desired position, typically a few dozen milliseconds.

For the first problem, google for arduino button debouncing and you'll find various solutions for it.
For the second issue, you just need to add delay() after every call to servo.write(); note that in your code you added delay(39); but only for one call to servo.write() not for both calls.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Fog machine Arduino integration
I want to control my fog machine with an Arduino.  Has a simple button that is used to activate the machine.  I want to press this button using an Arduino digital output pin, but the fog machine is operating on its own electrical circuit.  How do I use the Arduino to activate this machine?
I a few other machines with buttons that I want to wire into an Arduino, so is there a generic solution?

As krol says - a relay is liable to be what you want. Relays like these ones cost between $US1 and $US1.70 per relay and use 5V power supplies to operate them PLUS wil accept Arduino output signals top control them. I have found that specific seller reliable and the products good. Shipping is usually free and delivery to me (in NZ) takes typically 2 to 3 weeks. [I have no relationship with them except as a satisfied customer].

You can interface with the fog machine's button by:

Use a Relay (this will isolate the fog machine's circuit from your Arduino's)
Use a Servo to physically press the button on the fog machine

I believe those would be the simplest and most generic.

Krol - see my "answer" - you may add this material to yours if you wish.

@RussellMcMahon good expansion.

Please do not upvote this answer.
This is an expansion of @Krol's answer.
Krol may incorporate this material in his answer if he wishes.
The image below shows a typical relay module which is able to be driven by logic level / GPIO signals from typical microcontrollers.
The relays have 5V coils and there are optocouplers and drive transistors between the input and the relay.
Inputs are active LOW - ground to turn on.
These are available by mail from China for under $2/relay (under $1/relay if you buy 10 modules with several relays in).
They are NOTIONALLY opto-isolated as well as having relay isolation between input and contacts. BUT the PCB layout and relay design is such that mains to input clearances are poor. They will PROBABLY NOT kill you or your controller but they may - as is the case with much other items manufactured afar off at ludicrously low prices.
I have found the seller/manufacturer whose logo appears on that photo to be a reliable supplier of well made products. (Being well made does not overcome "dangerous design" as above.
Note that the above warning applies to most buffered relays you can buy on the hobbyist market and also top consumer products that have not been put through formal testing (UL etc). This relay board would fail UL testing - as would most others.


text:
Tv remote connection to an Arduino
I have a tv remote that I want to connect to an Arduino so that I can send a series of commands to the TV using the remote.  I would like to open the remote and solder transistors or a Transistor Array in place of the buttons.  I have never done this before, so what do I need to be aware of?  I think that I will need to power the remote using the Arduino's power supply, but I am a bit foggy on the details.

If you're just running lines to the buttons, you won't need to power the remote from the arduino.  You could just let it keep the internal batteries.  But it would be possible to wire it up for power as well.
As a learning project, you could just take it apart and see if you can access the button contacts.  See if the contacts are split.  If so, shorting one side to the other should count as a button press.  But the details have nothing to do with an arduino.  They would depend on your specific remote and how it's constructed.
If your purpose is really to control the TV (rather than learning about the remote and fiddling with it), it will be much easier (and probably cheaper) to blast the IR without involving the remote at all.  A single IR transmitter and a library would work in most cases.  As an example: http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
P.S.  By coincidence, Adafruit just posted an updated guide to IR library use on Arduino.  https://learn.adafruit.com/using-an-infrared-library/overview

That library is probably the best option.  Still, if I were to use the 'short' rout, I still need to automate the pressing of buttons in a specific order / timing.  I opened the remote and it does use two sided contacts.  How can I short them in a controlled, automatic way using an Arduino?

If you get an IR photodiode, you can read the output from the remote, store it either as flash or in program data. I've seen it done, Practical Electronics years ago on a PIC, so I know it works. You could add a 'learn' mode to your program.. you know, 'Press "1" now' sort of thing.

@Hoytman, An electrically easy way is to use a solid-state relay.  Treat it like an LED from the arduino and when it's on it completes the circut.  Use it to bridge the button.  More complex would be to tie the two devices together to ground and feed power to the correct side of the button.  That's more difficult in terms of investigation (which side is low and which is high) and making sure the voltage is good.  But it would probably be cheaper (no SSRs to deal with).

+1 for IR blasting. There's no need to complicate it by involving the remote except to program the Arduino with the command sequences.

Using an IR library as mentioned in a previous answer is likely to be about the best approach.  However, if you decide to use electronic switches to jumper across the remote's switch contacts, consider using CMOS analog switch chips for the purpose.  If each button on the remote connects one contact to a common net, inexpensive chips like 74HC4051 and CD74HCT4067 would serve for 8 or 16 buttons each, respectively.
I don't have a reference for an affordable many-SPST-contacts CMOS switch.  Inexpensive chips with a few such contacts are available.  The 74HC4053, for example, contains three SPDT CMOS switches.  Handling a dozen buttons would use four 4053 chips.  A CD4007 probably could provide three SPST switches also.

Edit: The figure above shows pinouts of CD4051/52/53 devices.  To use a CD4053 as three separate switches, connect V- and GND to Arduino ground, V+ to +5V or +3.3V, and each of COMA,B,C to one circuit contact to be switched.  With NCA, NCB, NCC connected to the other contacts of circuits A, B, C, raise ADDA, B, or C and drop INH to close circuit A, B, or C.
If your remote has dozens of buttons, it's likely that they are arranged in rows and columns for multiplexed scanning.  In this case, follow the printed circuit tracks to identify which buttons attach to which rows and which columns.  Suppose there are eight or fewer of one or the other; eg, suppose there are 5 columns and 8 rows.  In this case, you would hook up 5 CD4051 chips: connect V- and GND to Arduino ground, V+ to +5V or +3.3V, and the COM of each 4051 to a different column line.  Connect NO0–7 to row lines 0 to 7.
To close circuit j in column k, put j in binary on ADDA,B,C of all 4051s and drop INH on 4051 #k.  (Either use one DIO line per INH, or use a DM74LS138 or MM74HC138 (etc.) and put k in binary on the A,B,C select lines of the '138.)

That sounds good, could you give me draw me a quick schematic of how to connect the chip?

Hoytman, see edit. Please remember to upvote useful answers.

Great answer, but I really should do as the other answer recommends.


text:
Why is Serial.print working when nobody receives the data?
I have a kind of theoretical question. Let's have an Arduino Uno connected through USB that does a lot of Serial.print-ing. Then I disconnect it and I don't see anything on the Serial monitor, but the Arduino is still working. I can judge by the blinking lamps and so on.
Now I see that all printing goes through HardwareSerial::write from the Arduino core. There is this statement:
  // If the output buffer is full, there's nothing for it other than to
  // wait for the interrupt handler to empty it a bit
  // ???: return 0 here instead?
  while (i == _tx_buffer->tail)
    ;

It means that if the output buffer is full, the Serial.print will hang there eternally. However this doesn't happen. I guess somebody is consuming the data and to be more precise in ISR(USART_UDRE_vect). It seems as the only place where within interrupt _tx_buffer->tail can be changed. Otherwise the code would loop endlessly in HardwareSerial::write. This interrupt USART_UDRE_vect should be raised only when the Data Register is empty.
My question is - who is consuming the sent data? Is that done by some USART_to_USB drivers? Or am I missing some part of the picture?
Regards,
Boyan

Ignacio's answer is half right. | Right: Either the UART bridge is consuming the data - presumably into its own buffer or there is no "flow control" & the Arduino is sending "blind". | Partially wrong inasmuch as: If it can't YOU care as  your code would hang. || It doesn't so it can. || If you want to stop it from hanging even if the buffer is full you could do a non hanging test and do a check using millis() N ms later where N is somewhat less than a character time (or longer if you don't mind the buffer partially emptying before you restart.

atmega 328p datasheet, section 20.6.3:

The Data Register Empty (UDREn) Flag indicates whether the transmit
buffer is ready to receive new data. This bit is set when the transmit
buffer is empty, and cleared when the transmit buffer contains data to
be transmitted that has not yet been moved into the Shift Register
...
When interrupt-driven data transmission is used, the Data Register
Empty interrupt routine must either write new data to UDRn in order to
clear UDREn or disable the Data Register Empty interrupt, otherwise a
new interrupt will occur once the interrupt routine terminates.

the USART Data Register Empty vector is run when the hardware for USART serial has taken the byte in the register and sent it, not when a receiving device has polled and "taken" it. Once copied into the shift register and sent out of the chip nothing knows if there was another device to "hear" it or not. Some systems may have hardware flow control and wait for a CTS (clear to send) signal on a different wire, but the arduino does not.
You may also notice that if interrupts are not currently enabled (preventing USART_UDRE_vect from ever occuring) the HardwareSerial::write routine will manually poll the correct condition and run the interrupt handler when appropriate to cycle data through and prevent a deadlock.

Brett - It's apparent that you'll be aware of the following - mainly for completeness". I'm not aware of the specific implementation here and I'm sure that what you say applies, but in general a UART can if desired implement the equivalent of RTS/CTS (DTR/...) so that a hearer is needed.

The USB-UART bridge is, if it can. And if it can't, no one cares. A UART is asynchronous, hence it doesn't care if anyone consumes it; as long as it has sent the data, that's all it cares about. There can be additional checks to see if the other side is able to receive data, but that is not implemented on the Uno.


text:
How can I send data to many IC's without using tons of shift registers?
I'm building an audio circuit that will play VGM files (Video Game Music).
I have it working with two different "vintage" IC's such as the SN76489 and the AY-3-8912.
Currently, my design is using an Arduino Micro and two shift registers for the data buses and direct pins for the control pins on the audio IC's.
On average, an audio IC has 8 pins for the data bus and 4 pins for the control or address bus.  This varies per IC.  Some might be 3, some 4, some 6, etc.
Bottom line, even with the 20 IO pins on the Arduino, I will quickly run out of pins.  I thought about serializing many shift registers and basically pass 64 or 128 bit numbers to spread out to the multiple IC's but this sounds ugly.
I'd like to be able to support maybe 6 IC's which could be 60-80 pins.
I also have an Arduino DUE which has many more IO pins.  But then I have to deal with the 3.3v limit and I only have 4 level shifters (16 pins).
Any suggestions on how to handle this?
Thanks.

Get a ATmega128A and learn how to do MMIO.

A quick search reveals that MMIO "seems" to be very similar to how the Apple IIe handled the 7 slots.  Each slot has a /IOSEL pin that is normally HIGH.  When you access an address like $CNXX where N is the slot number, /IOSEL goes low and the slot becomes active.  Each slot has a 16bit address bus and 8bit data bus.  Is MMIO a similar technique?  So basically all IC's would be on the same address/data bus but different addresses would activate them separately?  If so, where can I find some info for doing this with Arduino?

Also, I should note that many of the IC's would not need to be disabled as they could be playing a note at the time.  So, I'm thinking that they all would share a common data bus.  Then, the address bus would be mapped to each IC so that certain ranges would turn the data bus on/off for them.  Would this be the job of an octal bus transceiver?

Neither the Atmega328P, ATmega1280, nor ATmega2560 have an external memory bus, so you'd have to look at something like the ATmega64A or ATmega128A. Many chips have a "select" or "enable" line as well as their data and command buses; if all of yours do then all you need to do is make sure that only one chip is enabled per address or range of addresses.

Thanks, that was an initial thought I had but I'm not sure yet how each IC will respond to being disabled while it's playing a note.  The AY-3-8912, for example, can be set to INACTIVE so I will have to see what that does.  I think it puts the address/data bus in high impedance mode.  But I don't know, yet, what that will do to the note(s) playing.

Looking at the datasheet, I don't believe that it will affect the notes in any way.

There are other ways,but for a brute force many pin driver solution:
Back at the beginning of time when steam driven IC's were all the vogue there was the awesome MM5450.  40 pin DIP. 34 on/off outputs. 3 pin control. Or the really keen could do it with 1` pin control and some basic RC timing. I was. I did.
Its day has passed. but, fortunately. neither Micrel or Digikey know this.
MM5450 datasheet
In stock Digikey $5.46/1
It's a very benign beat to drive once you get to know it. There is no reset (inless you buy bare dies) so you have to start off getting it synchronised  - it's not hard, just not quite usual. Works well.
For single GPIO pin control the pin acts as data out and clock with some RC timing.
Fot ICs with clock/data/load you can do all 3 with RC timing on one pin.
And there is a 44 pin PLCC pkg version available.

AND!
SN74LS673 16 bit SR, 24 pins
http://www.ti.com/product/sn74ls673
ICM7243
http://www.ebay.com/itm/ICM7243BIPL-HARRIS-40-Pin-DIP-LED-DISPLAY-DRIVER-ICM7243-7243A-/390402848376
And others
http://www.ebay.tv/sch/i.html?_sop=7&_nkw=led+driver+ic&_frs=1


text:
Arduino, relays and building code
I want to install several Arduino controlled relays which are use to turn on/off some lights, a fog machine and some door locks in a building.  What do I need to do to insure that the power relays don't violate building code?
Do components need to be put in a box or can they be mounted to a 2x4?
Are there requirements regarding the points were the bear wire is screwed into the relay?
I am assuming that if anyone as ever wired an Arduino into a garage door opener, these questions may have come up.

NB: IANAL nor US regulations expert.There are a few standard certifications that will essentially guarantee that a part will meet US regulatory requirements. Usually more of the form "your building burned down and you have no insurance because ..." rather than prosecuting you for non compliance. Relays with UL rating bought via a reputable US supplier will usually quality. eg if Digikey sell it it is PROBABLY Kosher. Also if made by reputable manufacturers the same applies, as long as its genuine. eg (1 of many) Omron - they don't make no junk largely and even their junk is certified :-).

Disclaimer:   IANAL nor US regulations expert.
There are a few standard certifications that will essentially guarantee that a part will meet US regulatory requirements. Usually more of the form "your building burned down and you have no insurance because ..." rather than prosecuting you for non compliance.
Relays with UL rating bought via a reputable US supplier will usually quality.
eg if Digikey sell it it is PROBABLY Kosher.
Also if made by reputable manufacturers the same applies, as long as its genuine. eg (1 of many) Omron - they don't make no junk largely and even their junk is certified :-).
HOWEVER if you are building something using such parts the whole unit will need to be certified. For small volume applications it may be easier and cheaper to buy comething COTS (commercial off the shelf) which has the relevant certifications. That said,be sure these are legitimate.
As a guide:
US standards a useful introduction
Extensive international standards summary
Wikipedia on UL
MET Labs strut their stuff comparison with UL.
Intertek test labs bow in
Useful - Understanding electrical certification
Possibly useful templates


text:
Need help with on off switch to power arduino.
I am trying to add an on and off power switch to my arduino project.  My project is running off a 9v battery and I would like to save as much power as I can.  There might be a better why that I don’t know.  I added SLEEP_MODE_PWR_DOWN to my project and from what I can tell, the arduino enters sleep mode.  I am having a hard time getting the arduino to wake from sleep mode.  Am I able to do this from a full power down?  I have been reading this link. http://www.gammon.com.au/forum/?id=11497  and others.

Yes, I am using a Uno.

It would also be helpful to know what else are you powering in your project (sensors, modules etc.), their part numbers and their typical and maximum current consumption.

Is there a problem with an actual switch? You could store state in NVRAM...

Since you are using an Arduino Uno board, putting the MCU (the ATmega328P-PU) to sleep won't save you much battery juice. Putting the MCU to sleep won't make a difference because the voltage regulator on the Uno will waste a lot more power than anything else on the board. The ON LED will also draw significant amount of current on that board.
To really save power you should look into getting an Arduino board that has a more efficient voltage regulator, or use no regulator at all by changing your 9V battery by, say, 4 NiMH AA cells.
Here's some more information about the issue for you to look at: What are (or how do I use) the power saving options of the Arduino to extend battery life?

And the usb-to-serial chip on the Uno will also consume power.

I will end up moving off the arduino board and just use what is needed down the line.  I have read about this being an issue.

There is a very good write-up on how to save power, use sleep mode etc, at: http://www.gammon.com.au/power
This includes step-by-step examples of what was done to save power, and how much power was saved, including examples on how to go to sleep and wake back up.


text:
Is there a thermal sensor with a distance of 10 meters for Arduino
I am looking for a thermal sensor with a distance of 10 meters . In my plan , I would like to recognize objects based on the heat. for example car.

Check this one i just found. http://www.farnell.com/datasheets/1675620.pdf . Price is friendly ~36 pounds. This is other datasheet http://www.mouser.com/pdfdocs/D6T01_ThermalIRSensorWhitepaper.pdf

@Martynas I can't find  maximum distance in datasheet.

Because there is no distance. You get a matrix. Here look at this https://www.youtube.com/watch?v=_ix0Rd4pIeA

How about this one at £20?
The range depends on what lens you put in front of it - this has to be plastic as IR doesn't penetrate glass, but you can set your own range, like a focus adjustment. Commercial IR remote thermometers generally have aiming dots (laser) so you can see the optimum range - there's a fixed lens.
The actual sensor won't have a defined range, because of this.


text:
Powering fans and arduino pro mini from single 12v supply
So, I have a 5V Arduino Pro Mini, which is running the logic behind a multi-DHT22 sensor array, and using that input to control a 12v 24mm fan (12v, 0.16 A).
This is currently a working board on an Arduino Nano with two separate power supplies (1 to USB, 1 to fan). I want to simplify it and make a more permanent installation.
What I'm keen to do is something like the following:
Wall Wart (12v, 500mA) ------------------------> Relay -> Fan
                \ (1) -> Arduino Pro Mini @5V -> /

In order to power the Arduino efficiently at 5V, and avoid drawing power all the time (i.e. when the Arduino is asleep), is the best way to apply a Linear (or Switching) Regulator with minimal burn when idle at (1) in the diagram, and power the Pro via its VCC line, or is it better to just run via the internal regulators and RAW?
Will this actually just generate a high burn whenever the arduino is on to convert the 12v-5v? What is the most power efficient approach here?

Can you see what's the part number of the regulator on the Mini? You can then loop up the Quiescent current (sometimes called bias current) of that part. But my guess is it's negligible. Also note that the arduino is only using around 5mA, so that is only 60mW of power. Even if the quiescent current of the regulator is 5mA, you only use 0.12W. If you want to safe power, it think you could better use a mosfet instead of a relay to switch the fan (as relays use quite a bit of power to keep energized). This also means you can PWM the fan, so you can have basic speed control.

If you want to minimize power usage, the best thing would be to start with devices that use more power! :D
It's time for math! I'm going to use the generic L7805CV 5V, 1A linear regulator. Poking in the datasheet, we find that the quiescent (standby) current is max of 6 mA. I'm assuming this power drawn is 12V, not 5V.
Since a linear regulator is basically a variable resistor, we can figure out that the efficiency is:
Vout / Vin

...thus, our efficiency in this application is...
5V / 12V = 0.416666667% efficiency

... Read more here.
So, we can use the inverse of the efficiency function (Vout / Vin → Vin / Vout) to establish the amount of power it'll use. Final equation:
Power Used (W) = (12V / 5V) * Current Draw + (0.006A * 12V)

...which simplifies to:
Power Used (W) = 2.4 * Current Draw + 0.072 W

So, all we need to find is the power consumption of the Arduino. This forum post states the power consumption of different sleep modes:

SLEEP_MODE_IDLE: 15 mA
SLEEP_MODE_ADC: 6.5 mA
SLEEP_MODE_PWR_SAVE: 1.62 mA
SLEEP_MODE_EXT_STANDBY: 1.62 mA
SLEEP_MODE_STANDBY : 0.84 mA
SLEEP_MODE_PWR_DOWN : 0.36 mA

Let's give the Arduino a generous 15mA to sleep:
Power Used (W) = 2.4 * 0.025 + 0.072 W = 0.132 W

So, 132 milliwatts, idle. A bit further, we can calculate that, if your wall wart has an efficiency of 10%, it will actually draw 1.32 W from your wall socket. Using a general cost per killawatt hour ($0.125), we can calculate that it will cost you about $1.45 a year for that Arduino to be ran in sleep mode 24/7 (given that we used the maximums for everything).
It's pretty cheap, so I wouldn't worry about that power. A good switching regulator will cost more than to run it for a few years with a linear regulator. I'd use the onboard one.
If you still want to optimize things, the wall wart or the fan should be looked at first. Consider getting a switching wall wart instead; this will give you a higher return on your investment since both the fan and the logic use this.


text:
SainSmart CO2 sensor module use?
I purchased this CO2 sensor a while back: SainSmart MG811 Gas CO2 Carbon Dioxide Sensor Module Sensor Module for Arduino UNO R3 Raspberry Pi
The module has four pins, Vin, GND, Dout and Aout. I assume Dout and Aout are digital output and analog output, respectively.
Other than that, the sensor came with no datasheet, instructions, or tutorial. I also searched online but fail to find anything useful.
I'm going simple for now, just hooking up the sensor module to Arduino board. I know I can probably connect the output pins to the analog pins, and analogRead them, but what I am looking for is how to convert the raw data readings into CO2 levels in PPM. Like a formula.
Also, I'm curious as to how the digital output works...

http://www.olimex.cl/pdf/CO2b.pdf

The Dout is a TTL threshold indicator; basically it goes high when a certain threshold of the sensor is reached, which is adjusted by the pot.  The Aout is the VRef of the sensor.
Now the MG-811 is not the best sensor in the world; I did look at the datasheet which shows this sensor outputs mV in relation to the PPM so a map function could be used such as 100-600mV maps to 400-10000ppm CO2, see MG-811 CO2 Sensor Module, so you could feed this into a map() function and get the result but since there is a signal conditioning circuit consisting of a op-amp I'm not sure what it does to the raw sensor voltage.
Now the sandbox electronics module may not be identical to the SainSmart module, so you may need to reverse engineer the module you have to determine what is going on or use the schematic from the sandbox site to build your own and de-solder the MG-811 from the SainSmart module.

You can not directly convert the reading to ppm because you do not know what value means what ppm. You'd need at least one calibration point to calculate how many particles per million there are. The sensor is both affected by temperature and humidity so you might wish to compensate that too.


text:
Can ZigBee API and ZigBee AT work together in the same network?
I'm currently trying to make 3 arduinos talking to each other with ZigBee, and it's kinda working.
But I currently use AT mode on the Bees and it's a little bit harsh when I have to switch the destination address in the Coordinator of the network (1 Coordinator and 2 Routers)
Can I put the Coordinator in API mode (to make it easier to switch addresses with xbee-api for Arduino) but still be able to communicate with the AT routers and be able to send/receive data from them?
Thanks for your answer :)

My question has been answered on Stack Overflow, if you ask
https://stackoverflow.com/questions/28765288/can-zigbee-api-and-zigbee-at-modules-work-together-in-the-same-network


text:
Does Nano not get sufficient power via USB?
I have an Uno, and I can play all I want with it, just using a USB cable.
Then I got two Nano clones, and they both show the same behavior:
When I connect it to the USB cable (which leads to my PC) it blinks a few times, then seemingly does nothing. I am also not able to connect to it via the Arduino IDE.
If I then connect an external power source to Vin and Gnd, it wakes up and blinks forever, and I am able to connect to it.
Is this just because I got a cheap clone? Or is this really the accepted / expected behavior?

Should work. Place a say 100 Ohm resistor across USB power leads (about 50 mA load). What Voltage? Remove R :-) | What is USB input voltage to Nano loaded? What brand is clone?

I have a few clones but have not seen this behaviour so I guess it could be one of three things (in order of most likely to least):

They have a fault related to taking power from the USB connector.
The USB lead is not able to supply enough power ie. it is cheap and extremely thin and cannot carry much current. Have you already tried other cables?
Your USB port cannot supply enough power. Given that the spec says 500mA from a USB 2 port, this seems unlikely unless the port is faulty. Have you tried other ports / another PC?

What is the reference of the board that you used ?

@MAC: Are you asking me? If so, sorry, but I don't understand the question.

@Crispy: Using another port made no difference. But using a different USB cable did. Crazy :) Thanks!

To answer your title question, My Nanos run at significantly less than the 500 mA you can draw from a normal USB port, so unless you have a cable problem it should be getting enough, yes.
One thing I have learned about cables is that your mileage may vary.  For the Pi, it is nice enough to show me a lightning bolt on-screen when it isn't getting enough, and swapping the cable fixes it 99.9% of the time.
Arduinos simply display odd behavior like this one.
I always suspect power supply first.
So first, try changing cables.  Then if that doesn't help try changing Arduinos and see if the problem follows the Arduino.
Good luck!


text:
Connecting Indicator LEDs to Arduino Pro Mini
I'm new to electronics and unsure whether my design below will work as intended. XBee Series 2 and Arduino Pro Mini 5V are used. There are 4 LEDs, each with the following roles:

LED1: Flicker when transferring data to XBee
LED2: Flicker when transferring data to Arduino
LED3: Turns on when XBee is powered on
LED4: Turns on when Arduino is powered on

Also, will it suffice to use 3.3V LEDs for LED1, LED2, LED3 and 5V LEDs for LED4?

They will all fail to work. Consider fooling around with LEDs separate from a MCU first.

@IgnacioVazquez-Abrams Is it because I left out a resistor in series with the LEDs?

That's one of them. The other is that current doesn't flow that way through a diode.

Oops I need to flip them around

The new schematic looks fine now. You can use any led you want, but you have to calculate the correct resistor value for them, so they don't burn out. Or you can be lazy and just use a 1000 Ohm resistor; the led will be less bright, but as it's only used as an indicator that doesn't matter so much.

Note that the LEDs on the UART might not work how you desire them to, and that I have no idea what DIO9 does.

@Gerben I notice that there are no 5V surface mount LEDs (0603 or similar) on Digikey/Mouser, am I checking under the wrong categories?

@IgnacioVazquez-Abrams Looks like I should connect LED3 to pin 1 instead... I was hoping the UART LEDs will flicker like on the Arduino Uno

There's no such thing as a "5V LED". You take the Vf of the LED you have, and then you calculate the resistance required to drop the rest of the voltage with the desired current.


text:
Arduino Based Solid State Drive
I've searched high and low for something to get me on the right track, it's making me think it might not be possible.
Basically, I want to create a cheap SSD using Arduino (or another microcontroller if it is too weak). I know I would have to implement the SATA protocol on the device and an OS driver for the disk drive. Assuming I could jump those two hurdles, what else would bar me from implementing a rudimentary SSD? I'm not even talking about full production quality, just a SATA wire coming from a mother board plugged into a socket on a breadboard. Do I need flash storage or would I need another kind of chip to handle the data needs?

Do you understand what SSD is standing for? Maybe you mean just some kind of SATA-connected storage?

The legacy SATA 1.0 throughput of 1.5 GB/s is going to be a huge problem without dedicated hardware - I don't think you stand a chance on any Arduino.

Is the SATA standard really not documented anywhere on the entire internet?

If you want to do this just for fun, implement USB Mass Storage on a Leonardo backed by an SD card or SPI flash.  It will be painfully slow, but the concept will be there.  Outside of the Arduino realm, I expect you could find an existing project to do this with the STM32F4 Discovery board (which is cheaper anyway).

This is such an awesome quest, Creating a storage device from scratch to be used from a computer. I really hope you succeed and please post updates if you make it :)

The good news is that SATA drivers are fairly generic so you don't have to write the OS side. The bad news is everything else.
just a SATA wire coming from a mother board plugged into a socket on a breadboard
Let me stop you there. The minimum data rate for SATA is sufficiently high that you need a PCB. If you try and do this with wires or breadboards it will simply not get through; it will be lost to parasitic capacitance.
(Many years ago as a student I tried to do something vaguely similar with a wire-wrap board. At just 20MHz you could see a clean signal go in one side and a noisy unreadable mess come out the other side. Actually seeing it on a scope drove home the importance of shielding.)
Do I need flash storage or would I need another kind of chip to handle the data needs
Where would you put the data otherwise? It might be an entertaining first step to create a read-only drive with constant contents, but it's not very useful.
You need a chip with a SATA interface. This will almost certainly be an ARM and almost certainly not in DIP. I can't remember at the moment whether SATA master and slave "PHY" interfaces are different or whether it's all defined in software, someone else can answer that.

Sweet thanks for the info. I guess the Arduino is a very "beginner's" setup so I would want to get a more advanced controller for such an undertaking. Thanks for the info.

@pjc50 - He could implement a Write Only Memory - perhaps an emulation of the Signetics 9C46XN / 25120


text:
Powering Arduino Uno R3 with battery packs
I am using Arduino Uno R3 with MPU 6050 for a personal project. MPU 6050 is being powered by the 3.3V supply pin in the Arduino board.
In order to make the sensor mobile, I ordered this battery, which has one power output of 5V 1Amp that I plan on plugging into the Uno's USB Power/Data Outlet.
I know that when plugged into the computer via the same USB port, around 5V 500 mA is supplied. I was wondering if someone could tell me, whether the 1A battery that I ordered would burn my board or not.
Also, is there a built in fuse inside this board?

Power sources like batteries and wall warts are voltage sources: they will deliver a fixed voltage, more or less. The current that they supply will be determined by the load you attach to them.
The "Amps" listed on a power supply is not how much current it will put out, it is the maximum current that the manufacturer has decided it can put out safely, without acting funny or overheating. So when you read that the USB port on a computer supplies 5V and 500mA, that means that it will supply 5V and up to 500mA. If you draw more than a 500mA current from your USB port, you would exceed the max current rating of the USB port. USB ports usually have an emergency shut-off mechanism built in, so they would just turn off if you drew more than 500mA out of them. I wouldn't try it though :). Your battery seems to have pretty similar safety features: "Super protection: overshoot, over-discharge, short circuit, over voltage, leakage, and many other protective functions".
If you had a 5V 20 Amp power supply, it will act the same as the USB port power supply, except it will be able to handle putting out much more current. As long as you don't exceed a voltage source's max current rating, the amount of current that a voltage source puts out depends on how much current the load draws, not on the voltage source. For example, a resistor will draw a current in Amps equal to the voltage supplied to it divided by the resistance (I=V/R), via Ohm's Law. For microcontrollers, you can often find their current draw on their datasheet: your MPU 6050 with the Gyro + Accel running has an operating current of 3.8mA when you give it ~3.3V. An Arduino Uno draws about 80mA by itself, though I don't think this includes the 3.3V power regulator on the 3V3 pin. So you're looking at somewhere a little over 84mA (=0.084A) in total. Your battery can supply 2.5A or 1A depending on which of its ports you use, so you are nowhere near exceeding the battery's max current rating, which is a good thing.
There are no fuses built in to the Arduino Uno R3. If you exceed its maximum current limitations, you will mess it up. There's a ruggedino available with more safety features if you're worried about frying your arduino. But as long as you're careful you should be fine with a standard R3.

The battery will be fine; the 1A rating is just a maximum, if your device only wants up to 500mA then it's got spare capacity, is all.
The battery appears to have in-built short protection etc, so better than a fuse..


text:
Send Keyboard Media Keys with Keyboard Library
I have an Arduino Pro Micro (ATMega32u4) that I want to use as an IR receiver for a media PC and need to send codes like Volume Up, Media Home, Play, etc. But when I look up the scan codes for those and send them to Keyboard.press() it just prints out '0' every time.
Any way to send those keyboard commands?

Include your sketch.  Provide a ref for where you looked up the scan codes etc, as most charts don't have media keys listed

I used an app I wrote in C# a long time ago to capture scan codes. Media Home is 128 apparently.

You have to do some tweaks to the usbkeyboard libraries that comes with the IDE.
For a video tutorial, take a look at this:
Arduino Leonardo as a multimedia keyboard
Which uses the information from this site, if you prefer text only:
Arduino Leonardo multimedia keys
The Leonardo and ProMicro both use the ATMega32u4 and should both work with theses tweaks. If you need more functionality than the ones that this tweak gives you, you have to dig down into usb descriptors on usb.org for the commands you need.

What is the meaning of "4" for the first parameter to HID_SendReport()? Is it for pretending to be an IR remote control?

OK, after a long, long search I found it: 4 is for "Consumer control" (for "report ID"). A more complete list (only 3 is left out) is in a library, with symbolic names: 1: Mouse, 2: Keyboard, 4: Consumer control (with the volume controls/multimedia control), 5: System control, 6: Gamepad, 7: Mouse absolute, 8: NKRO keyboard, 9: Teensy keyboard, 10: Surface dial

cont' - (defines (constants) HID_REPORTID_MOUSE, HID_REPORTID_KEYBOARD, HID_REPORTID_CONSUMERCONTROL, HID_REPORTID_SYSTEMCONTROL, HID_REPORTID_GAMEPAD, HID_REPORTID_MOUSE_ABSOLUTE, HID_REPORTID_NKRO_KEYBOARD, HID_REPORTID_TEENSY_KEYBOARD, HID_REPORTID_SURFACEDIAL, respectively).

Though the report IDs may be arbitrary (self-defined)?

It is indeed possible and also without the requirement to modify the Arduino environment itself. Just register an HID descriptor for the "report ID" for "Consumer Control" (the code is 4 (constant kHID_ReportID_ConsumerControl), where the "report ID" code for keyboard and mouse are 2 and 1, respectively):
static HIDSubDescriptor node(HID_ReportDescriptor_ConsumerControl,
                             sizeof(HID_ReportDescriptor_ConsumerControl));

HID().AppendDescriptor(&node);

After the registration, HID().SendReport() now works for "report ID" equal to 4 (the first parameter), and the audio volume can be changed, etc.
The registration needs to done once and can be put into the init() function, for instance, after the Keyboard.begin(); and Mouse.begin(); calls.
Usage
Example usage, increasing the audio volume by one step:
uint8_t data[2];
data[0] = kVolumeUp;
data[1] = 0;
HID().SendReport(kHID_ReportID_ConsumerControl, data, 2);

The constants are at the end.
Notes
"Consumer Control" has the multimedia controls Volume up, Volume down, Mute, Play, etc.
The registration is similar to the way the constructors for the built-in keyboard and mouse libraries do it. HID_ReportDescriptor_ConsumerControl and constants are listed at the end because it is quite long, but they must come first (for instance, in the beginning of the file).
All this could be packaged into a reusable form. Here I have demonstrated it in a paste-and-forget form to keep it short.
HID().SendReport() looks strange, but HID() is a global function that returns an instance of the class HID_ (all built into the standard Arduino libraries, presumably to avoid some initialisation order problems with global/static objects - I thought Scott Meyers had solved that a long time ago (47. in the first book)).
HID().SendReport() can also be used to circumvent the limitation of a presumption of a US keyboard. E.g. using code 100, page 56 (and kHID_ReportID_Keyboard, like in the standard class keyboard_) to emulate the 102th key on European keyboards (e.g. a Spanish keyboard).
Only volume up and volume down were tested.
Definition of HID_ReportDescriptor_ConsumerControl and constants:

// For direct use of USB HID (yes, 3 is left out)
const uint8_t kHID_ReportID_Mouse           =  1;
const uint8_t kHID_ReportID_Keyboard        =  2;
const uint8_t kHID_ReportID_ConsumerControl =  4;
const uint8_t kHID_ReportID_SystemControl   =  5;
const uint8_t kHID_ReportID_Gamepad         =  6;
const uint8_t kHID_ReportID_MouseAbsolute   =  7;
const uint8_t kHID_ReportID_NKRO_keyboard   =  8;
const uint8_t kHID_ReportID_TeensyKeyboard  =  9;
const uint8_t kHID_ReportID_SurfaceDial     = 10;

// For use in "Consumer Control". They are bit coded.
const uint8_t kVolumeUp   = 1 << 0; // Bit 0
const uint8_t kVolumeDown = 1 << 1; // Bit 1
const uint8_t kVolumeMute = 1 << 2; // Bit 2

static const uint8_t HID_ReportDescriptor_ConsumerControl[] PROGMEM =
{
    0x05, 0x0c,                           // Usage Page ("Consumer Devices")
    0x09, 0x01,                           // Usage (Consumer Control)
    0xa1, 0x01,                           // Collection (Application)
    0x85, kHID_ReportID_ConsumerControl,  // "Report ID"
    0x15, 0x00,                           // Logical Minimum (0)
    0x25, 0x01,                           // Logical Maximum (1)
    0x09, 0xe9,                           // Usage (Volume Up)
    0x09, 0xea,                           // Usage (Volume Down)
    0x75, 0x01,                           // Report Size (1)
    0x95, 0x02,                           // Report Count (2)
    0x81, 0x06,                           // Input (Data, Variable, Relative)

    0x09, 0xe2,                           // Usage (Mute)
    0x95, 0x01,                           // Report Count (1)
    0x81, 0x06,                           // Input (Data, Variable, Relative)

    0x09, 0xb0,                           // Usage (Play)
    0x95, 0x01,                           // Report Count (1)
    0x81, 0x06,                           // Input (Data, Variable, Relative)

    0x09, 0xb1,                           // Usage (Pause)
    0x95, 0x01,                           // Report Count (1)
    0x81, 0x06,                           // Input (Data, Variable, Relative)

    0x09, 0xb7,                           // Usage (Stop)
    0x95, 0x01,                           // Report Count (1)
    0x81, 0x06,                           // Input (Data, Variable, Relative)

    0x09, 0xb5,                           // Usage (Next)
    0x95, 0x01,                           // Report Count (1)
    0x81, 0x06,                           // Input (Data, Variable, Relative)

    0x09, 0xb6,                           // Usage (Previous)
    0x95, 0x01,                           // Report Count (1)
    0x81, 0x06,                           // Input (Data, Variable, Relative)

    0x09, 0xb3,                           // Usage (Fast Forward)
    0x95, 0x01,                           // Report Count (1)
    0x81, 0x06,                           // Input (Data, Variable, Relative)

    0x09, 0xb4,                           // Usage (Rewind)
    0x95, 0x01,                           // Report Count (1)
    0x81, 0x06,                           // Input (Data, Variable, Relative)

    0x95, 0x06,                           // Report Count (6) Number of bits remaining in byte
    0x81, 0x07,                           // Input (Constant, Variable, Relative)
    0xc0                                  // End Collection
}; // Table for USB HID "Consumer Control" (for audio volume control, etc.)

Platform
This was tested with:

Arduino Leonardo (already used as a macro keyboard, using an old PS/2 keyboard. Two new macro keys were assigned for testing audio volume up / down).
The Arduino Leonardo connected to an extra current port of a D-Link USB hub (necessary, for unknown reasons - probably a local problem)
Arduino IDE v. 1.18.10
Linux, Ubuntu 19.10 (Eoan Ermine), but with the buggy GNOME replaced by Cinnamon.

I had the same problem, and the existing information here was not sufficient. Later, I found and tested a solution. And here is the result!

Some trivia: This started because the volume wheel on the keyboard exhibited strange behaviour. The emulation was an effort to try to isolate the problem. It turned out it is most likely a mechanical issue (it has had problems before with some keys (that resoldering solved)).

Though, are the report IDs entirely arbitrary (self-defined)? Do they just happen to be 2 and 1 for keyboard and mouse in the Arduino standard library? Or are there some conventions/default values/standard?

Thank you for this recipe, it was the only one that worked for me! Using an Arduino Micro (not Pro) with an IR receiver+remote, working well on Ubuntu 20.04.

The Spanish keyboard reference was meant to be a reference to this how-to guide (on this site), but I will not bump it at this time.

If you are getting zeros, the most probably cause is it's the library for the IR. Reinstall or update the library. Sometimes you have to reinstall more than one time. That should work.
About media keys, the keyboard library doesn't have media keys functionality, so you need to use another one. This one worked for me: https://github.com/NicoHood/HID
After you install this library, you have to change your code. The code for pressing media keys is different. You have to use Consumer.write, for example, Consumer.write(MEDIA_VOLUME_UP) for volume up. You can find the name of every key here: https://github.com/NicoHood/HID/wiki/Consumer-API
For normal keys, just use Keyboard.write(). If you want, I can send you the code I made to do this.

Keyboard.press() presses a key and “holds it down” until a Keyboard.release() or releaseAll() is issued.  That is, Keyboard.press() isn't appropriate for simulation of just tapping and releasing a key, unless you follow it with a delay and a release.
Also see Keyboard.write().  But note the following, from Keyboard.write()'s documentation:

Only ASCII characters that are on the keyboard are supported. For example, ASCII 8 (backspace) would work, but ASCII 25 (Substitution) would not.

On my linux system, xev (used via xev -event keyboard) shows the following data for media keys labeled as shown.
  Excerpt from info displayed by xev           Picture
keycode 180 (keysym 0x1008ff18, XF86HomePage)   house
keycode 179 (keysym 0x1008ff81, XF86Tools)   quarter-notes
keycode 163 (keysym 0x1008ff19, XF86Mail)      envelope
keycode 172 (keysym 0x1008ff14, XF86AudioPlay)  >/||
keycode 122 (keysym 0x1008ff11, XF86AudioLowerVolume)  speaker
keycode 123 (keysym 0x1008ff13, XF86AudioRaiseVolume)  speaker
keycode 121 (keysym 0x1008ff12, XF86AudioMute)  x'd-speaker
keycode 148 (keysym 0x1008ff1d, XF86Calculator)  Calculator

I know... I'm doing press();delay();releaseAll().
But if I give it code 128 for example, it does nothing.

Peter's answer probably is the way to go from scratch. But if you want to start from somewhere there's also another library by BleKeyboard https://github.com/T-vK/ESP32-BLE-Keyboard/blob/master/BleKeyboard.cpp. It shows you pretty much the whole process how the media report is created.
// ------------------------------------------------- Media Keys
  USAGE_PAGE(1),      0x0C,          // USAGE_PAGE (Consumer)
  USAGE(1),           0x01,          // USAGE (Consumer Control)
  COLLECTION(1),      0x01,          // COLLECTION (Application)
  REPORT_ID(1),       MEDIA_KEYS_ID, //   REPORT_ID (3)
  USAGE_PAGE(1),      0x0C,          //   USAGE_PAGE (Consumer)
  LOGICAL_MINIMUM(1), 0x00,          //   LOGICAL_MINIMUM (0)
  LOGICAL_MAXIMUM(1), 0x01,          //   LOGICAL_MAXIMUM (1)
  REPORT_SIZE(1),     0x01,          //   REPORT_SIZE (1)
  REPORT_COUNT(1),    0x10,          //   REPORT_COUNT (16)
  USAGE(1),           0xB5,          //   USAGE (Scan Next Track)     ; bit 0: 1
  USAGE(1),           0xB6,          //   USAGE (Scan Previous Track) ; bit 1: 2
  USAGE(1),           0xB7,          //   USAGE (Stop)                ; bit 2: 4
  USAGE(1),           0xCD,          //   USAGE (Play/Pause)          ; bit 3: 8
  USAGE(1),           0xE2,          //   USAGE (Mute)                ; bit 4: 16
  USAGE(1),           0xE9,          //   USAGE (Volume Increment)    ; bit 5: 32
  USAGE(1),           0xEA,          //   USAGE (Volume Decrement)    ; bit 6: 64
  USAGE(2),           0x23, 0x02,    //   Usage (WWW Home)            ; bit 7: 128
  USAGE(2),           0x94, 0x01,    //   Usage (My Computer) ; bit 0: 1
  USAGE(2),           0x92, 0x01,    //   Usage (Calculator)  ; bit 1: 2
  USAGE(2),           0x2A, 0x02,    //   Usage (WWW fav)     ; bit 2: 4
  USAGE(2),           0x21, 0x02,    //   Usage (WWW search)  ; bit 3: 8
  USAGE(2),           0x26, 0x02,    //   Usage (WWW stop)    ; bit 4: 16
  USAGE(2),           0x24, 0x02,    //   Usage (WWW back)    ; bit 5: 32
  USAGE(2),           0x83, 0x01,    //   Usage (Media sel)   ; bit 6: 64
  USAGE(2),           0x8A, 0x01,    //   Usage (Mail)        ; bit 7: 128
  HIDINPUT(1),        0x02,          //   INPUT (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
  END_COLLECTION(0)                  // END_COLLECTION

If you are curious why these media button works, you can checkout the USB doc https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf, Page 75, where it states why each key usage is used.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Do Water sensors Rust?
I'm new to Arduino and still learning the basics.
I tried reading water level by using this sensor I left it in the water for about 5 minutes then I noticed it changing color (some parts darker than other)like the water is still over it .
So my question is do Water sensors really rust ? or is it my own imagination?

The color change you observed is probably caused a galvanic reaction between metals in the sensor and other metals that are present, such as the tank, piping, or dissolved metals in the water. Do not modify the parallel strips of metal on the sensor. This will render the sensor useless. To reduce the effects of galvanic corrosion, you can:
1) Reduce the current passing through the sensor. To do this, sample the sensor less frequently. For, example, sample it once every second.
2) If possible, remove sources of metal from the water. For example, replace metal pipes with PVC, and replace screws with plastic zip-ties.
3) Move the sensor further away from sources of metal.
4) Place a grounded sacrificial zinc in the water, close any other metal sources. If the water is circulating, place the zinc near the inflow opening.
5) Remove stray or electrical currents from the water. Connect the "-" pin (GND) and the water to the same ground.

I agree with every statement in this response but the one about the strips on the sensor.  From experience, This sensor is not effected or changed from tining the strips.  That is not to say that other sensors would not be more sensitive to this.  Wonderful insight!

Most metals will tarnish, rust, or corrode when left in water, especially in the presence of an electric current. To be safe, a water sensor should either be gold-plated or made of a conductive, insoluble, non-metallic substance.

& running AC through it helps as well - reverses the electrolysis process every cycle.

I have that same sensor, and found a couple things to help with this issue.  The first thing that I did with min was tin the contacts with solder (All 10 'sensor contacts' all the way down) and also, using the GPIO, only power it on about 1 second before I read it, and turn it off immediately after.  By reducing the amount of time current is running through it, you reduce the tarnish, and the solder i tined everything with is less likely to corrode than the raw contacts.

I'll use GPIO only at the moment until I get a soldering iron.
Thanks !


text:
Can I mix 22awg and 26awg hookup wire in the same circuit?
I'm still fairly new to Arduino projects, and am only just now getting into building circuits where I want to cut and place my own hookup wire instead of using the precut jumper wires. I inherited some supplies from a friend who abandoned the hobby, and about half of the wire he gave me is 22awg and the other half is 26awg. All of it is solid core copper. Is it ok to mix wire gauges like this in the same circuit/project?

Assuming you won't ever put more current through it than the 26AWG wire can handle, you'll be safe.

Thanks. Any tips on where to get reliable info on what 26AWG copper (for example) can handle? In searching just now, I found charts & answers that indicate everything from .3 to 6 amps.

It depends on how warm you can let the wire get. I wouldn't let it get above 75degC total, so assuming 20degC ambient, that's a 55K rise. You plug that and the wire gauge into a calculator, and it will spit out the maximum allowable current.


text:
Serial port field greyed out with error on launch (Ubuntu 14,04)
I know this has been asked several times already, but I've nevered seen it asked with an error included on launch.
Here is the message that comes up in the terminal when I launch arduino (with root privileges if thats relevant):
(java:9042): GLib-GIO-CRITICAL **: g_dbus_connection_get_unique_name: assertion 'G_IS_DBUS_CONNECTION (connection)' failed
When I try to compile the code, it gives me the standard, "COM1 NOT FOUND" and a bunch of other errors. I can post the entire error message here.
Any suggestions?

That error has nothing to do with the serial port.

Are you in the dialout group (if I remember what ubuntu calls it) so you have permission to open the serial ports?

Yes, I am in the dialout group.


text:
Which Microcontroller to use
I want to use a wifi shield, as well as a 2.8 inch touch LCD shield; both would fit the arduino uno V3 nicely.  Is that the best microcontroller to use

That isn't a mocrocontroller, it's a development platform.

Without any further comments on what you intend to do with it, it is impossible to say what is "the best" for your situation. Please provide more details about your project.

There are Uno Wifi shields and there are Uno LCD shields; do you ask whether you can stack both of them on top of the Uno simultaneously ?

yes, can I stack them simultaneously. @Omer

I meant which arduino microcontroller would be best to use? @Ignacio Vazquez-Abrams

I want to be able to scan for existing networks, and then go from there. @ jfpoilpret

I was wondering if the mega 2560 would work better? @Ignacio Vazquez-Abrams

@BMode35 - The main difference with the mega is that it has more pins for input and output. So you can control more external motors, switches etc.

If you want to do wifi and a GUI, you probably shouldn't be using an Arduino (or at least not an ATmega-based one) at all.  Get something with more memory - it won't cost more, in fact it will probably cost less.

To answer your first question, regarding stacking a WiFi Arduino Shield on top of a LCD Shield:

can I stack them simultaneously

The obvious answer is - it depends on the shields. Each shield might use a different set of Arduino I/O pins, making them unavailable to the next shield stacked on top of it.
for example, this formal Arduino WiFi shield makes I/O pins 10, 11, 12, 13 and 7 (on Arduino Uno) unavailable to the next top shield.
Unfortunately, this LCD KeyPad shield needs pins 7 and 10 available (among others) in order to function properly. This makes it incompatible for stacking on top of the WiFi shield mentioned above (or vice versa).
It doesn't mean that there is no way that any LCD shield could be stacked on top of a WiFi shield, but to be honest, I couldn't easily find any LCD shield that won't collide with a WiFI shield pins. You might want to change approach and send the WiFi data using the built-in Serial to a computer.

Is that the best microcontroller to use

If there would have been a manifest to this website, I'm sure that "The best product is the one that meet your needs best" would be it's first sentence. In order for someone with experience to answer what is best, (s)he would need to know your exact needs. Since you are still not sure what they are, and just want to play around a bit, I imagine that the classic Arduino Uno R3 could help you find your way, especially if you are doing your first steps with Arduino.

I'll have to chime in with the others and say "It depends." The Uno, or more precisely its Atmega328p microcontroller, is rather memory limited, especially the RAM memory needed for data buffers, stack-frames, and tables such as the character-generator for the LCD. That last one can usually be kept in program memory, but note that if you're having to plan memory assignment before you even start the project, it's a pretty good sign that you should consider something more capable.
An Arduino Mega 2560 is about twice the price of the Uno (in the US, US$50 vs. US$25) but gives you 4 times the RAM memory, 8 times the flash (program) memory, and a bunch more (sorry to get all technical :) I/O pins. Of these, the RAM is likely to be your most stringent limit with the UNO.
I keep one Arduino Mega around for prototyping or when don't want to build another board for an experiment, and a handful of AtMega328p chips to build into "Arduin-ettes" for my more permanent gadgets. Most of my toys will fit on the '328 chip but it's awfully nice to be able to shove a ton of code, libraries, debugging statements, logging buffers and what have you, into the larger processor without having to think about what will fit. Or, what's worse, if I cause a stack crash by stuffing all of that into too-little memory, I could waste a lot of time debugging a presumed coding error when it was really an out-of-memory problem.


text:
POST request not working
I'm following a guide on storing sensor data to MySQL:
Guide
My POST request isn't getting any results to my server. For now, I'm only storing temperature.
Here is my code for saving data:
void sendData(double input) {
  String data = "sensorid=3000000&temp=" + doubleToString(input, 2) + "&hum=1.2";

  if (client.connect("192.168.1.50", 80)) {
    client.println("POST /arduino/add.php HTTP/1.1");
    client.println("Host: 192.168.1.50");
    // client.println("User-Agent: Arduino/1.0");
    // client.println("Connection: close");
    client.println("Content-Type: application/x-www-form-urlencoded");
    client.print("Content-Length: ");
    client.print(data.length());
    client.println();
    client.print(data);

    Serial.println("Sent data: " + data);
  }

  if (client.connected()) {
    client.stop();
  }

  delay(300000);
}

I've commented out two headers since it did not give any other results. My Serial.println gives: Sent data: sensorid=3000000&temp=24.00&hum=1.2, which means that the Arduino is connected to the given IP-adress and that my request data is as I want. They are also working perfectly when I'm testing with Requestmaker, so I'm pretty sure my error comes from the way I'm doing the request here.
Do you have any idea how I can solve or debug this?

There needs to be an empty line between the headers and the body of the request. Therefore you have to println() (not print()) the end of the last header.

Try to use print() with '\n' at the end (only a newline, not carriage return.
xportSendTextNoLine("C192.168.200.136/80\n"); sprintf(request,"GET /debug.php?dat=%u HTTP/1.0\n\n",value); xportSendTextNoLine(request); <-- This worked for me. But you'll have to change it a bit to arduino code.

did you solve this problem. I am having exactly the same issue and came to the same conclusion: the error comes from the way I am doing the request from the arduino.

yes, the first comment was the solution to my problem. End with println instead of print. Could not mark it as answer since it was only a comment.

Answered by Edgar Bonet
There needs to be an empty line between the headers and the body of the request. Therefore you have to println() (not print()) the end of the last header.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Arduino weird bluetooth module
Recently I bought a BT module from eBay which was very cheap. I didn't really noticed the image and I just bought it. When it came I couldn't find any holes to solder the headers. Also the specific module is pretty rare and I couldn't find anything.
Here is an image:

How do I wire up this chip?

Are you able to post a clearer photo? If your camera has a close-up or 'macro' mode then it may help.

You at least post a link to the item on ebay; the blur pict you linked to is totally useless currently.

@jfpoilpret Not exactly useless, but it definitely needs improvement.

From the picture you posted, i was able to google and find something called a BC04-B Bluetooth serial module. It looks almost exactly like yours, and I found a diagram on how to hook it up.

I also believe that these are the serial commands you can use with it...

It could be HC-06 or HC-05 but they operate quite similarly.

These Bluetooth modules are typically mounted onto another substrate, either the product board or a small PCB backplane which provides the pinouts and any additional circuitry like the pairing LED, and power- & signal-level management.
They are readily available as HC-05 (master/slave) or HC-06 (slave only) with signals brought to through-holes or pins at the edge of the backplane.


text:
External access to Yun - request not recognised as HTML
I am trying to access my Yun externally.
My router recognises traffic on Port XXXXX and forwards it to my Arduino Yun.
I have the below code working internally and now trying to adapt this to work for external (adapted from http://arduino.cc/en/Tutorial/TemperatureWebPanel).
To access the Arduino Yun over the network I type:
http://XXX.XXX.XXX.XXX:XXXXX/arduino/on

When using this script locally, i.e. myArduinoName.local/arduino/on, the onboard light turns on (and off if URL changed accordingly).
Adapting this working code, I have changed to "noListenOnLocalhost" and put in my port number (XXXXX).
The code is reached (see below for the response).
#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>

// Listen on default port 5555, the webserver on the Yun
// will forward there all the HTTP requests for us.
YunServer server(XXXXX);
String startString;
long hits = 0;

void setup() {
  //Serial.begin(9600);

  // Bridge startup
  pinMode(13,OUTPUT);
  digitalWrite(13, LOW);
  digitalWrite(13, HIGH);

  Bridge.begin();
  Console.begin();

  // Listen for incoming connection only from localhost
  // (no one from the external network could connect)
  //server.listenOnLocalhost();
  server.noListenOnLocalhost();
  server.begin();

}

void loop() {
  // Get clients coming from server
  YunClient client = server.accept();

  client.println("hello");

  // There is a new client?
  if (client) {
    // read the command
    String command = client.readString();

    command.trim();        //kill whitespace

    client.println(command); // why does this return a full GET request instead of "on"?

    if (command == "on") {
      digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(1000);
    }

    if (command == "off") {
      digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
      delay(1000);              // wait for a second
    }

    // Close connection and free resources.
    client.stop();
    hits++;
  }

  delay(50); // Poll every 50ms
}

The response I get is (I have replaced my IP and port with X's):

hello
GET /arduino/off HTTP/1.1 Host: XXX.XXX.XXX.XXX:XXXXX
  Connection: keep-alive Pragma: no-cache Cache-Control: no-cache
  Accept:
  text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
  User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36
  (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36
  Accept-Encoding: gzip, deflate, sdch Accept-Language:
  en-GB,en-US;q=0.8,en;q=0.6

I expected

hello
on

So it would seem that because I'm using a different port (other than 80 or 5555) the response is no longer being interpreted as an HTTP request.
I have also tried to edit the uhttpd file via SSH to provide a specific address and port for both my external IP address and my fixed internal IP address.
Then tried to restart the device and also a uhttpd restart i.e.:
/etc/init.d/uhttpd restart

I have attempted to access the URL using my mobile phone (i.e. not on the same network).
Any ideas why my request is not being treated as HTTP?

It works!
The changes to the uhttpd must have done the trick to listen for http traffic on a given IP/port (other than 0.0.0.0:80).
Instead of supplying a port number for the server in the code, I would surmise that the change to the config takes care of it so this, so the port number in code is no longer needed:
YunServer server(XXXXX);
should be changed back to
YunServer server;


text:
Having difficulty uploading sketch to an Arduino Pro Mini
Having developed and tested a project using an Arduino Uno, I would now like to upload it to an Arduino Pro Mini (5V, 328, 16MHz) for semi-permanent, long-term use, but I can't get any sign of life from the Pro Mini.
I'm using the latest Arduino IDE (v1.6.0 with Java 6, on Mac OS X Mavericks), and I've got a USB 2.0 to TTL UART 6PIN CP2102 Module Serial Converter to connect the Pro Mini to the Mac, and I've selected Tools —> Board —> Arduino Pro or Pro Mini (5V, 16MHz) w/ ATmega328.
The problem is that I don't see a suitable serial port in the list. When I plug in the Arduino Uno, "/dev/tty.usbmodem1421" immediately pops up in the Tools —> Serial Port menu, but I don't see anything similar with the Mini Pro.
The problem is probably in the connection between the USB/TTL converter and the Mini Pro, so my question is: which pins should connect to which?

FWIW the USB/TTL converter was supplied with a 5-core (not 6-core) cable to connect its 6 pins.
So do I connect Tx—>Tx and Rx->Rx, or should they be crossed over? It's fairly clear that "5V" connects to "Vcc" and "GND" goes to "GND", but what about CTS and DTR?
Also FWIW, I have googled this, and I have read a number of other posts and answers on StackExchange, but the fact that I'm here writing my question means that I'm still stuck. Any and all constructive suggestions will be appreciated. Thanks!

Forgot to mention: I've tried just plugging the six pins straight across into the six holes, and I've tried just using four connections as suggested here, but to no avail.

Linking a relevant post: https://arduino.stackexchange.com/a/95853/92185

You need to hook it up with the Arduino TX --> FTDI RX, and vise versa, so crossed over.  If you take the FTDI and hook it up to the Ardiono pin to pin as you have it pictured it should work, provided the FTDI works.
No to your note about not having a serial port, you should have that as soon as you plug the FTDI into your computer, the Arduino is not necessary for this.  First things first, check you drivers, and check your USB connection.  You won't get anywhere until that Serial port is recognized on your computer.

Thanks for your help. I think I expected to see the serial port as soon as the FTDI was present, but wasn't sure.
Now... drivers, you say? I'll go googling for those, unless someone has a helpful link...

@TimMorley Mine always install automatically, but I'm on Windows.  Who knows about you Mac guys :)  I would think it would be pretty similar to the Arduino drivers (Maybe even compatible) but I don't use that particular FTDI device.

Yay! With drivers I got the COM port to show up in the Arduino IDE; and the advice in the comment from @kontur helped me to find the split second when I had to press the RESET button; and I now have my sketch uploaded to my Arduino Mini Pro. Thank you, @Butters!

@TimMorley It looks like that FTDI is setup for the auto reset, so if you hook up all 6 pins, it should take care of the reset for you.  When I have pins like that on one of my boards, I put them in the arduino, and with just a little force forward on the FTDI, enough contact is made to flash the Arduino.

If you still have any issues, try connecting the vcc and gnd to raw and gnd near the pins. Mine worked this way


text:
Multiple shields on one Arduino/Linker base shield
I'm using an Arduino Uno R3 along with an Ethernet shield as well as the linker base shield for interfacing with three linker modules, light, temperature and some LEDs as I believed this would be simpler than using a breadboard and look neater. Are there any problems I'm likely to run into regarding compatibility or power consumption? It's a prototype for a hydroponic garden automation system. As a secondary, are there any c02 sensors under $60 available on the market?

I would recommend looking up the power consumption specs on the datasheets for each shield. Then determine whether the current used by all of the shields exceeds the limits for any given pin and for the board as a whole. I highly recommend the following article: http://www.ruggedcircuits.com/10-ways-to-destroy-an-arduino/


text:
How to program ATTiny85 running 3.3V
I have a working project built around ATTiny85 on a breadboard running at 5V. Now I want to move this prototype on a PCB where it will be powered from batteries. All components used are capable of running 3.3V so I want to run the ATTiny85 at 3.3V as well.
I don't have a programmer so I use ArduinoISP to program the ATTiny. If I change the fuses on Tiny to run it at 3.3V can I still use the 5V Arduino to program the tiny?
Since the ATTiny can easily run at 5V I don't see any problem with programming it at 5V levels and then run it at 3.3V. Is that correct?

Since the ATTiny can easily run at 5V I don't see any problem with programming it at 5V levels and then run it at 3.3V. Is that correct?

Yes. But if there are any components on the board that can't run at 5V then you must provide some way of protecting them from the excessive voltage.

If I change the fuses on Tiny to run it at 3.3V can I still use the 5V Arduino to program the tiny?

There are no fuses required to change the actual operating voltage of the device. There is the BOD threshold, but you can still operate the device at a higher voltage without issue regardless.

Most ideal would be to use a buffer chip (like there is on the AVR Pocket Programmer).
But in your case you could get away with just placing some resistors (1k or something) on the ISP lines. This is because if the chip is powered by 3v and you put a 5v signal on one of the pins it's clamping diodes will redirect the higher voltage to VCC, raising VCC to 5v. In your case the 5v is not necessarily a problem. But if you circuit is using e.g. 100mA, that means 100mA will go through the clamping diode. It's not designed for that.


text:
Arduino and ESP8266 Web server
First things first, if there was an ESP8266 StackExchange, I would post this there.
I am setting up a web server that will programmaticly be controlled from an external Python script, and I am currently able to send this server data using this script, but I don't receive an HTTP response back when I do, so the external script crashes.
I have googled around and not found much on this, so the question is How do I, From the Arduino, using an ESP8266 send an HTML response code?

After countless Trial/error attempts, I was able to put together the proper sequence.
AT+CIPSEND=0,40  \\Set this for your current connection ID and payload length.
HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n
AT+CIPCLOSE=0  \\Set this for your current connection ID

Send these commands with the arduino, and it should exit successfully.  You can also flush out the HTTP line with any other information you would like to include, as defined in the rfc2616 (HTTP/1.1) standard

Altough this works fine, I recommend you to take a look at ditching your arduino and just using your esp8266. The ESP8266 is much more powerfull then the Arduino. Take a look at the Sming Framework for example. It gives you so much more to work with the driving it through AT commands

@larzz11 While, yes the ESP is easier to work with natively, I only had access to the 8 pin version (Then REV number escapes me at the moment) and that didn't give me enough GPIO pins for the project at hand, and it didn't have enough processing time or memory.


text:
Can you query the current serial port's speed?
Is there some code I can use to find out what the a chosen serial port's speed is running at ?

Might just be easier to define the speed in a variable :)

Do you mean the PC or some other device sets the serial speed, and the Arduino to adjust itself to match?

There is not a top level, easy to use way. Sorry. It is probably easier to just store your chosen baud rate in a variable when you setup the serial port.
Anyway, What you can try to do for the AVR-based, hardware UARTs is undo what Serial.begin does to set up a particular baud rate, but its a bit of a pain. This is the code for setting the baud rate:
  // Try u2x mode first
  uint16_t baud_setting = (F_CPU / 4 / baud - 1) / 2;
  *_ucsra = 1 << U2X0;

  // hardcoded exception for 57600 for compatibility with the bootloader
  // shipped with the Duemilanove and previous boards and the firmware
  // on the 8U2 on the Uno and Mega 2560. Also, The baud_setting cannot
  // be > 4095, so switch back to non-u2x mode if the baud rate is too
  // low.
  if (((F_CPU == 16000000UL) && (baud == 57600)) || (baud_setting >4095))
  {
    *_ucsra = 0;
    baud_setting = (F_CPU / 8 / baud - 1) / 2;
  }

  // assign the baud_setting, a.k.a. ubrr (USART Baud Rate Register)
  *_ubrrh = baud_setting >> 8;
  *_ubrrl = baud_setting;

You can find the results of this by reading the right UCSRA, UBRRH, and UBRRL registers. On an uno those are the correct register names, on an mega its UCSR0A, UBRR0H, UBRR0L for Serial, UCRS1A ... for serial1 and so on. Non-avr boards (and Serial on a leonardo) will be totally different.
There will be a single state for those three registers on an AVR hardware serial port for a particular board (and frequency of that board) at each baud rate. You can try and make an equation to get the original baud rate out, but I recommend just comparing the direct values with a lookup of some kind because the integer arithmetic rounding errors will make it a huge mess.
For example, on my mega UBBR0H, UBBR0L, and UCSR0A are 0, 207, 2 at 9600 baud, but they are 0, 51, 2 at 38400 baud and 0, 16, 0 at 57600 baud.

thanks this is the sort of thing i was looking for, but as said it may be more trouble than worth compared with other alternatives.


text:
STEPPER MOTOR CONTROLLER Using LEONARDO PRO MICRO
I want to Use LEONARDO PRO MICRO and A4988 Stepper Motor DRIVER to control Nema 17 Stepper Motor.

Please let me know how to hookup these together.
Please give me a circuit for this type of assembly with Arduino code.

You can simply make a google search;

Here is some code to get you started
// Declaration of variables
#define Step 7     // Pin that transmits the "step" order to the board
#define Dir  6     // Pin that indicates the direction of the rotation
int vit  =   10 ;   // Speed of the rotation (smaller means faster rotation)
int sens =   1  ;  // Rotation direction (0 or 1)

void setup()
{
  pinMode( Step  , OUTPUT );
  pinMode( Dir   , OUTPUT );
}
void loop()
{
    digitalWrite( Dir   , sens);
    digitalWrite( Step  , LOW);
    // Fabrication d'un "Pas"
    digitalWrite( Step, HIGH );
    delay(vit);
    digitalWrite( Step, LOW );
    delay(vit);
}

Just a google search and I got on [this site][2] which had the code I gave you.
I think you can also find some libraries that can do the work for you.
in case that you need to wait less than a millisecond, millis() won't be useful for you; instead, use delayMicroseconds() which will make you wait a thousandth (at minimum) of a millisecond.
EDIT
For what you asked you have to first get the voltage:
float voltage = analogRead ( 0 )  * (3.0 / 1023.0);

You just have to adapt your speed relatively to the voltage.
To do this, I suggest you the map function directly from Arduino site.
Be careful just because whatever you are doing, analogRead takes 100 microseconds to get the voltage, so if you need to go very fast you can't.  I suggest you to work with a different type of communication, like Serial, SPI or I2c.

Thanks, Can you tell me how can i control motor speed/RPM using a analog voltage which came from some other device. The voltage are range in 0-3V.

There you go. I edited the answer for your question


text:
Read data from SD
I have logged  some data in my sdcard/FAT32 (format).
I can read and display them on the serial monitor but additionally I want to use these data as float.
Here is my code:
       byte index = 0;

       Tfile = SD.open("DATALOG.TXT",FILE_READ);

       while (Tfile.available()) {

         x[index++] = Tfile.read();
         x[index] = '\0'; // NULL terminate the array
       }

Printing the data using:
   Serial.print(fileContents);

I receive  the following float values that are correct:
   .63
   15.63
   16.60
   16.60
   16.60
   16.60
   etc

Now I want to work with values so i need to store them on a double index:
    double dtemp[320];
    for(index = 0, i=0; index < 320; index++, i++) {
       dtemp[i] =  fileContents[index];
       Serial.println(dtemp[i]); }

but i receive fault values:
      46.00
      54.00
      51.00
      13.00
      10.00
      49.00
      53.00
      etc

Any comment is welcomed !
Thank you in advance !

The "fault" values are the ASCII code...ok there is a solution reading the valid values(excluding the new line and carriage return) an putting them in an index 5x320, each line will be whole number and then I can store it in a float... but is there a faster way?

You have to parse the character array in order to convert it to
floats. There is no fast way to do this: since the Arduino has no FPU,
anything involving floats is slow.
Unless you really have to, I would not recommend slurping the whole file
into RAM. You will save memory by parsing the file on the fly. This
should be as simple as calling the parseFloat() method of the File
object:
double dtemp[320];
int i;
for (i = 0; Tfile.avalable() && i < 320; i++) {
    dtemp[i] = Tfile.parseFloat();
    Serial.println(dtemp[i]);
}
if (i < 320)
    Serial.println("WARNING: Premature end of file.");

Be careful with i declaration, byte is too small tp hold a value as big as 320.

@jfpoilpret: Oops! My bad. Just fixed it, thanks.

using double or float, arduino (UNO in my case) stops responding and it doesn't print anything in the serial monitor. Using int, it parses the integer part of the number correctly....

This is very weird. The parseInt() and parseFloat() functions are extremely similar, and they both implement timeouts. Neither should hang your Uno. I suspect your error lies somewhere else in your code. Could you please update your question with a minimal – but complete – sketch that reproduces the problem? Both the int version that works and the float version that does not please.


text:
Feasibility of a Wi-Fi Positioning System
In the project of guiding a sight disabled person in a known environment, we need to have a precise way of figuring out where the user is. Our current solution is to use WPS.
This is however our first project with Arduino, and we're not quite sure if we're going the right way about this. We're thinking of getting a compass component and such, but is there something we should know before advancing further in the project?
EDIT: Additional information.
The system is placed on the user, most probably strapped to the arm. The communication to the Wi-Fi beacons will be done from there, as well as the calculations.
The environment is supposed to be as complex as an exposition hall, but we can aim higher.
Budget range is around $100, Arduino itself excluded. A UNO is already provided to us.

You need to know where the person is and also in which direction the person is facing (so instructions like "move left", "move right" or whatever are correct). To do this most simply, you would need some kind of sensor or detectable marker on the person. Is this something like you're planning? Perhaps expand a bit more on your thinking.

@RogerRowland My bad; I went a bit too fast and forgot to include that part. I've edited the question with extra information.

This is probably a more general problem than Arduino, have a look on EE.SE where there have been numerous similar questions. It may help refine your ideas.

I don't think that arduino is the right hardware for such a project. Better use a cheap android phone, there you have a stronger processor with more memory as well as a lot of sensors like compass, accelerometer, gyroscope and maybe in newer ones barometer, which you will need - also you have wifi. An arduino uno just comes without wifi and all the sensors. Also I guess a lot of persons already have a phone, so this will lower your project costs, because hardware is already available at most users. Last but not least I think you could use mobile phone vibrations to give feedback to the sight disabled users, oder sound commands like "go left" etc.


text:
Problems with (somewhat) large boolean arrays
I am writing a simple Conway's Game of Life implementation just to get to grips with the "Nokia 3310" LCD and I am having problems with boolean arrays. I am using an (unofficial) Arduino Pro Micro 5V/16MHz
Here's the code that is causing me trouble:
boolean buffer[84][48];

void setup(){
  for(int i = 0; i < 84; i++){
    for(int j = 0; j < 48; j++){
      buffer[i][j] = true;
    }
  }
}

void loop(){}

When I upload this to the Arduino, it seemingly freezes up with the RX led on and its COM port stops working. If I want to upload any other sketch, I have to manually pull the RST pin LOW (since the Pro Micro doesn't have a reset button).
I've been playing around with the code and found out that the source of problems is this line:
buffer[i][j] = true;

It also doesn't matter if I use true or false.
I have tried debugging with Serial to the computer, but the Serial communication doesn't work at all, so I tried using an LED to find out where the problem is. I don't have any "regular" LEDs on me, so I had to try with an Adafruit NeoPixel. The outcome was quite interesting. When I comment out the problematic line, everything runs just fine, the led goes red for 500ms then it blinks white every time the problematic line would run and then it goes green and stays that way. With the problematic line in place, the LED won't do anything, even turn red, which I put much earlier in the code than the source of the problem.
Does anybody have any insights that might be useful? (Also, I really hope it is not some stupid typo, I swear I read it through about twenty times)

According to http://arduino.cc/en/pmwiki.php?n=Reference/BooleanVariables, "Each boolean variable occupies one byte of memory." Meaning you are trying to use 4032 Bytes of RAM with your array which I assume you do not have (whatever this unofficial Arduino is -- it's likely to be less than that: the ATmega328 of the Arduino Mini has 2 kB of SRAM, the ATmega32u4 of the Micro has 2.5 kB).
You could try with a quarter of the field size for a start and see if that makes your problems go away.

It's usually the ATmega32U4 in a Pro Mini I think. That still only has 2.5 KB SRAM though.

The Micro has an ATmega32U4 (I guess you mean that, google says it's the same for the Pro Micro), but the Mini has an ATmega328. (I only know Pro Mini, that's why I assumed it's more like that :)

Yep, that was it. The possibility crossed my mind, but I guess I forgot to check it. Just to clarify - the Pro Micro is functionally identical (AFAIK) to the Micro, but slightly smaller (12 0.1" pitch header pins on the Pro Micro and 17 on the Micro) and was designed by SparkFun instead of Adafruit. Also, by unofficial I meant from eBay :)

Well, if each boolean takes a full byte, as fuenfundachtzig says, then you might try some bitwise hacking to fit 8 bools per byte on your own.  Maybe something like this:
unsigned int16 buffer[84][3];  //16 bits * 3 = 48 bits, per the original example

void init_buffer()
{
    for(int i = 0; i < 84; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            buffer[i][j] = 0xFFFF;  //all TRUE: each F is hexadecimal for 0b1111 in binary
        }
    }
}

bool get_buffer(unsigned int8 i, unsigned int8 j)
{
    unsigned int16 k = 0;
    while(j >= 16)
    {
        j -= 16;  //I can do this because i and j are passed by value and are therefore separate copies inside this function
        k++;
    }
    //now k is the array index and j is the bit position inside that element
    if(buffer[i][k] & (1 << j))  //(bitwise AND with 1 shifted left by j positions, so we only care about that bit)
    {
        return TRUE;
    }
    else
    {
        return FALSE;
    }
    //or, if your compiler supports it, you might replace the if/else with:
    return (buffer[i][k] & (1 << j));
}

As for the stylistic differences between my example and yours:

I like to completely specify my datatypes if I can.  Don't rely on the compiler to do what you expect because it may have options to that effect that are set differently than you think.
I like to use brackets for everything, even single statements, and make them obvious.  That way, there's no confusion later or additional bugs because a second statement was added to what used to be a bracketless single without adding the brackets.

The only exception to that is when I'm writing a series of almost-identical if's and I put both the if and the action on the same line, all aligned so that the subtle differences line up and become obvious.

I'll have to do something of the sorts. The good thing is, that the display I am working with takes 504 bytes to draw the full screen (84 columns of 6 bytes), so I will probably use bytes instead of uint16_t, but I will have to make sure bytes don't have any similar overhead.
Regarding your stylistic advice, I haven't yet had any problem with using just int, but I will have to look into it to know, when it causes problems. Also, I do a similar thing with brackets, but I like to leave the opening bracket at the end of the line after the control structure.
Cheers


text:
7 segment LEDs on wood face
I'm not sure this is right place for this question, but does anyone have any idea how a 7 segment display is projected or embedded in wood for products like this?

Full product info at http://www.amazon.com/Cube-Wood-LED-Alarm-Clock/dp/B00D6DI0LE
Another example:

From: http://www.selectism.com/2013/11/27/a-wooden-led-alarm-clock-and-wireless-bluetooth-speaker-from-gogroove/

Those examples are computer generated. In reality the contrast is a bit less, and the outlines aren't as sharp. But it's still a very cool effect.

This is done by carefully placing a layer of wood veneer over the 7-segment displays. The veneer is thin enough to let the light pass through. I wouldn't be surprised if some manufacturers use brighter than normal LEDs to make the display easier to see. Here is a video detailing an example.
It is also possible to simply drill out the wood to make it very thin where the 7-segment displays go. Here is an example of drilling the solid wood to be very thin.


text:
gpio input read 0, but voltage is 3V3
I'm using GPIO api and configure it as input pull down. It reads value 0. However, when I use power meter, and connect this gpio and ground, it shows 3.3V. Is it normal or maybe some other peripheral module actually pull this gpio high? To reduce power consumption, should I connect this gpio to 3V3 and configure it as input pull high? Thanks.

What is your vref tied to?

How have you configured the pin as pull-down? Did you add an external resistor?

Please show your wiring and your code. Your description is not clear, on Arduino MCU, there is no notion of "input pulldown", it is either "input" (high impedence) or "input pullup".


text:
Streaming IMU data over BLE using Sparkfun 6 DOF and Blend Micro
I am trying to use the RedBear Blend Micro to send data captured by my SparkFun 6 DOF IMU.  I am completely lost, and if anyone has any documentation I can read, or even tutorials that work for this specific IMU, I would highly appreciate it.


text:
Build arduino with windows command line
Can someone explain, step by step, along with all software I must use for using Windows command prompt to build an Arduino sketch (.ino file )?
I've followed these steps but I can't.

See the examples at the end of the link that Federico gave eg example only:
Compile and upload a sketch to an Arduino Nano, with an Atmega168 CPU, connected on port /dev/ttyACM0:
arduino --board arduino:avr:nano:cpu=atmega168 --port /dev/ttyACM0 --upload /path/to/sketch/sketch.ino

You said "I can't": can you clarify what you tried, what you expected andwhat you got?

The command line interface of the Arduino IDE is described in this document
https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc
For example, this command will compile and upload the Blink example to my Arduino Leonardo
./arduino --upload --board arduino:avr:leonardo --port /dev/ttyACM0 --verbose examples/01.Basics/Blink/Blink.ino

Foot note: with IDE 1.6.0, there is an experimental version of the IDE for recent MacOSXs. It doesn't yet support the command line. If you need the command line on Mac, use the recommended version. This will be fixed with 1.6.1