text:
Arduino Uno R3 not recognized by computer, TX and RX not blinking, neither are lit. Is it dead?
I was trying to make my arduino uno r3 to work on my Linux machine (including the IDE), but it wouldn't. At first I thought it was a software problem. Added myself to different groups and did everything, people discussed on the forums. It didn't work. It wasn't recognized by the computer at all. I reinstalled. Nothing again. Thought it was a hardware problem of my computer. Tried with dad's (Windows 7 machine). Didn't work. Then I saw that the two leds (TX and RX) are not blinking, neither are lit. I started doing a research on the internet but everybody suggests doing the loopback test from the IDE. My Arduino Uno R3 is not recognized by the computer, therefore the IDE. Is there any way to check if it's dead or if it's a minor problem?
Edit: I read a lot on the case last night and I reach to the conclusion that my ATmega16u2 (the usb-serial chip, I'm sure it is 16u2 and not 8u2, it's written on the chip itself) might be dead. Tried to reflash the firmware but cannot get it in DFU mode (as it says in this article click here). dfu-programmer (the Linux application) throws the following error: dfu-programmer: no device present. What to do?

Have you tried seeing if a programmer can talk to the two MCUs?

Pretty new to electrical engineering, what does MCU stands for. Google gives too much results.

"Microcontroller unit", or just "microcontroller" for short.

Ok, but how to check if the programmer can talk to the MCUs?

Hook it up and run the programmer software, and try to read something from them.

There is a chance that your bootloader is not working anymore. You can burn a new bootloader to the device with another Uno, there are nice guides on the Arduino-Website.

Before you can access serial TX/RX on Arduino make sure USB to serial converter on the board is working. To check it (on Linux) do the following:

Open the terminal, type 'dmesg' and press 'enter'. You will see some output with timestamps (number in square brackets). Note the timestamp of the last line. Run dmesg several times to make sure nothing writes to it and you still see the last timestamp.
Plug your board into USB port and run dmesg once again. You should see something like the output below. The first line is the last line of dmesg prior to plugging in the Arduino, the second line is actual detection. The board I used in this example is 2560, UNO will give you similar output. If you can see this output your board is recognized just fine. If you can't see it then either the USB to serial chip (just another AVR MCU) on the Arduino or USB host in your PC or both are defective.

    [279152.351690] systemd-logind[867]: New session c51 of user lightdm.
    [280362.732094] usb 3-2: new full-speed USB device number 3 using uhci_hcd
    [280362.931266] usb 3-2: New USB device found, idVendor=2341, idProduct=0010
    [280362.931275] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=220
    [280362.931282] usb 3-2: Product: Arduino Mega 2560
    [280362.931288] usb 3-2: Manufacturer: Arduino (www.arduino.cc)
    [280362.931293] usb 3-2: SerialNumber: 64938323331351213172
    [280362.986579] cdc_acm 3-2:1.0: ttyACM0: USB ACM device
    [280362.988470] usbcore: registered new interface driver cdc_acm
    [280362.988473] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
    [280362.732094] usb 3-2: new full-speed USB device number 3 using uhci_hcd
    [280362.931266] usb 3-2: New USB device found, idVendor=2341, idProduct=0010
    [280362.931275] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=220
    [280362.931282] usb 3-2: Product: Arduino Mega 2560
    [280362.931288] usb 3-2: Manufacturer: Arduino (www.arduino.cc)
    [280362.931293] usb 3-2: SerialNumber: 64938323331351213172
    [280362.986579] cdc_acm 3-2:1.0: ttyACM0: USB ACM device
    [280362.988470] usbcore: registered new interface driver cdc_acm
    [280362.988473] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

dmesg isn't changing it's output at all. lsusb doesn't detect it also. /dev/ttyACM0 or /dev/ttyUSB0 are not created.

If you need an answer to a question which part of my answer answers your question then please ask another question.

What? Why? Your answer doesn't answer my question, it just starts a series of "Do this!" and "Doesn't work comments".

Delete your Arduino IDE, but store your libraries if you need in future.
Download Arduino ERW 1.0.5 from here: http://forum.arduino.cc/index.php?topic=118440
Try your steps again with your connections belong to your schematic.

The hardware doesn't work on two independent machines and you're blaming the software?

Did the other PC has Arduino IDE or Arduino ERW? I guess, it was Arduino IDE not ERW. Shall we try ERW? If not, I will be in silence.

Arduino ERW is only for Windows and I use Linux. For now, I don't have a Windows PC around me, but even if I had, I need to make it work under Linux. I understand that, at least I will find out if the Arduino board is broken, but...


text:
Increasing payload size above 32 bytes using nRF24L01+
I tried to modify the example in the following page, by replacing the given string with a 56 bytes one after making all the suitable changes to read(), write() and max_payload_size(increased to 64 bytes), payload_size() parameters/methods in the RF24 library.
http://shanes.net/another-nrf24l01-sketch-string-sendreceive/
The problem is the receiver truncates the string to 32 characters. Is 32 bytes a hard limitation for payload with the nrf24l01+ radio? If so how to I modify the receiver in above example problem to receive the entire string?

If you look at the specification or datasheet for the nRF24l01+, you will see that the 32 byte payload is the maximum that the device can handle.
For example:

If you need to transmit anything larger than 32 bytes, you will need to develop a protocol that splits up your data into chunks of 32 bytes or less and sends the data in several packets.
The actual protocol you design is up to you, but a simple technique might be using the first packet to send a count of the number of data packets to expect and then simply send those packets, each with a part of your data and reassemble it at the receiving end.
You may need to design something more robust so you don't get confused by lost packets or bad data. The larger your payload, the more chance of transmission errors, so it might be an idea to experiemnt with the payload size to get the best throughput for your particular application.

source: Stack Exchange

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

sort: votes


text:
Increasing analogread speed on the Arduino Uno
I want to transfer data from my smartphon to the Arduino by using the audio jack of my smartphone. For this I need verry high reading frequencys.
I have used
bitClear(ADCSRA,ADPS0);
bitSet(ADCSRA,ADPS1);
bitClear(ADCSRA,ADPS2);

to boost analogread to ~10microseconds, which would be enough. But somehow I am still wasting 5.4 ms at the beginning of the transmission.
The only thing between signal start and first analogread is a start of a for loop:
while(analogRead(A0)<50) (true); //wait for start of transmission
for(i = 0; i<500;i++){
data[i]=analogRead(A0);
}

But does starting a for loop take 5.4 ms?
Do you have any ideas?

Before we spend any more time on this, what conversion speed/rate do you require?

Currently recieving a 40 bit packet takes about 10ms. I would consider 5ms a good value.

An Instructable on audio sampling got 125us per sample using analogRead(), down to 26us per sample by bypassing analogRead, reading straight from the register, and clipping to 8-bit resolution. See sections 5 and 6. I suspect that's pretty much as fast as it gets. http://www.instructables.com/id/Arduino-Audio-Input/?ALLSTEPS

I am allready at 10us. But between seeing the first signal and saving the next signal 5.4 ms pass.

So only the first cycle (i==0) takes 4.5ms, all the others (i>0) take 10uS? From the datasheet; A normal conversion takes 13 ADC clock cycles. The first conversion after the ADC is switched on (ADEN in ADCSRA is set) takes 25 ADC clock cycles in order to initialize the analog circuitry.. Try doing a dummy analogRead in the setup function.

@Gerben From while(analogRead(A0)<50) (true); to data[i]=... it takes 4.5ms. My signals are stronger than 50 and so the while loop stops and the next analogread is written to the array. But the array contains only values, which were send 4.5 ms before. So analogread is called many times before the actual measurement.

It sounds like you could benefit from interrupt handled free running sampling, doing that should get you sampling rates up to the maximum listed on the 328's datasheet, 76.9 kSPs. Although, that's at a reduced resolution. This site explains better, under the section "Free running sampling".

I did some further analysis on the signal and the problem was not the Arduino. It did everything quick and correct.
The problem was my smartphone. I used androids AudioTrack class and somehow it did cut off parts of the signal. This could be "fixed" by increasing the length of the signal. I just added 0's at the beginning and end.

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


text:
integration of GSM module and Bluetooth using arduino
Please help me. There is a conflict when I put GSM and Bluetooth module in one MCU. The problem is when I use the GSM, the Bluetooth will not respond and vice-versa.

How do you "use the GSM" and what response are you expecting from the Bluetooth module that you didn't get? There's not enough information here to know what's happening.

actually i cant connect the GSM module to the network and also i cant combine the GSM module and Bluetooth module in one MCU. i'm using arduino uno


text:
Does Leonardo need a separate power supply?
I'm currently using an Arduino Uno (R3), but want to switch to Leonardo for the USB-ability. The Uno can work from the USB's 5V. Looking at the Leonardo's schematic it seems the only input to the voltage regulator is from the power connector. This makes sense as it's a 5V regulator which needs > 5V in. But I don't see the MOSFET which connects the USB's 5V to the board's 5V, like there's one on the UNO.
So, does the Leonardo need the separate power input connected?

Power steering is performed by the assembly labelled "+5V AUTO SELECTOR" at the bottom of the page. The voltage at VIN is halved and then compared with the board's 3.3V output in order to determine whether or not to enable USB power via T1.

Ow! Didn't see that. It was close enough to the 1117 though. :-( Thanks a lot!


text:
Connecting multiple DHT 11 sensors
I want to collect data (both Humidity & Temperature) from 80 sensors. let's say I have 80 "DHT 11 Humidity & Temperature" sensors (for ex. in a warehouse) and one Arduino Uno R3 pack. It's clear that arduino has no so many pins to connect. I'm sorry that I don't know if it's possible. If so, what can I use to achieve this?
Thank you all for your suggestions.

Probably it may be possible with multiplexing but I don't know which multiplexer to use and how to connect multiplexer :(

80 sensors would means some sensors will have a few tens of meters of wire. You'll run into data integrity issues with that long a cable. Also might I suggest the DS18B20. No humidity, but better precision. Every sensor has its own 64-bit unique address, so you can have multiple sensors on one data line. It doesn't even need a separate power line.

Analog multiplexers are one way, but they tend to have a significant resistance when on, and this could cause the protocol not to work.
For 80 channels you need 7 bits addressing. Say you have an 8-input multiplexer, then a 3-bit address indicates which of the 8 inputs is selected. Use 10 of these, all with the three address lines connected, and you have 10 outputs from 80 inputs.
Next, use a 16-input multiplexer to select which of the 10 inputs you want to use. For this multiplexer you need 4 address lines. Together with the other 3 address lines you have 7 address lines, enough to select 1 of up to 128 sensors. But I repeat, this approach may not work if the multiplexer's resistance is too high.
A more robust (albeit more expensive) is to use analog switches to connect/disconnect each sensor. Analog switches (Analog Devices has a lot of them) have on-resistances down to < 1 ohm, so the sure should be OK for the application.
To control the long series of switches you could use a daisy chain of 74HC595 shift registers, which only requires a couple of I/Os on your controller, but gives you virtually unlimited outputs.

I think 74HC595 shift registers will be good choise :) thank you very much for your answer


text:
Arduino on battery getting unstable if temperature falls
i am building an outdoor sensor with a combination of a custom Arduino board and a battery (+solar charging). I experience strange behavior when the temperature falls below a certain value (i can reproduce it by putting it in the freezer), regardless which type of battery i am using. The custom Arduino runs without power-regulation, straight from the 3.7volts the battery can provide.
How can i prevent this to happen? I guess a little heating would be not really a solution as i am trying to consume as less energy as possible.
Would a (step up) regulator possibly help? Any other ideas?
---Update---
Thanks to your comments here i figured out, that the AVR 328p should not be operated below a voltage of 3.7v if run at 16Mhz. As i am running with a 3.7v LiPo Battery that could easily explain my problem i guess. My first try to decrease the processor speed to 8Mhz with a Prescaler worked, but the GSM Fona does not seem to like it. So i would like to try something in between like 10Mhz or 12Mhz. As the prescaler does not support this, my question is: can i just use another crystal or would i have to modify something in the code/bootloader as well?

Lithium chemistries may not like cold, so consider something else.  Also make sure you clock is in spec for the voltage and that your brown out fuses aren't set high.

AFAIK all battery chemistries have problems with cold: Capacity drops, current delivery drops, and internal resistance increases, so the voltage over your device drops. Not sure if a step up regulator would help, since the battery may still be too current limited in the cold. Perhaps an EE question? Not an expert, but I imagine a combination of more batteries and a regulator would help.

As others have mentioned, most batteries have problems at low temperatures. In very cold conditions I used to keep batteries next to the body. You could test this by running in the freezer with the battery outside.

In theory you could need to adjust the capacitors on the crystal, in practice it is likely to just work, especially if you can find the specs of the original and order something similar.  But figure out how low the voltage is really dropping if loaded when cold - and consider if rising impedance may be a better model than dropping nominal voltage.

see instructions for 12Mhz bootloader here: http://ceptimus.co.uk/?p=102

To answer your modified question:
Running the ATmega328p at 16Mhz with 3.7v is out of spec - see this EESE answer for reference or the ATmega datasheet - so the obvious solution would be to lower its speed to 8Mhz.
But since you also mentioned that there is an additional GSM breakout board involved (Adafruit Fona), which expects UART (in auto-baud mode) Rx/Tx connection, it might not be that trivial. Further exploration of the Fona library's source code reveals that it has several hard-coded delays (see Adafruit_FONA.cpp::begin, for example), but its core seems to be implemented inside the Adafruit_FONA::readline method, which uses an underlying Stream, which in turns comes from a Software/Hardware serial object, as shown in the FONAtest.ino example that comes with the library.
From my experience, Software/Hardware serial should work fine on 8Mhz, except maybe when using high baud rates, which is solvable.
The hard-coded delays doesn't look like they should cause actual damage except for delay, but you could cut them in half just to see if you can make the library work.
Additional aspect that you should consider is the comment from Adafruit's Fona product page, regarding pin Vio:

This is the pin that you MUST drive with an external voltage from
  3V-5V to set the logic level converter

So, despite that from the datasheet, the Fona seems to have a voltage regulator, you might still want to consider adding a decoupling capacitor between Vcc and Gnd of your battery, to  mitigate transient current draws from any component in your circuit.

Actual GSM (even in comparison to its more modern replacements) involves quite high current, I could easily see the first transmit attempt triggering a brown out when the battery is cold.

@Chris that's a very good point

Excellent hint Omer - i also had checked the library for delays etc. and cut them in half - but i didn't have the baud-rate in mind. Instead of 4800 i am now initializing Fona with 9600baud and everything seems to work fine so far, it is running since hours now.

It's most likely that the cold weather is messing with your batteries. I don't know what battery types you've tried, but this site says that Lithium batteries (Not Li Ion, but standard single use, expensive, lithiums) hold up well in very cold and very hot environments. For rechargeable batteries the site recommends NiMH batteries. Of course, we all know that lead acid batteries hold up well in cold (Or else our cars wouldn't start!), so those are also a viable option. Lead acids can be purchased in somewhat small forms, but they may still be too big for your purposes.
For the other part of your question, yes a regulator will help. It's rarely acceptable to run directly off a battery without a regulator. Since your application is low power you'll want to use an efficient switching regulator (Search for modules, not individual chips). Remember that a battery's output changes based on its charge level, temperature, current draw, and other things I'm likely forgetting. Using a regulator mitigates these effects as regulators are less affected by temperature and current draw than the battery that supplies it (Hopefully).
So to summarize: Use Lithium batteries, or NiMH if you need to recharge, or Lead Acid if you need a ton of capacity and size isn't a limit. Then get a switching regulator module. Best of luck with your project!

No, it is quite normal to run processors such as the ATmega off unregulated batteries whose useful curves fall within their input range.  Please review the specs before making recommendations.

When using battery, always use a step-up converter, something like LTC3525 or NCP1402. A direct connection of unregulated battery voltage to an analog input can give you a good information on the remaining capacity while the step-up converter still provides stable 3.3V for operation.

No.  This is throwing expense and inefficiency in a direction far removed from the problem, which is simply that the chosen cell won't deliver useful energy.

I beg to differ. A step-up converter assures the microcontroller to work until the very end of battery capacity and enables reporting low-battery status. Assuming the battery is providing accurate voltage is energy efficient (about 15% more efficient) but far from reliable.

A converter can't obtain energy which isn't there.  Additionally, over discharging rechargeable lithium cells prevents their reliable recharging.

True, but the microcontroller is rather sensitive to low voltage when running on higher frequencies and that seems to be the problem with Stephan's outdoor sensor in cold environment. That's why I think the converter might be useful. As you have already pointed out in your comment, reducing the frequency actually enables the chip to run on much lower voltage so this could be an alternative way to go. Though you can not rely on reference voltage any more if it is not regulated, but this is another story.


text:
Interfacing Hex keypad with arduino
I was trying to interface my hex keypad with Arduino. I declared rows as input and columns as output. When I initialize three of the four columns as HIGH and one as LOW, and detect the button pressed as LOW in the corresponding row, it works fine. That is, it detects the button when its corresponding row and column is LOW. But, when I reverse the condition, i.e. when I try to detect the button pressed when its corresponding row and column is high while others are low, it does not work as expected.
I really want to know why is this happening?
The code that works:-
int row[]={6,7,8,9};
int col[]={10,11,12,13};
int i,j;
int col_scan;
void setup()
{
   Serial.begin(9600);
   for(i=0;i<=3;i++)
   {
      pinMode(row[i],OUTPUT);
      pinMode(col[i],INPUT);
      digitalWrite(col[i],HIGH);
   } }
void loop()
{
   for(i=0; i<=3; i++)
   {
      digitalWrite(row[0],HIGH);
      digitalWrite(row[1],HIGH);
      digitalWrite(row[2],HIGH);
      digitalWrite(row[3],HIGH);
      digitalWrite(row[i],LOW);
      for(j=0; j<=3; j++)
      {
     col_scan=digitalRead(col[j]);
     if(col_scan==LOW)
     {
        keypress(i,j);
        delay(300);
     }}
   }}
void keypress(int i, int j)
{
   if(i==0&&j==0)
      Serial.println("1");
   if(i==0&&j==1)
      Serial.println("2");
   if(i==0&&j==2)
      Serial.println("3");
   if(i==0&&j==3)
      Serial.println("A");
   if(i==1&&j==0)
      Serial.println("4");
   if(i==1&&j==1)
      Serial.println("5");
   if(i==1&&j==2)
      Serial.println("6");
   if(i==1&&j==3)
      Serial.println("B");
   if(i==2&&j==0)
      Serial.println("7");
   if(i==2&&j==1)
      Serial.println("8");
   if(i==2&&j==2)
      Serial.println("9");
   if(i==2&&j==3)
      Serial.println("C");
   if(i==3&&j==0)
      Serial.println("*");
   if(i==3&&j==1)
      Serial.println("0");
   if(i==3&&j==2)
      Serial.println("#");
   if(i==3&&j==3)
      Serial.println("D");
}

the code that doesn't work:-
int row[]={6,7,8,9};
int col[]={10,11,12,13};
int i,j;
int col_scan;
void setup()
{
   Serial.begin(9600);
   for(i=0;i<=3;i++)
   {
      pinMode(row[i],OUTPUT);
      pinMode(col[i],INPUT);
      digitalWrite(col[i],LOW);
   } }
void loop()
{
   for(i=0; i<=3; i++)
   {
      digitalWrite(row[0],LOW);
      digitalWrite(row[1],LOW);
      digitalWrite(row[2],LOW);
      digitalWrite(row[3],LOW);
      digitalWrite(row[i],HIGH);
      for(j=0; j<=3; j++)
      {
     col_scan=digitalRead(col[j]);
     if(col_scan==HIGH)
     {
        keypress(i,j);
        delay(300);
     }}
   }}
void keypress(int i, int j)
{
   if(i==0&&j==0)
      Serial.println("1");
   if(i==0&&j==1)
      Serial.println("2");
   if(i==0&&j==2)
      Serial.println("3");
   if(i==0&&j==3)
      Serial.println("A");
   if(i==1&&j==0)
      Serial.println("4");
   if(i==1&&j==1)
      Serial.println("5");
   if(i==1&&j==2)
      Serial.println("6");
   if(i==1&&j==3)
      Serial.println("B");
   if(i==2&&j==0)
      Serial.println("7");
   if(i==2&&j==1)
      Serial.println("8");
   if(i==2&&j==2)
      Serial.println("9");
   if(i==2&&j==3)
      Serial.println("C");
   if(i==3&&j==0)
      Serial.println("*");
   if(i==3&&j==1)
      Serial.println("0");
   if(i==3&&j==2)
      Serial.println("#");
   if(i==3&&j==3)
      Serial.println("D");
}

There could be any number of reasons, but we'd need to see a schematic and some code, or at least the representative parts of each. There's not enough information here to be able to tell.

To use unipolar switches as inputs, you need pulling resistors to give the input pin a defined value when the switch is open.
The ATmega has software configurable internal pullups.  Even if these are not configured, implementation detail may (or may not) yield a very weak unreliable pullup effect.
There is no configurable pulldown on the ATmega.  To operate in that direction (with a switch to high) you would need external pulldown resistors.
A few matrix keyboards include diodes, to combat some of the confusion which results when multiple keys are pressed in a simple matrix.
Also, you should add a tiny delay between driving and reading, in order to allow for capacitive delay.


text:
Simultaneous input output in arduino mega
I need to read 5 analog pins simultaneously , is it possible?
note that:
analogRead(1);
analogRead(2);
analogRead(3);
will not work this case

on the UNO (mega should be same) the analogRead(x); takes about 500us to complete. So depending upon the reaction speed of the signals that may be sufficient. You need to ask yourself what is the precision of time you consider to be simultaneous. If you are only looking at sampling everything once a Kilo Hertz (give or take) then back to back reads may be sufficient.

Why won't the code given work?

No, it is not. The ADC in the MCU is only capable of sampling a single analog channel at a time.
If you require sampling more than one channel at a time then you will need to use one or more external ADCs that are capable of sampling multiple channels, or multiple ADCs each dedicated to a single channel.


text:
Random(min,max) Function only giving ~50 range no matter what the values?
I can't get the min,max range to function properly. Monitoring the serial, only gives out ~50 difference from the min. I then added truerandom.ino to try to fix, but no help.
const int ledPin = 13; // the number of the LED pin
// Variables will change:
int ledState = LOW; // ledState used to set the LED
long previousMillis = 0; // will store last time LED was updated
// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
//long interval = random(800, 8000); // interval at which to blink (milliseconds)
void setup() {
// set the digital pin as output:
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
// here is where you'd put code that needs to be running all the time.
// check to see if it's time to blink the LED; that is, if the
// difference between the current time and last time you blinked
// the LED is bigger than the interval at which you want to
// blink the LED.
long interval = random(800,8000);
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
Serial.println(interval);
}
}

Added truerandom.ino still ~50 range:
// TrueRandomSeed.ino
//   This example sketch shows how to provide a truly random seed value to the built in
//   library pseudo random number generator.  This ensures that your sketch will be
//   using a different sequence of random numbers every time it runs.  Unlike the
//   usually suggested randomSeed(analogRead(0)) this method will provide a much more
//   uniform and varied seed value.  For more information about the basic technique used
//   here to produce a random number or if you need more than one such number you can
//   find a library, Entropy from the following web site along with documentation of how
//   the library has been tested to provide TRUE random numbers on a variety of AVR
//   chips and arduino environments.
//
//   https://sites.google.com/site/astudyofentropy/project-definition/
//           timer-jitter-entropy-sources/entropy-library
//
//   Copyright 2014 by Walter Anderson, wandrson01 at gmail dot com
//

#include <avr/interrupt.h>
#include <avr/wdt.h>
#include <util/atomic.h>
// The following addresses a problem in version 1.0.5 and earlier of the Arduino IDE
// that prevents randomSeed from working properly.
//        https://github.com/arduino/Arduino/issues/575
#define randomSeed(s) srandom(s)

volatile uint32_t seed;  // These two variables can be reused in your program after the
volatile int8_t nrot;    // function CreateTrulyRandomSeed()executes in the setup()
                         // function.
const int ledPin = 13; // the number of the LED pin
// Variables will change:
int ledState = LOW; // ledState used to set the LED
long previousMillis = 0; // will store last time LED was updated

void CreateTrulyRandomSeed()
{
  seed = 0;
  nrot = 32; // Must be at least 4, but more increased the uniformity of the produced
             // seeds entropy.

  // The following five lines of code turn on the watch dog timer interrupt to create
  // the seed value
  cli();
  MCUSR = 0;
  _WD_CONTROL_REG |= (1<<_WD_CHANGE_BIT) | (1<<WDE);
  _WD_CONTROL_REG = (1<<WDIE);
  sei();

  while (nrot > 0);  // wait here until seed is created

  // The following five lines turn off the watch dog timer interrupt
  cli();
  MCUSR = 0;
  _WD_CONTROL_REG |= (1<<_WD_CHANGE_BIT) | (0<<WDE);
  _WD_CONTROL_REG = (0<< WDIE);
  sei();
}

ISR(WDT_vect)
{
  nrot--;
  seed = seed << 8;
  seed = seed ^ TCNT1L;
}

void setup()
{
  CreateTrulyRandomSeed();
  randomSeed(seed);
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
  // The preceeding two function calls will take approximately 0.5 second to execute if
  // nrot is set to 32 ... the rest of your setup code should FOLLOW from here.
}

void loop()
{
  long interval = random(800,8000);
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
Serial.println(interval);
}
}

can you give some example outputs of random sent through serial?

818
847
800
842
802
801
818
817
813
849
817
810
808
805
808
810
828
814
818
810
813
817
803
830
803
802
824
829
836
844
804
806
813
849
831
848
806
803
802
833
842

I suspect it actually is generating other values and it's your program logic that's at fault.
Here's what I think you meant your program to do:

Generate a random interval.
Wait until that interval has elapsed.
Start again with a new interval.

Here's what's actually happening:

Generate a random interval.
Check if that interval has elapsed.
Whether or not it has elapsed, generate a new random interval anyway.

Note that you're generating a new random interval every time round loop(). This means your condition just keeps trying new random intervals until one happens (by chance) to be less than the amount of time that's elapsed since the last interval. You're only outputting the interval when that occurs, and evidently it happens on average at least every 50ms.
You can test this theory by outputting interval to serial as soon as you've generated it (i.e. before the if statement). I think you'll find it will flood the serial monitor with a huge range of values.
Fixing the problem should be pretty easy. Just generate your first interval value during setup(). After that, only generate a new random interval value when the old interval has elapsed (i.e. inside the if block). Don't do it every time round the main loop.

I had the same problem (random, milliseconds), and in my case what I needed to make was a toy, able to Blink its eye (LED) in a more human way, with variable intervals, so I used the basic "blink without delay" and tweaked until I got a result I wanted.
This is my first post here so I hope I'm doing it correctly. Here is the code that worked for me:
const int ledPin =  13;      // the number of the LED pin
unsigned long previousMillis = 0;        // will store last time LED was     updated

 long interval = 4000;           // starting interval at which to blink   (milliseconds)

void setup() {
Serial.begin(9600);
// set the digital pin as output:
pinMode(ledPin, OUTPUT);
}

void loop()
{
digitalWrite(ledPin, HIGH);

unsigned long currentMillis = millis();

if(currentMillis - previousMillis >= interval)

{
  // save the last time you blinked the LED
  previousMillis  = currentMillis;
  interval = random((3, 14) * 1000);

Serial.println("Blink");
Serial.println(interval);  // Just so I can confirm if the effect seems natural
digitalWrite(ledPin, LOW);
delay(250);
digitalWrite(ledPin, HIGH);
 }
}


text:
How can I speed up reading of an SD card?
I am working on a project using an Arduino as a web server.
Code:
webFile = SD.open("index.htm");
if (webFile) {
  while(webFile.available()) {
    client.write(webFile.read());
  }
webFile.close();

This sends data line by line, leading to a long time to load the webpage. Is there a faster way to load this page?

Yes, reading in a full sector at a time and writing in large pieces which a TCP stack can chop into full packets which can be left outstanding awaiting later acks would be preferable - but likely requires more buffer memory than you have.  This is why hanging a network interface on an Arduino is not only an unecessarily costly way to solve a problem,  but also a generally unwise one.

@ChrisStratton plz give me more information about how can do this

Switch to a platform with more memory.  Many of them are substantially cheaper anyway.

Take a look at the libraries produced by www.pjrc.com (teensy)

Well I have two ideas on the SD card side, though neither really seem great to me they could still help you. I read on the Arduino forum that the SD card R/W speeds generally come out to 600kB/s, I'm not really sure why, the Arduino SPI can go up to 8 MB/s and I didn't think there would be that much protocol/data-handling in SD.

Sector R/W - As Chris Stratton said, this is an obvious method, it's probably much faster to do sector reads. You may have to greatly change your code to implement it, but I imagine you'd see performance increase in the end. Apparently there's an unofficial library for it, though it seems to impart some potentially serious limitations.
RAM - This is the second thing that came to mind when thinking about the problem is that you could use external RAM, when not handling network transfers (Idling, should be most of the time) the Arduino transfers data to external SRAM which you add. SPI RAM is most likely the easiest to implement, but not likely to be any faster than an SD card. Parallel RAM is going to be difficult to implement, you'll likely need to write your own class/library, but it could be much faster than SPI RAM or an SD card.

I'm not actually sure if either of these would be any faster, it's all just theory and I hope others will share their thoughts. If you have trouble finding the download link for the SD Card library, it's right here. In that ZIP folder there's a file called SDCARD, just move that folder into your Arduino libraries folder on your computer.

how can get this library ?
i can't found it in google ?
@Unit_One

Adding external RAM to an ATmega is absurdly inefficient.  If you need more memory, use a processor which has that from the start.

When I said RAM, I meant SRAM specifically. Which I did mention. Of course DRAM is practically unusable on Arduino, but SRAM is practical.

Keeping in mind that I do not mean the use of external RAM to supplement the MCU's RAM, which is of course a terrible idea. But only to serve as a buffer for the data in the SD card.

No, adding external SRAM to an ATmega for buffering reads from an sdcard is an absurdly slow and expensive solution to a problem correctly solved by selecting an MCU with sufficient on-board buffer memory (and in the case of this need, on-board or inexpensively added network interface).

maybe you should use SdFat library; a library which is almost the same as the standard SD library, but also it can support Long Filenames.
I did some tests with read and write; it is most of the times > 60% faster!!
https://github.com/greiman/SdFat


text:
How do I replace a burnt atmega328 with a new atmega328(bootloaded) in arduino?
I have an arduino UNO with atmega 328 whose microcontroller got burnt. I bought a new atmega328. I have another working arduino with atmega8. I followed the instructions in http://arduino.cc/en/Tutorial/ArduinoToBreadboard but I got a little confused.
I burnt the bootloader into my new atmega328 using atmega8 arduino as described in the link above. Now, can I replace my old atmega328 with this new bootloaded atmega328 to upload sketches to it? Or should I follow the steps described in the link to upload sketches?

Once the bootloader has been burned to it, the chip can replace the one that is currently on the Arduino board. Simply follow normal DIP removal and insertion procedures to replace it.


text:
How do I replace a burnt atmega328 with a new atmega328(bootloaded) in arduino?
I have an arduino UNO with atmega 328 whose microcontroller got burnt. I bought a new atmega328. I have another working arduino with atmega8. I followed the instructions in http://arduino.cc/en/Tutorial/ArduinoToBreadboard but I got a little confused.
I burnt the bootloader into my new atmega328 using atmega8 arduino as described in the link above. Now, can I replace my old atmega328 with this new bootloaded atmega328 to upload sketches to it? Or should I follow the steps described in the link to upload sketches?

Once the bootloader has been burned to it, the chip can replace the one that is currently on the Arduino board. Simply follow normal DIP removal and insertion procedures to replace it.

You can use the 328p as usual (for an Arduino), once the bootloader is burned.
Background: You just used your Atmega8 as an ISP (In-System-Programmer) to get a bootloader onto your new 328p. The bootloader now enables the 328p to be programmed via serial port.

Yes - though the baud rate configured for the board chosen in the IDE  will need to match what the bootloader expects, which might or might not be the same as the original one.


text:
RN-52 - Bluetooth Audio Module two way communication with Android
Im planning a project that involves sending data from a door phone to an android phone and vice versa using the RN-52 chip from sparkfun. Because of the nature of the project it is necessary to be able to send and receive audio simultaneously, is this possible? I've done some googling and it seems to me impossible because of sink/source, since you cant have both at the same time (using A2DP).
Can this be done with another profile I don't know of?
Even if that were to work, can the chip handle two way communication?
Is this project feasible with BT, or should I be looking at WIFI-communication instead?
Ultimately it would be nice to be able to use BT because of costs.
Edit: Can I use bluetooth hands free profile? This profile is (AFAIK) intended to send audio to and from a phone (amongst other functionality). The chip does support HFP/HSP, can this work?

Regardless of channel issues, full duplex audio is likely to cause feedback issues which are tricky to eliminate.

Well, I guess I could make it half-duplex though. I.e you hold a button on the phone to talk, and is not able to press it when someone is talking in the other end.


text:
Using 555 as an external Watchdog
I would like to use a 555 circuit as an external watchdog for my Arduino project. The project is a cellular tracker that goes to sleep for an hour, wakes up and does some measurements, uploads them and then goes to sleep again. The 555 should take care that the active period does not take too long because the systems hangs, and in that case trigger a reset. My first thought was to power the 555 circuit with a PIN of the Arduino so that it only goes on when the system is awake and is turned off while sleeping.
But this does not work as the reset line has to stay high even while sleeping and if i turn the 555 off reset would also go low. Could a Mosfet help? Any other ideas?

Why can't you use the internal watchdog for this?

Because it is not reliable and way too fast. I am running on reduced clock speed which means maximum watchdog cycle would be 3-4seconds. GSM communication takes time...

GSM communication shouldn't block the arduino code. You should at least be able to work around any blocking code that is in the library. Something like while(!Serial.available() && millis()-starttime<10000){wdt_reset()}.

Will give it a try - but nevertheless - would feel saver with an external fallback, still. Any ideas on this?

ok guys - found the answer: this post here at electronics-stackexchange gave the right hint: Watch-Dog Timer. And my gut feeling was right as well - i simply use a NPN-Mosfet that is being triggered by an Arduino-PIN (which easily can be done while sleeping as well as sleeping means waking up every 8seconds anyway) that connects the capacitor to ground and therefore discharges the guy. Awesome.
This solution can be used as a real fallback in case of whatever happens, while operating the system with built in watchdog-functions while everything is ok.


text:
Arduino Uno + Ethernet shield stability question
i have a climate control software which reports data back through the web browser.  Everything seems to be working however I am running into an issue where
1 - after a bit it seems the page doesnt refresh completely and instead displays a long list of the same webpage, so i have like 30 pages of the same thing as you scroll down
2 - when i woke up in the morning i could not load the page at all
What i am wondering is how can i get this to be stable and reliable so that the climate control software / sensors can run non-stop.
Currently as long as i dont use the ethernet shield reporting everything else seems to work great, i leave it on for 12 -20 hours and it still runs, but not with the ethernet reporting.
any help wold be apreciated thanks.
this is my code:
//Define Start
#define NOTE_D2  73 //sound note for beep
#define DHTPIN 2
#define DHTTYPE DHT22
#define DHT2PIN 3
#define DHTTYPE2 DHT22
#define MAGENTA //Define a color for screen
#define sclk 8 //screen pin
#define mosi 5 //screen pin
#define cs   6 //screen pin
#define dc   7 //screen pin
#define rst  rstpin  // you can also connect this to the Arduino reset
#define ANALOG_IN 0 // for cds light sensor

//Define End
//Include start
#include <DHT.h>//dht sensor library
#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>//needed to run screen
#include <Wire.h>
#include "RTClib.h"
#include <Ethernet.h>
//Include end
//declare start
DHT dht2(DHT2PIN, DHTTYPE2);
DHT dht(DHTPIN, DHTTYPE);
int powerswitch1 = A0;
int powerswitch2 = A1;
const int ledPin =  A2;
const int ledPin2 =  A3;
Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, mosi, sclk);
char* myString = { "OFF" };//relay1 on / off status
char* myString2 = { "OFF" };//relay2 on / off status
const int chipSelect = 4;
RTC_DS1307 RTC;
byte mac[] = {
  0x90, 0xA2, 0xDA, 0x00, 0x23, 0x36 }; //MAC address found on the back of your ethernet shield.
IPAddress ip(192,168,1,40);
//decalare end
EthernetServer server(80);

void setup() {
pinMode(ledPin, OUTPUT);
pinMode(ledPin2, OUTPUT);
tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab
tft.fillScreen(ST7735_RED);//make screen red
  pinMode(powerswitch1, OUTPUT);
  pinMode(powerswitch2, OUTPUT);
  Serial.begin(9600);
  Wire.begin();
  RTC.begin();
if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
 //   RTC.adjust(DateTime(__DATE__, __TIME__));
  }

// get time to display "sensor up time"
  uint16_t time = millis();
 // tft.fillScreen(ST7735_BLACK); //black screen
  time = millis() - time;

Serial.println(time, DEC);

  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}
void loop(){
  //Tone Start
    tone(9, NOTE_D2);
    delay(65);
    noTone(9);
//Tone End

//clock start
  DateTime now = RTC.now();

    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();

 //hour conversion to 12 hour start
   int x;
   int timeresult;
   x = (now.hour());
   if (x > 12) {
   timeresult = x - 12;
   }
   else
   {
    timeresult = x;
   }
   Serial.println(timeresult);
    //hour conversion to 24 hour start
//clock end
//sensor 1 start
    //Serial.println("read DHT22 #1");
    float h = dht.readHumidity();
    float t = dht.readTemperature();
    float f = dht.readTemperature(true);
    //sensor 1 end
    //sensor 2 start
    //Serial.println("read DHT22 #2");
    float h2 = dht2.readHumidity();
    float t2 = dht2.readTemperature();
    float f2 = dht2.readTemperature(true);
    //sensor 2 end
    //temp average begin
    //Serial.println("average calculation");
    float havg = (h + h2) / 2;
    float favg = (f + f2) / 2;
    float tavg = (t + t2) / 2;
    //temp average end

//Relay 1 Start
    if (h < 42) //top threshold
    {
        if (h < 39) //bottom threshhold
        {
            digitalWrite(powerswitch1, HIGH);
            // Turn the Powertail on
            Serial.println("Switch ON");
digitalWrite(ledPin, HIGH);
            myString = "ON";
        }

    }
    else
    {
                myString = "OFF";
        digitalWrite(powerswitch1, LOW);    // turn the Powertail off
digitalWrite(ledPin, LOW);
        Serial.println("Switch OFF");

    }
//Relay 1 End
//Relay 2 Start
    if (f < 60) //top threshold
    {
        if (h < 60) //bottom threshhold
        {
            digitalWrite(powerswitch2, HIGH);
            // Turn the Powertail on
            Serial.println("Switch ON");
digitalWrite(ledPin2, HIGH);
            myString2 = "ON";
        }

    }
    else
    {
                myString2 = "OFF";
        digitalWrite(powerswitch2, LOW);    // turn the Powertail off
digitalWrite(ledPin2, LOW);
        Serial.println("Switch OFF");

    }
//Relay 2 End
//Screen start

delay(500);

tft.fillRect(20,19,80,140, ST7735_RED);//clear text
//(left wall,top wall px from top,right wall,bottom wall px from top)
tft.drawRect(20,19,80,140, ST7735_RED);//cleartext
//active text
tft.setCursor(35, 20);
tft.setTextSize(2);
tft.setTextColor(ST7735_WHITE);
tft.println(f);
tft.setCursor(35, 40);
tft.setTextSize(2);
tft.setTextColor(ST7735_WHITE);
tft.println(t);
tft.setCursor(35, 60);
tft.setTextSize(2);
tft.setTextColor(ST7735_WHITE);
tft.println(h);
tft.setCursor(25, 120);
tft.setTextSize(2);
tft.setTextColor(ST7735_WHITE);
tft.println(timeresult);
tft.setCursor(50, 120);
tft.setTextSize(2);
tft.setTextColor(ST7735_WHITE);
tft.println(now.minute(), DEC);
tft.setCursor(75, 120);
tft.setTextSize(2);
tft.setTextColor(ST7735_WHITE);
tft.println(now.second(), DEC);

//static text

tft.setCursor(105, 20);
tft.setTextSize(2);
tft.setTextColor(ST7735_WHITE);
tft.println("F");
tft.setCursor(105, 40);
tft.setTextSize(2);
tft.setTextColor(ST7735_WHITE);
tft.println("C");
tft.setCursor(105, 60);
tft.setTextSize(2);
tft.setTextColor(ST7735_WHITE);
tft.println("%");
tft.setCursor(52, 80);
tft.setTextSize(2);
tft.setTextColor(ST7735_WHITE);
tft.println(myString);
tft.setCursor(105, 80);
tft.setTextSize(2);
tft.setTextColor(ST7735_WHITE);
tft.println("H");
tft.setCursor(52, 100);
tft.setTextSize(2);
tft.setTextColor(ST7735_WHITE);
tft.println(myString2);
tft.setCursor(105, 100);
tft.setTextSize(2);
tft.setTextColor(ST7735_WHITE);
tft.println("T");
tft.setCursor(52, 140);
tft.setTextSize(2);
tft.setTextColor(ST7735_WHITE);
tft.println(millis() / 1000);
tft.setCursor(105, 140);
tft.setTextSize(2);
tft.setTextColor(ST7735_WHITE);
tft.println("-");

tft.print(millis() / 1000);
//Screen end

 EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
   client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("");
          client.println("");
          /////CSS
            client.println("");
          ///CSS

          client.println("
");
          client.println(""); //how to change color adruino version

            client.println("
");
            client.println("<text4>");
            client.print("Sensor 1");
            client.println("</text4>");
            client.println("
");
            client.println("<text1>");
            client.print(h);
            client.print(" %\t");
            client.println("</text1>");
            client.println("
");
            client.println("<text2>");
            client.print(f);
            client.println(" °");
            client.println("F");
            client.println("</text2>");
            client.println("
");
            client.println("<text2>");
            client.print(t);
            client.println(" °");
            client.println("C");
            client.println("</text2>");
            client.println("
");
            client.println("
");
            client.println("
");
            client.println("<text4>");
            client.print("Sensor 2");
            client.println("</text4>");
            client.println("
");
            client.println("<text1>");
            client.print(h2);
            client.print(" %\t");
            client.println("</text1>");
            client.println("
");
            client.println("<text2>");
            client.print(f2);
            client.println(" °");
            client.println("F");
            client.println("</text2>");
            client.println("
");
            client.println("<text2>");
            client.print(t);
            client.println(" °");
            client.println("C");
            client.println("</text2>");
            client.println("
");
            client.println("
");
            client.println("
");
            client.println("<text5>");
            client.print("Humidifier: ");
            client.println("</text5>");
            client.println("<humidifier>");
            client.print(myString);
            client.println("</humidifier>");
            client.println("<text5>");
            client.print("Heater: ");
            client.println("</text5>");
            client.println("<heater>");
            client.print(myString2);
            client.println("</heater>");
            client.println("<text6>");
            client.println("
");
            client.print(millis() / 1000);
            client.println("</text6>");
            client.println("<text6>");
            client.print(timeresult);
            client.print(":");
            client.print(now.minute(), DEC);
            client.print(":");
            client.print(now.second(), DEC);
            client.println("</text6>");
             client.println("
");
              client.println("
");
          client.println("");
          client.println("");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disonnected");
  }

delay(3000);

}

I have had to program in a reset for the network connection on quite a few of my ethernet projects.  I am not entirely sure the cause, but adding a close connection; open connection to run every x minutes seems to have helped prevent both the duplicating content and the timeout issues.

I would go for a memory issue - try to rewrite your code in a way that consumes less memory, the easiest first step is to avoid any Serial.printl("String"); and replace that with Serial.println(F("String"));. But in general you are using a lot of String objects which should be avoided if possible (try to use char() instead).
To check memory consumption of your sketch you can use a function like this and log the values from specific points in the code:
int freeRam () {
extern int __heap_start, *__brkval;
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}

I used to encounter weird issues, e.g. starting a new instance of a program with Arduino Yun. The issue in the end was power supply, a large capacitor before the voltage regulator has solved the problem. What do you use for power supply?

Hey, i just started this arduino stuff like 3 weeks ago and have literally 0 knowledge of terminology or anything what so ever.  I know this power issue is something of concern. Currently it has been powered directly from USB, now starting today, (a few hours after this post) i am using the ac power adapter directly to the arduino Uno.  I will leave it on till tomorrow to see what happens.  I dont really understand much about the voltage regulation or anything like that. Im learning though. :P

I have noticed lower than 5V voltages when powering Arduino from the computer's USB. Better results were with ordinary mobile phone chargers/power adapters (USB), but the most stable power supply was with a dedicated AC/DC transformer/rectifier to 9V and then reduced to 5V with a linear regulator (LM7805 or similar + capacitors). The last version has the highest losses, needs additional circuit, but works in rather harsh conditions. Might be overkill for home, if ordinary AC power adapter works, stick to it. And as Stephan pointed out, checking free memory is your friend, too.

Thanks for the info. So far its been 2+ days and it has been running non stop with AC power brick, i am going to give it 3 days until i consider it stable.


text:
How to remove Adafruit Pro Trinket bootloader flashing startup sequence
From what I understand, the Pro Trinket has "Optiboot" which allows it to detect which boot loader you are trying to use, one for USB and one for FTDI. When it's in this "bootloader state" the red LED on pin 13 buses for 10 seconds before it starts to run the program I've programmed.
Can I remove this Optiboot functionality? Would that entail permanently choosing a single boot loader/interface?
One problem I have with this is that along with the LED on 13, it causes the LED strip I have attached to pins 9, 10, 11 to blink. I would also really like to not have to wait 10 seconds to start running code.
Here's the page on Adafruit's site that talks about the bootloader[s] on the Pro Trinket.
Thanks!

If you have the source code and a programmer and the drive to dive into detail, then yes, you can presumably do that.

Have you asked on the Adafruit forums? They probably can answer better than anyone.

Only pin 13 will blink. Pins 9-11 will be floating. Maybe you should add some pull-down resistors to the FETs connected to the led strip (which is a good idea even if you do change the bootloader).

You could take the Pro Trinket bootloader source code and tweak it to your needs, burn it, and make sure you have patience and debugging skills.
From the author's (Frank Zhao) source code, it seems that this is the 10 seconds loop you are referring to, located in main.c, line #456:
if ( ((usbHasRxed != 0) && (timeout > USBBOOTLOADER_TIMEOUT)

The USBBOOTLOADER_TIMEOUT variable which is defined to 10 at the top of that file, line #70:
#define USBBOOTLOADER_TIMEOUT 10

and is progressed after 'roughly' 1 second, at line #496:
// roughly 1 second
#if (F_CPU == 12000000)
    if (t1ovf > 183) {
    #elif (F_CPU == 16000000)
    if (t1ovf > 244) {
    #endif
        t1ovf = 0;
        timeout++;
    }

Not the regular trinket. PRO trinket bootloader source code.

Just program the pro trinket using ISP. (not using the USB connector). For example by using an Arduino as a ISP-programmer.
If you are brave, you could change the bootloader to only run when the reset button was pressed, and not at power-up. I've done exactly that for the regular trinket (see my github)

I'd be careful to remove that section because these ten seconds are not only where the board detects which bootloader to use but also when it is accepting a new sketch at all. So if you'd get rid of that, you wouldn't be able to upload new sketches anymore i guess.

That's more of a comment than an actual answer. You could tweak the timing so it fits better, woulnd't be a problem. IF you can change the bootloader you should also be able to undo it (same tools/same changes). I'm not sure if the bootloader does the blinking, you could also easily disable that in the bootloader. But yeah, I would test it before shipping it to customers ;D

It is actually much simpler than the other answers suggest. There is no need to remove/overwrite the bootloader. You can just disable the bootloader by setting the appropriate fuse bit.
In order to do so, you need an ISP programmer. As you might know, you'll loose the ability to upload code though USB/FTDI. But you can restore that ability at any time, just by resetting the appropriate fuse bit to its original value.
Step 1: Connect your trinket through an ISP programmer
There is no ISP header on the trinket, but you can easily build one or just use jumper wires to connect the individual pins directly to the programmer. Pinout can be found at learn.adafruit.com. You need to connect MISO, MOSI, SCK, RST, VCC and GND.
Step 2: Determine current fuse configuration
avrdude -c usbtiny -p m328p

If you're using a different programmer than the USBTinyISP, replace usbtiny with the appropriate identifier. List possible values by specifying a bogus identifier, eg. avrdude -c foo.
Among some other things, avrdude should return a line containing the current fuse values. It should look similar to the following:

avrdude: safemode: Fuses OK (E:FD, H:D0, L:FF)

We're interested in the high fuse (H:D0). D0 indicates that the bootloader is enabled. Actually, any even number means the bootloader is enabled.
Step 3: Calculate new fuse value
We want to set the BOOTRST bit of the high fuse. It is the least significant bit of the fuse, which equals the number 1. So all we need to do is increment the value by 1.
In the example, the new fuse value is D1.
If you are unsure how to calculate the fuse value, you can use the Fuse Calculator. Choose ATMega328P as your device, enter the fuse values as reported by avrdude at the very bottom under "Current settings", then click apply. Uncheck BOOTRST in the "Manual fuse bits configuration" section, then you will see the new fuse value in the bottom section, where you entered the original value.
Step 4: Program new fuse value
avrdude -c usbtiny -p m328p -U hfuse:w:0xd1:m

Again, replace usbtiny with the identifier of your programmer. If you calculated a different value than D1, replace 0xd1 with your approriate value. However, if your original value for the high fuse was D0, then your new value is D1.
Done!

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


text:
Smaller version of the Mega
I'm currently working on a Arduino Mega (GPS + IMU + SD card logging + BT). I need the Mega for extra memory and serial port.
I would like to transition to something with a smaller form factor now. I need help with suggestions for a smaller form factor board/version of Mega.
Any suggestions?
I can't really find anything.
The only small size yet meeting requirements (in terms of memory) option seems to be a Microduino -
but I'm not whether all the libraries (SDfat etc.) will work on this.

It should be possible to make something smaller with an ATmega2560, but realistically most of that market is claimed by little ARM cortex boards which are yet more capable - Teensy for example.

@O.K. Microduino appears to be a company, not a single product. What board did you go with? Also, you link appears to be broken.

@Cerin we eventually used a Teensy 3.2... btw this post was 2+ years old, so Microduino may have changed the product links

@O.K. The Teensy does indeed look exactly like what you described. I was looking for something like that myself. Thanks.

The ATmega1284P provides 128kB of flash, 16kB of SRAM, 4kB of EEPROM, and 2 USARTs in a 40/44/49-pin package. Mighty 1284P provides Arduino support for the '1284P.
There aren't too many actual boards that feature it, but it can be used very easily on a breadboard or custom PCB with a programmer.

thanks Ignacio. I think I will go for the Microduino (link in my ques), which as mentioned by Nathan uses the ATmega1284 you mentioned.

The link uses the same chip that Ignacio recommended.  The libraries will need some minor edits, but many of the standard ones do have a 1284P fork.  It is mostly just redoing pin assignments, or adding the 1284P to the board definitions.  I am working on a similar project and have gotten the 1284P to work with SDfat, a bunch of standard GPS libraries, and TinyGPS++ .

Thanks Nathan, good to know someone has tried using 1284 with the existing libs. I want to avoid any major/complex work in porting libs; your comment is helpful here. Also, if you don't mind, can you share exactly which 1284 board you are using?

I am using a breadboard version documented here: https://maniacbug.wordpress.com/2011/11/27/arduino-on-atmega1284p-4/  The included zip file has some already adapted libraries but adapting the others wasn't too hard.  Basically you just have to search 1284P and library for the major ones.

I like Jack Christensen's Might Mini design so much I sell it assembled on eBay, username hexinverter. That 2K of RAM in Nanos and the like is just painful. Anyone interested in making their own can find the design and BOM here: https://github.com/JChristensen/mini1284 and a boards.txt for 1.0.5/6 here: https://github.com/JChristensen/mighty-1284p ... all derived from and mentioned in the ManiacBug post and discussed at arduino.cc forums.

Look for "Mega2560-CORE" on ebay.
Some information:
http://www.inhaos.com/product_info.php?products_id=88


text:
Freeduino avrdude stk500_getsync() not in sync
I have a Freeduino USB 1.1 board with atmega 8l-8pu microcontroller on it. When I try to upload program, it shows error:
avrdude stk500_getsync() not in sync: resp 0x00

I have tried reset and the red led blinks which I think suggest bootloader is working fine.
On Arduino IDE, I have set Arduino Uno and correct port which is shown in device manager.
One weird problem that I noticed is that no matter which USB port I connect to, it says COM9 on device manager. Is that something to look into?
Any ideas?

Do you have anything plugged into the RX/TX pins? That has tripped me up a few times.

@Nathan nope....

There could be many reasons for the problem you have got.
1) Try to program your Board with any other device you have got. If you are trying to program it with PC try to do it using Laptop.
2) Plug your board to any other port. Then Right Click My Computer and Select Manage--> Device Manager and find the port where your Freeduino is connected. Then Select that port in  your Arduino IDE.
Solution 1 worked for me!


text:
Proxy and Authentication in Arduino Uno
I am using the Ethernet Shield on top of the Arduino Uno. I want to use this setup to access  webpages. But I am unable to access because the ethernet connection is present in a University which requires a proxy server with authentication. I am unsure of what extra code to include so as to get past the proxy which requires authentication.
Can anyone help in solving this problem?

Any semi-reputable authentication mechanism would be performed over HTTPS, which is an encrypted connection - this would require an SSL library to be installed for use along with the normal Ethernet and HTTP libraries, and I don't believe the arduino really has the processing capability to make connections like this feasible.
Unfortunately this is one of those cases where a more sophisticated device may be more appropriate.... (like a Beaglebone Black, or a Raspberry Pi.)
It is possible that you could add headers into the HTTP connection packet to either bypass proxy authentication, or include a cookie that has already undergone authentication and is cached by the proxy. How you do this is almost entirely down to how your proxy works. You may also find this doesn't work unless you spoof the MAC address of your device to match that of the machine used to fulfill the authentication.
It is entirely possible to set up a system to share the internet connection (act as a router) between two adapters - so you end up making connection requests to webpages, but the authenticated proxy only sees requests coming from your system (this is kind of how mobile phone tethering works, when you access the internet on a laptop or tablet through your smartphone's internet connection).
If the proxy supports unencrypted authentication, it may be possible to pass through username/password details in plaintext (or Base64 encoded) in Basic access authentication, which is what HTTP (and HTTPS) often uses - but this is unsafe on HTTP and is VERY unsafe when any part of the connection is publicly transmitted - like when using wifi, for example. (Doesn't matter if the wifi is encrypted - as on a university network, everyone who can connect to the wifi can see your wifi traffic (typically).)
If you're going to be using your own personal university login credentials to do this, make sure you always use ethernet to do it, not wifi, and if possible, obtain a second username/password explicitly for connecting this way - you don't want to have to hard-code your own personal username and password into source code that you have to give to anyone.
Here's a few links to get you started:

HTTP Spec: Proxy-Authorization and Authorization headers
How to use authentication in an HTTP Proxy?
Wikipedia: X-Forwarded-For


text:
Works on Uno but not on Yun
I found some code that works to transmit the required signal to an RX-2B RC receiver, the code works great from my Uno but when I tried to run it from my Yún nothing happens.
The code has definitely uploaded as I tested with an LED and the pin is getting a HIGH voltage written to it.
Does anyone have any idea what the issue might be? Code below.
Thanks.
/**
* Control Realtek RX2 (RX2 -G) RC Receiver with Arduino
*
* @author Mircea Diaconescu, Octomber 28, 2013
* @source https://github.com/dimircea/
* GPL v3 License
*
 * Many cheap RC toys are based on TX2 / RX2 transmitter / receiver ICs.
 * This Arduino sketch allows to replace the TX2 based Remote Control with Arduino.
 * Just one single pin is used from the Arduino board.
 *
 * Connect Arduino pin 10 to the solder point where the toy antenna is connected or         to the toy antenna cable.
 * One can replace pin 10 with other free digital pin available on the Arduino board.
     *
 * TX-2B/RX-2B datasheet: http://www.datasheetarchive.com/dl/Datasheet-    035/DSA0017137.pdf
 */

/** Functions (aka W1) - as defined by the IC datasheet */
#define COMMAND_ENDCODE         4
#define COMMAND_FORWARD        10
#define COMMAND_FORWARD_TURBO  16
#define COMMAND_TURBO          22
#define COMMAND_FORWARD_LEFT   28
#define COMMAND_FORWARD_RIGHT  34
#define COMMAND_BACKWARD       40
#define COMMAND_BACKWARD_RIGHT 46
#define COMMAND_BACKWARD_LEFT  52
#define COMMAND_LEFT           58
#define COMMAND_RIGHT          64

//output pins
#define ANTENNA_PIN 9

/** Initialize the Arduino data and pin */
void setup() {
 pinMode( ANTENNA_PIN, OUTPUT);
}

/** Loop code */
void loop() {
 // add here your commands to control the RX2 module...
 // for test purposes, here a continuous forward command is sent

 sendCommand( COMMAND_FORWARD);

}

/** Send command to the RX2 IC */
void sendCommand( int command) {
 int w1 = 0, w2 = 0;

 /** start code sequence 4 x W2, ~625Hz, Duty Cycle 75% */
 for ( w2 = 0; w2 < 4; w2++) {
   digitalWrite( ANTENNA_PIN, HIGH);
   delayMicroseconds( 1200);
   digitalWrite( ANTENNA_PIN, LOW);
   delayMicroseconds( 400);
  }

 /** function code sequence, n x W1, ~1.25KHz, Duty Cycle 50% */
 for ( w1 = 0; w1 < command; w1++) {
   digitalWrite( ANTENNA_PIN, HIGH);
   delayMicroseconds( 400);
   digitalWrite( ANTENNA_PIN, LOW);
   delayMicroseconds( 400);
 }
}

Note that delayMicroseconds() based timing is only consistent if you disable interrupts, though that would probably lead to intermittent rather than complete failure.  It's also not particularly accurate, as the time of intervening operations must be taken into account, too.  Your data rate is slow enough that you might be able to use a sound card as an oscilloscope to debug the timing.

Thanks for the info Chris, I will disable interrupts and see if it makes a difference. There is other code here link which does a similar job but again doesn't work on the Yun, only the Uno and another variant which I haven't had a chance to try yet link

Try the sound card, probing through a .1 - 1uF capacitor, starting with the uno.  It will be educational if nothing else.

Indeed it would, any resources?

A Yun is like a Leonardo with a CPU running GNU/Linux at its side. If your sketch works with a Leonardo, it's likely to work with a Yun.
Uno has a different MCU and thus not every sketch will just work, especially those using the hardware serial. You'll have to convert them.

As this bears no relation to the operations performed by the posted code it is at most a comment.  It is nowhere near being an answer.


text:
Arduino Uno + Wifi Shield + PS2 Keyboard + LCD Display
I'm new in the Arduino Community and I'm facing a problem when I try to use a PS2 Keyboard and an LCD Display (16x2) on an Arduino Uno with a Wifi shield.
I would like to write something with the keyboard and display it in the LCD before sending it to a webservice.
Here is my problem:

When I use the keyboard and the display on my Arduino WITHOUT the wifi shield --> All is OK. I can write on the display the key that has been pressed.
When I use the keyboard and the display on my Arduino WITH the wifi shield --> All is OK until I write something on the display. As soon as I write on the display with the function lcd.print(), the keyboard does not work anymore (it detect the character '2' every time I press a key).

It's very surprisingly because if I dont use lcd.print(), the keybord works without any problem.
Here is a part of my code:
#include <LiquidCrystal.h>
#include <PS2Keyboard.h>

LiquidCrystal lcd(12, 11, 2, 5, 6, 8);
PS2Keyboard keyboard;

const int DataPin = 9;
const int IRQpin = 3;

void setup(){
  keyboard.begin(DataPin, IRQpin);
  lcd.begin(16, 2);
}

void loop(){
  checkKeyboard();
}

void checkKeyboard(){
  if (keyboard.available()) {

    char c = keyboard.read();

    // check for some of the special keys
    if (c == PS2_ENTER) {
      Serial.println();
    } else if (c == PS2_TAB) {
      Serial.print("[Tab]");
    } else if (c == PS2_ESC) {
      Serial.print("[ESC]");
    } else if (c == PS2_PAGEDOWN) {
      Serial.print("[PgDn]");
    } else if (c == PS2_PAGEUP) {
      Serial.print("[PgUp]");
    } else if (c == PS2_LEFTARROW) {
      Serial.print("[Left]");
    } else if (c == PS2_RIGHTARROW) {
      Serial.print("[Right]");
    } else if (c == PS2_UPARROW) {
      Serial.print("[Up]");
    } else if (c == PS2_DOWNARROW) {
      Serial.print("[Down]");
    } else if (c == PS2_DELETE) {
      Serial.print("[Del]");
    } else {
      Serial.print(c);
      displayText(c);
    }
  }
}

void displayText(char c){
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Pressed key:");
  lcd.setCursor(0,1);
  lcd.print(c);
}

Does somebody know how to solve this problem?
Thank you very much in advance :)
Edit: Here are the pins that I use on the board :

Arduino pin 2 -> LCD pin 11
Arduino pin 5 -> LCD pin 12
Arduino pin 6 -> LCD pin 13
Arduino pin 8 -> LCD pin 14
Arduino pin 11 -> LCD pin 6
Arduino pin 12 -> LCD pin 4
Arduino pin 3 -> Keyboard IRQ
Arduino pin 9 -> Keyboard Data

As you say, I can't use pins 10, 11, 12, 13 because they are used for the SPI.
-> So, I tried to use the pins 4 and 7 instead of 11 and 12.
The problem is that the pin 7 is used by the Wifi shield (Handshake) and I have no other free digital pin.
-> So, I tried to use an analog pin instead of the pin 7 and ..... it works very well.
Here is my final solution :

Arduino Pin 2 -> LCD Pin 4 (RS)
Arduino Pin 3 -> Keyboard IRQ
Arduino Pin 4 -> LCD Pin 11 (D4)
Arduino Pin 5 -> LCD Pin 12 (D5)
Arduino Pin 6 -> LCD Pin 13 (D6)
Arduino Pin 7 ->
Arduino Pin 8 -> LCD Pin 14 (D7)
Arduino Pin 9 -> Keyboard Data
Arduino Pin 10 ->
Arduino Pin 11 ->
Arduino Pin 12 ->
Arduino Pin 13 ->
Arduino Pin 14 (= Analog 1) -> LCD Pin 6 (E)

Sorry I do not have enough reputation to place a comment.
@Valentin from the link, you provided, to the wifi shield it states that it uses pins 11 ,12 and 13 on the UNO which will give you a conflict on pins 11 and 12 with the LCD. Not sure why that manifests as an apparent keyboard error though:
From the linked page:

Arduino communicates with both the Wifi shield's processor and SD card using the SPI bus (through the ICSP header). This is on digital pins 11, 12, and 13 on the Uno and pins 50, >51, and 52 on the Mega. On both boards, pin 10 is used to select the HDG204 and pin 4 for >the SD card. These pins cannot be used for general I/O. On the Mega, the hardware SS pin, >53, is not used to select either the HDG204 or the SD card, but it must be kept as an output or the SPI interface won't work.

Again sorry this is not a full answer but thought it may help.

You must verify which pins the wifi shield is using and see if they aren't used also by the LCD.
Can you provide further details on the wifi shield ?

I put the keyboard on the pins 3 (IRQ) and 9 (Data). The LCD use the pins 12, 11, 2, 5, 6 and 8. I know the Wifi shield use some pins. If I correctly read the documentation (http://arduino.cc/en/Main/ArduinoWiFiShield), the pins 4, 7 and 10 are reserved for the Wifi shield.


text:
Arduino Yun, pass int data true REST
Would it be possible to instead of passing a state via a REST browser:
digital/13/1

to set an int value? For example, if in the sketch if I would name an int: 2, could I set this to 48 via REST?
If so, how?

Just to be perfectly clear, it is illegal in C++ to have a variable name start with (or be) a number.

Check out the TemperatureWebPanel example: you'll see that you can make your own REST APIs and pass any values your sketch can handle.


text:
Arduino board not recognized by Linux (dmesg, lsusb, etc.)
I just received my first Arduino board which is essentially a Leonardo (ATmega32U4) customized to include a NFC reader (PN532).
When I plug it in, the PWR LED comes on steady, the D13 LED flashes a few times, and then the STA LED blinks once and only the PWR LED is left on. I can upload a basic sketch to the correct Serial Port, but the Serial Monitor is always empty.
I have noticed that, when uploading the sketch, the RX/TX LEDs stay off (which I thought was a sign of uploading/downloading data). I figured this was the root of my issue so I tried to look into it further. Running lsusb does not find the device and dmesg does not show any information when (un)plugging the device.
I also tried on a Windows install, but couldn't install the Leonardo drivers since Device Manager wouldn't register any unknown USB/Arduino devices.
Do you think my board is dead on arrival or am I doing something wrong?

Update:
I just uploaded the Blink tutorial sketch and it uploaded "successfully" but I noticed no differences. Please note that I don't have an external LED attached, but am looking at the board's LED on pin 13. This pin already flashes a few times (as mentioned above) on a reset, so I modified the delay times and still noticed no change.

I am uploading using board Leonardo, as recommended for my hardware, and the serial port /dev/ttyS0. I thought this was the right port because I remember not seeing it at first, but on second thought I had a permission issue at first (which is now resolved) causing me to not see the port.
So it looks like my board is not detected by my computer and I'm successfully uploading sketches to a meaningless port. Any troubleshooting options for me? I've tried different USB ports and am, as of recently, plugging my board into external power (9V). The only thing I can think of that on my end is that I'm using a Y-cable for my USB connection (I have a normal Mini-USB coming tomorrow via Amazon) since it is all I had. I can also confirm that this USB connection does power the board when plugged in.

Something is inconsistent in your description - either the board is recognized, or else you cannot upload to it.

I'll say again, something is inconsistent in your report, as you cannot upload to a USB device which is not detected by the operating system.  There's something you aren't accurately reporting, and it is key to solving your issue.  Perhaps you are mistaken in thinking you managed to upload something?  To what serial device node did you allegedly upload?

Further to that, can you upload a demo such as 'blink' & have it flash an LED at you to confirm it's taken the upload?

@chrisStratton -- thanks for forcing me to look at this again, this is my first time really messing with hardware. Please see my update.

I'd like to ping @MarkWilliams also, since he pointed me to the Blink tutorial (which I thought I needed an external LED for).

/dev/ttyS0 is a serial port - not a serial-via-USB - and so will be looking for something plugged into a 9-pin D socket (or 25-pin; if you even have one at all) - this may well explain things, although there is meant to be 2-way comms. I'd definitely check the cable as Arduino boards lighting up & flashing is a good sign! Do you not have a printer cable or something you can 'borrow'?

I have a camera card at my girlfriend's that is Mini-USB, but none in the office here (surprisingly). I'll just wait until tomorrow and get back to you guys unless there are any other ideas. Glad I was on the right track buying a cord to troubleshoot :)

Just to confirm, would I be looking for a /dev/ttyUSB0 or /dev/ttyACM0 instead of /dev/ttyS0? Either way, I believe it should show up in my kernel log if I have a good connection..

A Y cable should work (if it still works on its original disk drive) if you plug in the end that actually has data wires.

@ChrisStratton it's not a normal split Y-cable, the other end is a female USB-A (see image)..didn't know what else to call it

@MarkWilliams -- it was the USB cable only sending power, not data. Either of you can submit an answer for points (thanks for the help)..if not, I'll write my own answer later.

So, to summarise the comments trail; the blinking lights at power-up are the normal boot sequence for the Leonardo,  indicating the processor is good, and that power is reaching the board; the device seen should be /dev/ttyACM0 or some other number; dmesg wasn't recording a plug-in event as the cable was not good.
We still don't quite know why the IDE thought it had sent a program to /dev/ttyS0, but presumably the level of interaction is much less (ie, none) via RS232 serial? Which explains why it said it had uploaded a test program when, in fact, it hadn't!
And replacing the USB cable has solved the problem - excellent news!


text:
Concatenate two non constant char arrays in Arduino
I have two non constant char arrays. One is "buff" and other is "buffa". I get values in buffa via rf transmitter of other Arduino and I want to append those data to the data inside of buff. Then I will send all data to other Arduino. So I don't want to send two different char arrays. I want to send them all at once as just one array.
I TRIED SPRINTF BUT IT DOESNT WORK.
char buffa[144];
    char buff[1000];

void loop() {

  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;

  sprintf(buff,"<status>\n");

    if (vw_get_message(buf, &buflen)) { // check to see if anything has been received
      int i;
      for (i = 0; i < buflen; i++) {
        buffa[i] = (char) buf[i];  // the received data is stored in buffer

      }
    }

  distance1 = getDistance(initPin1, echoPin1);
  sendData(3, distance1);

  sprintf(buff, "%s", buffa);

delay(5000);
 const char *msg0 = buff;

 vw_send((uint8_t *)msg0, strlen(msg0)); // Send control character
 vw_wait_tx();

 Serial.print(msg0);

}

Assuming the data in buffa is a c-style string (i.e. null-terminated), replace
sprintf(buff, "%s", buffa);

with
strcat( buff, buffa );


text:
Variable current switch by human touch
Two goals:

Make an LED turn on when a person touches two conductive pads (e.g. two square of aluminum foil)
Make the RGB LED change color depending on how hard the pads are squeezed. I will figure out the color algorithm later. For now I just need to be able to sense variable conductivity/capacitance/current (one of those?).

I have an Arduino LilyPad. I know this can be done because I've seen it before (just don't remember the code or circuit). Example image:

I know the human body is conductive, so I'm not quite sure why the LED won't go on when I contact the conductive pads. My only hypothesis is that the resistance is too high, but that must mean some current is going through, no?
Thanks.

I am going to make this answer as simple as I can, the body is not THAT conductive, you gotta use something like a touch sensor.

+1; most touch switches use capacitance; a firmer press will put more of your finger against the pad, the increase in area increases the capacitance (& slows the discharge time, which you measure)

I'd downvote this but I can't yet on this SE.  He's asking how to create this.  Not asking how conductive the body is, we all know there are touch sensors that do work.  What the OP wants to know is how to make this work, not how conductive the body is, followed by "use a touch sensor" which is what he's asking how to do to begin with (most likely home built)... he just didn't use those words.

@Tyson Yes, right. I need a capacitance sensor, so how. It looks like there's an Arduino library for this, and I see an Instructable for using it. I don't have a standalone resistor, though—just LEDs with resistors built in. How can I work around that?

Okay; to start with, the Arduino Playground has a how-to guide, the components are commonplace - either recycle a high-resistance resistor from junk or buy one from eg Maplin at 38p.
This works as follows:
You charge the capacitor with one output, through a resistor. This charges the capacitor in RxC seconds - C is very small, typically 10^-11 or so, so a decent sized resistor helps make it slow, in computer terms. Ensure this is held on for long enough to charge fully. You can use one charge pin for many touch sensors.
You then drop the charge pin to 0, and see how fast the sense voltage drops; this will be affected by fingers etc, giving a time value reflecting the degree of contact; normally this is used as a threshold on/off, but does allow for some pressure sensitivity. You need one R/C/sense-pin per switch.


text:
Arduino and Raspberry Pi - 5V/3.3V I2C
This topic have been covered in various places, but I still think it hasn't been thoroughly explained anywhere. Doing google search on connecting Arduino to Raspberry Pi via i2c gives for example, this page.
While apparently this should work, there is a factual error there: on arduino side, pins used for i2c do have internal pull ups, and they are activated by Wire library.
Digging further, I've found following information:

However, it turns out that these are weak (high-resistance) pull-ups;
  the Pi has strong pull-ups which dominate those on the Arduino, making
  direct connection safe.

What does safe mean? And how weaker are those pullups compared to raspberry pi ones?
Let's check:

rpi i2c pullup: 1K8
arduino i2c pullup: 20K-50K from datasheet (if I'm looking correctly, I'm using ATmega8), though the above page states 10K.

What can I make of those values? My (intuition rather than) basic knowledge hints me something along the lines:
If the i2c is floating, it means the 5V is connected with 3.3V and there are only those pullups along the way, so:

calculate voltage drop between 5 and 3.3: 1.7V.
calculate voltage drop across rpi pullup proportionally to voltage drop across arduino pullup:
1800 / 30000 = 0.06, meaning 0.102V across rpi pullup and 1.598 across arduino pullup, so the actual pulled up voltage is gonna be 3.3V + 0.102V = 5V - 1.598V = 3.402V?

Though I'm pretty sure I'm doing some terrible math here and someone is gonna have good laugh:)
So, my question is not whether it's safe (as it's been proved), but rather why is it safe considering the internet resources are inaccurate on this matter.

And your question is? I have done this and it works. 2. What makes you think the Arduino pullups are enabled? Even if they were, I²C would not work reliably. 3. I haven't checked your calculation, but even if you put 3.402V it wouldn't matter. It only becomes an issue if the voltage exceeds a diode voltage drop.

Well, my question is to find out why is it safe, cause it's been tested and proven, yet always backed by some erroneous/informal claims.
The pullups are enabled, check 'twi_init' helper function in Wire library source.

You math seems correct. Try calculation the amount of current. It will be in the micro-amps. Combined with the low voltage, you get a few micro-watt in power. Not enough to do any kind of damage. I think that is how they came to the conclusion it's safe.

If you are sure to disable pull up on arduino side you are safe, as i2c works in open-drain mode, but the logic level "high" of arduino is about 3.2v, so it would be unstable.
Otherwise i2c pin of rasp are NOT 5v tolerant, so you must be sure the voltage on the bus does not exceed operative limit; as you calculated ~3.5v should be good on raspi, but please check on datasheet.
Also, you should check the total current on the bus, but as atmega resistor as so high,it should not pose a problem with raspi (but may give problem with passive i2c, that you can solve with a external pull up)

But I have no idea whether I calculated it correctly...


text:
Cannot control servo with button.
I am unable to get a button on my arduino board to control a servo. I'd like the servo to rotate 90 degrees on button push, but it is unresponsive.
Is there a flaw in my code or is it wiring?
#include <Servo.h>  // servo library

const int button1Pin = 2;  // pushbutton 1 pin
Servo servo1; // servo control object

void setup()
{
  pinMode(button1Pin, INPUT);
  servo1.attach(9);

  // Set servo 1 to output?
}

void loop()
{
  int button1State;
int position;

button1State = digitalRead(button1Pin);

if (button1State == LOW);
{
  servo1.write(90);  // move servo
}

}

It might already start at 90 degrees. If you can, turn the motor (carefully!) and see if that helps.

The problem is that servo1.write(90) does not do what you think it does.
servo.write(angle) tells the servo to go to that position, not to move by that many degrees. What you need is to set one angle when the button is not pressed, and a different angle when the button is pressed.
Normal hobby servos can move about 180 degrees. Where 0 is depends on how the servo horn is positioned. Which direction of rotation is positive depends on the manufacturer.
try something like this to set one position when the button is pressed and a different one when it is not:
if (button1State == LOW);{
    servo1.write(45);  // move servo
}
else {
    servo1.write(135);
}


text:
What is the best way to establish wireless communication between the Lilypad and a Mac?
I want to build a wearable device for a dancer using the Lilypad and I need to first send the programme from my Mac to the Lilypad board and then transfer the data read by sensors back to my Mac.
I want to know what is the best wireless solution to use here. I've seen various options such:

the Xbee or Bluetooth modules (http://www.hobbytronics.co.uk/bluetooth-mate-silver)

Have you considered using one of those 315MHz or 433MHz modules with a UART?

What is "best?" Can you please add your requirements (price, range, speed, size, etc.)...

@AnnonomusPenguin The size is important to me because it is a wearable device. But what I want to know is which the most reliable one.

I have been using a hc-06 module very successfully. http://www.dx.com/p/hc-06-wireless-bluetooth-serial-pass-through-module-for-arduino-works-with-official-arduino-board-238364#.VLg153WjlIc
Connect pins to +5v, Gnd, and digital pins 0 and 1 (rx & tx).
Do not try to connect to USB and this at the same time, as communication will get garbled.


text:
Get the distance to non perpendicular surface
So I'm using the HC-SR04 modules to get the distance to objects, the problem is that if it's not a perpendicular surface I dont get any reading, and I assume that the reason is that the ultrasounds get reflected in another direction, so they don't come back to the sensor. What's the way to get over this issue?
Thanks in advance

To use a completely different sensor.

I'm guessing that the sensor sends only one column of sound, thus it would bounce off to another angle. I'm not sure how a light sensor would work...

SO what sensor would it be?

What is the surface made of & what sort of range are we considering?

The ideal scenario would be a room inside a building, so the range would be from some cm to a few meters. The surface any kind of material I'd say

The distance from a point to a plane is defined as perpendicular.

Use a Infrared Proximity Sensor

or
Something like a LidarLite

They measures distance by measuring the offset (parallax) from a projected point of light. This will not suffer from echo restrictions, like Ultrasonic Sensors do.

You mean to say that you get proper reading when the surfaces are FLAT?
Ultrasonic sensors have this property that the waves emitted from then are only 15 degree from the line of sight, but this means that you can surely calculate distance of objects having a curved shape. The only condition is the object should be directly in a straight line

That's not the issue.  Rather, when the surface is sufficiently canted, most of the energy bounces off in some other direction and not back at the transducer, meaning no echo is measured.  It's not entirely different from a mirror, or bouncing a ball off a wall.

Coming in late but seeing no solutions offered yet, I'll take a stab at it:
Assume your vehicle is traveling obliquely toward the wall.
Assume you can find and measure the perpendicular distance to the wall.
Then you can calculate the travel distance from those two measurements:

Next we need to find the angle between the vehicle's heading (center-line) and the perpendicular. A rotating sensor that senses return-signal strength could probably give good results but is mechanically more complicated. Given that the ultrasonic sensors have a somewhat broad sensing angle, 3 or 5 fixed sensors (1 straight ahead and 1 or 2 to either side) may work well enough if you're just trying to avoid hitting the wall. In that case you could measure with all of the sensors, take the least distance measurement as 'p' and the known angle of that sensor as 'theta'.
What's left is to decide how to make the calculation and work with cosines. For the rotating sensor case, you'll have to find the angle of the sensor at the time of it's smallest reading, and look up in a table (or calculate) the cosine of that angle. For the multiple fixed sensors case, you already know the sensors' angles and therefore, their cosines.
If you have enough code memory it would easy to write your calculations in floating point, certainly for some quick and dirty testing. If not, or you need to speed up the calculations, you can do it in fixed point with less code. it's a little bit harder for the programmer but much easier and quicker for the MCU.

Please note that ultrasonic sensors tend to interfere with eachother depending on environments and how close they are pointed to eachother in degrees and how close a wall is

Yes, they would need to be pinged sequentially, and the smallest reading taken.


text:
Freeze with VCNL 4000 Proximity Sensor
I've the VCNL 4000 Proximity Sensor I use some sample code and at the very beginning
the following code hangs (never finishes)
 readVCNLByte(0x81); is called

Can this problem be caused because the contact of the pin isn't very good.
I only but the part with pins in the sensor without to solder it.
Is it likely that this may be the problem ? I have not many experince with solder and the sensor is really small so i'd like to avoid it for first tests ;)
Here the code. The last output in the Serial window is "pre product"
  Serial.println("VCNL");
  Wire.begin();
  Serial.println("pre product");
  uint8_t rev = read8(VCNL4000_PRODUCTID);
   Serial.println("post product");
  if ((rev & 0xF0) != 0x10) {
    Serial.println("Sensor not found :(");
    while (1);
  }

Try applying some lateral force to the connection. Or just solder the headers. It's not that hard to desolder them, if you remove the black plastic, before desoldering.

You really can't expect this to work unsoldered. The contacts will be at best intermittent, and poor contact. Even a 'dry joint' where the pin is mostly surrounded by solder doesn't work well, these are the ultimate examples! You could however use an edge-connector, if you can find one; not something you see often nowadays.

Sorry .. my answer comes late ..
I had the same issue, this has nothing to do with bad connexion between wires (not only at least).
But by playing with some parameter (current value > 60mA) I noticed that the module begin to freeze more often.
To fix that :
You need to add a small delay within your readbyte function after a i2c.stop()
I found that an issue had been written about that : https://github.com/adafruit/VCNL4000/issues/1
They recommand a 170us delay
I'm testing myself at full current and max speed (an since 30min it didn't freeze)... Before it could freeze in a second.
Hope it helps ;)

EDIT :
In order to better understand where the freeze comes from, I re-write a simple I2C library. I could get rid of the freeze by simple add a small delay in the i2c_start function (that send the start condition along with the slave address)
uint8_t i2c_start(uint8_t i2c_slave_address){
       //reset TWI control register
       TWCR = 0;
       //transmit start condition
       TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN);
       //wait for end of transmission
       while((TWCR & (1<<TWINT))==0){
              _delay_us(75); // <-- here is the trick
       }
       if( (TWSR & 0xF8)!= TW_START ){
              return -1;
       }
       // load slave address into data register
       TWDR = i2c_slave_address;
       //start address transmission
       TWCR = (1<<TWINT) | (1<<TWEN);
       //wait for transmission
       while ( (TWCR & (1<<TWINT))==0 );
       //check if the slave did acknoledge the Read/Write mode
       uint8_t twst = TW_STATUS & 0xF8;
       if ( (twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK) ){
               return -1;
       }
       return 0;
}

you will need to add these libraries :
util/twi.h (for the macro TW_STATUS .. TTW_MT_SLA_ACK and so on)
util/delay.h
stdlib.h (for the uint8_t way of typing variable ..not actually 100% sure)
I'm still not fully satisfy by this solution, but it is still more effective that the one that adafruit propose.
I suggest you write you own i2c library (5 functions : init / start / read / write / stop) you now have the start already .. so 4 left ;)
If you're still to much afraid : in twi.c ( .\arduino\avr\libraries\Wire\utility\twi.c) and twi_readFrom(...) function.
On line 155 and 159 you will see that arduino send the start condition, but do not wait / take care that the transmission as been done... you can add a while function as previously describe to ensure it.

MASTER EDIT :
My previous solution didn't solve the issue neither...
Actually reading the application note (Designing VCNL4000 into an Application : google that)
gives the solution (page 7)
after you send the command to perform a single measurement, you need to wait.
I put a delay of 500ms and have none anywhere else. This works like a charm.
But for energy efficiency I recommend to put the uC in sleep mode for that period of time.