text:
Leonardo with xbee shield?
I'm trying to get a XBEE shield to operate on an Arduino Leonardo. Usually i use the AltSerialLibrary to emulate an extra serial for the xbee. However since the Leonardo comes with two sets of serial, i figured I use that instead.
//#include <AltSoftSerial.h>

//AltSoftSerial XBee(5,13); // RX, TX

void setup() {

  Serial1.begin(9600);
  Serial.begin(9600);

}

void loop() {

  Serial.println("Odds");
  Serial1.println("Ends");

  delay(1000);

}

The code above aims to write values to both the serial monitor (serial) and xbee (serial1). However in the Xbee's XCTU program, the remote xbee does not recieve any data.
Any feedback on how I might fix this will be appreciated.

How is the Xbee connected? You have a SoftSerial connection commented out, but Serial1 does not use the same pins as the SoftSerial would have.

kinda obvious question, but how did you configure the XBee previously?

You said you are using a Xbee shield.  What shield is it, and what pins does it use for Serial communications?
If you were using software to emulate the second serial port on other arduinos, you were probably using different pins, and so if the shield is designed to communicate over (as an example) pins 2 and 3 then it will most likely not work with pin 0 and 1 without moving jumpers or switches.  For example, this
Xbee Shield: http://core-electronics.com.au/xbee-shield.html/?acc=9f61408e3afb633e50cdf1b20de6f466 has a switch to switch between pins 0 and 1 and pins 2 and 3.
You could also try some code that reads from Serial and prints the data to Serial1 and visa versa.  This means you can experiment to get a greater understanding of the problem.


text:
Temperature sensors TMP36 and LM35 have temperature diff. (offset) in the same circuit
I am trying to use the two temperature sensors TMP36 (from Sparkfun Inventor's kit) and KEYES LM35.
In read TMP36 Sensor and I convert the result to Celsius using the following code:
// TMP36 input sensor -> degrees Celsius calculation
TM36reading = analogRead(TM36sensor);
TM36voltage = (TM36reading/1024.0)*5.0;
//converting from 10mv per degree with 500 mV offset
//             (TMP36 voltage - 500mV) times 100)
TM36degreesC = (TM36voltage - 0.5) * 100;

In read LM35 Sensor and I convert the result to Celsius using the following code:
// LM35 input sensor -> degrees Celsius calculation
LM35reading=analogRead(LM35sensor);    // reads the LM35 output
LM35voltage = (LM35reading/1024.0)*5.0;
LM35degreesC=LM35voltage*100.0;

I have connected also a LCD display to monitor visually the values of these two sensors. Here is my full code. I use also a serial log. Here is a sample from this serial log (as you can see there is a difference/offset between 0.5 to 0.9 Celsius).
TM36: 17.38, LM35: 16.60 diff -> 0.78
TM36: 16.89, LM35: 16.11 diff -> 0.78
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 17.87, LM35: 16.60 diff -> 1.27
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 16.89, LM35: 17.09 diff -> 0.20
TM36: 17.38, LM35: 17.09 diff -> 0.29
mean difference between sensors: 0.48
TM36: 17.38, LM35: 16.11 diff -> 1.27
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 17.38, LM35: 16.60 diff -> 0.78
TM36: 16.41, LM35: 17.58 diff -> 1.17
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 17.38, LM35: 16.11 diff -> 1.27
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 17.38, LM35: 16.11 diff -> 1.27
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 16.89, LM35: 17.09 diff -> 0.20
mean difference between sensors: 0.71
TM36: 17.38, LM35: 16.60 diff -> 0.78
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 17.38, LM35: 16.11 diff -> 1.27
TM36: 17.38, LM35: 16.11 diff -> 1.27
TM36: 17.38, LM35: 16.11 diff -> 1.27
TM36: 17.38, LM35: 16.60 diff -> 0.78
TM36: 17.38, LM35: 16.11 diff -> 1.27
TM36: 17.38, LM35: 16.11 diff -> 1.27
TM36: 17.38, LM35: 17.09 diff -> 0.29
TM36: 16.89, LM35: 16.11 diff -> 0.78
mean difference between sensors: 0.93

I power the Arduino from the computer using the USB cable. When the computer is ON we have the offset that I already demonstrated above. When the computer is turned off (after computer shutdown), immediately the sensor of TMP36 falls around 1 Celsius.. And then both sensors have similar temperature.

Why there is this temperature difference between TMP36 and LM35 sensors? How can we "fine tune" these sensors to monitor the real temperature?

Not sure if this applies (I'm a total newbie to Arduino), but this link (https://learn.adafruit.com/tmp36-temperature-sensor) has a section at the bottom called "Problems you may encounter with multiple sensors".  Might be something to review and see if it applies to your case.

The sensors have different accuracy, according to their datasheets.
The TMP36 has ±2°C typical accuracy, while the the LM35 has 0.5°C typical accuracy (over 25°C).
Read the datasheet carefully and pay attention to the characteristics, more specifically to the accuracy error graphs for each sensor. At your measured temperature (~17°C), you should expect the following error (the red line is not super accurate, but should give a general clue):
LM35:

TMP36:

In addition, as Michal stated, you might have noise in your circuit, and you are not connecting the TMP36 as per the datasheet suggests (note the capacitor between +V and Ground):

Thanks for the detailed charts.. I will try to use the 100nF Capacitor next days (I have to buy one first).

That's good, and might help a bit, as long as you understand that you will still see differences between the two sensors because of different characteristics.

There are many things, first different sensors have different accuracy or they may not have been calibrated from the factory. In addition both are analog and analog reading is susceptible to noise. My guess is there is a high frequency noise on power line coming from the computer interfering with your readings. Try putting a small (100nF) capacitor between AREF and GND pin. You can always just take median of the measured values as the actual temperature.

I read here that Arduino Mega already has a capacitor 100nF connected between AREF and GND. I will try to buy next days a 100nF and try to see if the noise is filtered in that way. Thanks.

source: Stack Exchange

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

sort: votes


text:
ov7670 + Sd Card + arduino
I have three devices for making a motion activated security camera system:

this is the camera : LINK  OV 7670
this is the SD Card module: LINK
and a basic motion Sensor: PIR with 3 pin

I have an Arduino UNO and an Arduino Mega 2560.
I can connect the SD card and sensor, they work fine but I cannot connect the camera as there are not enough pins for it on UNO.
Is there a chance to connect all of them without any additional device?
I saw some working project with additional device (arducam) but I do not have much money to spend on this project.

Do this camera module have AL422 FIFO?

I think both the Camera module and the SD (can't see underside) require 3.3v logic, while the Uno and Mega have 5v I/O. So you probably need some logic level shifting. Other than that, I see no problem.

to Gerben: Yes camera need 3.3v logic, but SD card module also have 5v. @AndrewPaes I don't think so. It was cheapest module when I buy ($10). OV 7670+AL422 FIFO was $22. What is AL422 ?

I am facing the same problem as you mister LuffyTheKaizoku. I bought the non-FIFO and then bought the FIFO version of the OV7670 but still not found a way to program it. I am also trying to save the code to an SD card! Did you manage to find a solution for this problem?
If you did, I would really really need your help. Thank you very much in advanced!
Felipe

This camera module requires the use of additional hardware, as the camera and Arduino operating frequencies differ, which can result in loss of synchronization and changes to the image, and other connection problems.
Thus, we must use an integrated circuit intermediary, making the connection between the camera and the Arduino. The function of this chip is to receive the camera information, store them and then send them to the Arduino using the digital doors, much faster than if we used the serial communication.
An example of an integrated circuit that could be used is AL422, suitable for treating a video signal, which also is embedded in some OV7670 modules.
Looking like the connection pins behave in 7670, your module should be equal to it. So spare pins to be able to make other necessary connections.

Would better check the connection through the datasheets:
7670 datasheet
AL422 datasheet
An example of project
But to answer your question; You'll need to purchase a piece more if you don't have AL442.
Regards,

Thanks for your help Andrew. I found the same project yesterday and I realised that I need Al422. After all these research , I also learned there isn't any shop to buy AL422 in my country (internet shop). So I give up and order new camera module. Thanks a lot again.

You don't need these 10Ohms (by the way totally insufficient if needed), because RPi and the camera JTRON function at 3.3V.

Example link goes to an adware download site now :(

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


text:
Read all Digital input in arduino once time and sent theme to serial
i need to read all Read all Digital input in arduino once time; example:
Serial.write(digitalRead(0),digitalRead(1),...,digitalRead(13));

to receive state of all digital pin in one times from my app build with delphi

So what's your question?

Serial.write(digitalRead(0),digitalRead(1),...,digitalRead(13)); not working , i need to get function like that

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  Serial.print("<");
  for (int p = 0; p < 14; p++)
  {
    Serial.print(digitalRead(p));
  }
  Serial.println(">");
}

According to the pin mapping, D0-D13 and A0-A5 are mapped to ports B, C, and D. So simply read the raw ports as bytes, send the values, and decode them on the other side.
Serial.write(PINB);
Serial.write(PINC);
Serial.write(PIND);

Note that A6 and A7 (on boards that have them) are not mapped to digital pins and so cannot be read in this way.

iam tring this command but not working for me , any one can help me with example or demo ?


text:
IDE support for Arduino micro
I have an Arduino micro http://arduino.cc/en/Main/arduinoBoardMicro I was looking to know which is the lowest version of the IDE that support it. Actually on the IDE 0023 is not present in Tools > Board.

Why are you still using 0023?

Find some very old .pde that works and is compatible with 002x

I don't think you're gonna get an answer here, as it's generally accepted to use the latest version, and we're gonna need to know why you don't want to do that.

According to the Arduino Software Release Notes, support for the Arduino Micro was added in 1.0.2.


text:
Program got so many errors about expected ) or ; before either
This is my first time to try program arduino, and I am clueless. I have a friend who told me about things work, and he told me the programming language is C (or similar to C) which we have learned in our class. I just program as my friend examples, but it doesn't work and return error codes about expected ; before ( or ) before ; etc.
I'm not sure why this wont work. This is the hardware (simulated) I going to make.

here's the code:
#define dw 8; //buttons down
#define ri 9; //buttons right
#define le 10; //buttons left
#define up 11; //buttons up
#define ok 12; //buttons ok
#define mn 13; //buttons menu
#include <LiquidCrystal.h>
LiquidCrystal lcd(6,5,4,3,2,1);
int i=0;
char input[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

void setup()
{
  pinMode(dw, INPUT);
  pinMode(ri, INPUT);
  pinMode(le, INPUT);
  pinMode(up, INPUT);
  pinMode(ok, INPUT);
  pinMode(mn, INPUT);
}
void intext()
{
  int c=0, lim=16;
  for(i=0;i<lim;)
  {
    lcd.setCursor(c,1);
    input[i]=97;
    if(dw=HIGH)
    {
      if(input[i]>122)
        input[i]=97;
      input[i]=input[i]+1;
      lcd.print(input[i]);
    }
    if(up=HIGH)
    {
      if(input[i]>97)
        input[i]=122;
      input[i]=input[i]-1;
      lcd.print(input[i]);
    }
    if(ri=HIGH)
    {
      c=c+1;
      lcd.setCursor(c,1);
      lcd.print(input[i]);
    }
    if(le=HIGH)
    {
      c=c-1;
      lcd.setCursor(c,1);
      lcd.print(input[i]);
    }
    if(ok=HIGH)
    {
      lim=i+1;
    }
  }
}

void loop()
{
  lcd.begin(16,2);
  lcd.setCursor(0,0);
  lcd.print("Masukan kata:");
  intext();
}

I have no idea why it wouldn't work. I'm sorry if I'm too stupid to understand.
Thank you!
Edit: oh yeah, the errors, here:
  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
Arduino: 1.0.6 (Windows NT (unknown)), Board: "Arduino Uno"
programyuhu.ino: In function 'void setup()':
programyuhu:14: error: expected `)' before ';' token
programyuhu:14: error: expected primary-expression before ',' token
programyuhu:14: error: expected `;' before ')' token
programyuhu:15: error: expected `)' before ';' token
programyuhu:15: error: expected primary-expression before ',' token
programyuhu:15: error: expected `;' before ')' token
programyuhu:16: error: expected `)' before ';' token
programyuhu:16: error: expected primary-expression before ',' token
programyuhu:16: error: expected `;' before ')' token
programyuhu:17: error: expected `)' before ';' token
programyuhu:17: error: expected primary-expression before ',' token
programyuhu:17: error: expected `;' before ')' token
programyuhu:18: error: expected `)' before ';' token
programyuhu:18: error: expected primary-expression before ',' token
programyuhu:18: error: expected `;' before ')' token
programyuhu:19: error: expected `)' before ';' token
programyuhu:19: error: expected primary-expression before ',' token
programyuhu:19: error: expected `;' before ')' token
programyuhu.ino: In function 'void intext()':
programyuhu:28: error: expected `)' before ';' token
programyuhu:28: error: expected primary-expression before '=' token
programyuhu:28: error: expected `;' before ')' token
programyuhu:35: error: expected `)' before ';' token
programyuhu:35: error: expected primary-expression before '=' token
programyuhu:35: error: expected `;' before ')' token
programyuhu:42: error: expected `)' before ';' token
programyuhu:42: error: expected primary-expression before '=' token
programyuhu:42: error: expected `;' before ')' token
programyuhu:48: error: expected `)' before ';' token
programyuhu:48: error: expected primary-expression before '=' token
programyuhu:48: error: expected `;' before ')' token
programyuhu:54: error: expected `)' before ';' token
programyuhu:54: error: expected primary-expression before '=' token
programyuhu:54: error: expected `;' before ')' token

In C and in C++, #define is not an instruction of the language, but a directive of the pre-processor.
What it does is define a "macro" which will be replaced everywhere it appears later on in the source file.
For instance:
#define DUMMY 152

int x = x + DUMMY;
myfunction(DUMMY);

will be changed, before compilation, into:
int x = x + 152;
myfuntion(152);

In the example above, DUMMY is replaced everywhere by what follows it in the  #define line, i.e. 152.
As pre-processor directive is not an instruction, it shall not be ended by ;. If you add ; at the end of a #define, then it will be part of the replacement:
#define DUMMY 152;

int x = x + 152;;
myfuntion(152;);

As you can see now, DUMMY is replaced by 152;, not just 152.
So the solution in you example is to remove all ; that are at the end of #define lines:
//buttons down
#define dw 8
//buttons right
#define ri 9
//buttons left
#define le 10
//buttons up
#define up 11
//buttons ok
#define ok 12
//buttons menu
#define mn 13

Note that comments should also be removed from the #define otherwise they would also appear everywhere the replacements are done.

Here's the first line of your code:

#define dw 8; //buttons down

Here's the first error line:

pinMode(dw, INPUT);

Let's put them together and see what we get:
pinMode(8; //buttons down, INPUT);

That's not valid C++. Using the output I've shown you, modify the input until it looks correct. And then keep doing it until the code compiles.

I am sorry for asking this, but did you mean
(pinMode(8; buttons down, INPUT);) ? I don't quite understand on the comment part.

Did you read the code you wrote? Did you read the parts I extracted?

Sorry again if I don't understand, I don't know about C++ at all (as I only learn about the regular C).
So I just copy your code as is?
I'm lost

Look at the first line of code in my answer. Look at the second line of code in my answer. When taken together, they result in the third line of code in my answer. Does this make sense to you?

I tried it but it's still doesn't work. I will try to redo/change my code using another way. Sorry for the trouble I have caused.
Thank you for your assistance.
You made me realize how difference C++ with C is.
Again Thank you.

This is not a C-vs.-C++ issue. You would have exactly the same problem if only C were in use.

The errors are in your #define statements.
These should not have ; as they are not executable statements


text:
Raspberry Pi with Arduino, Serial connection stops working
This is the hardware set-up at home,
Raspberry Pi GPIO -> Logic Level Converter -> Arduino -> Multiple Relays

I am running Raspbian and NodeJS on the Pi while the Arduino is loaded with StandardFirmata.
I connect NodeJS to the Arduino with the johnny-five package and it works well after it's started. But after extended periods, a few hours? The Arduino stops responding. Whatever command that I send to the Arduino won't be acted on. It's as though as the Arduino hung.
Both the Raspberry Pi and Arduino are being powered indenpendently with a 1A Nokia USB Adapter.
Does anyone know why this is happening?

johnny-five
StandardFirmata
NodeJS Server Code

Also, please add links to all the products you are using. I don't know what "Johnny-Five" is aside from a robot from an 80s movie. Same with "StandardFirmata".

Also, the details on the RPi code, as well as (ideally) pictures of how you have everything hooked up.

You might want to consider posting your code, otherwise every answer here will be a guess at best

Very often, if Arduino hangs, this is a memory problem (typically collision between the heap and the stack). It's gonna be hard to diagnose the actual issue without the source code of the program you downloaded to Arduino!

Hav you check that your Arduino still works properly with usual programs (blink in particular). You first need to find out if it is a hardware issue (pin or MCU fried due to too much current switched through the relays) or software.

Added links to all the software I am using and my NodeJS Server code. Will take pictures of the set-up in a bit.

@jfpoilpret added in connection. I'm sure the Uno is fine as I can just restart the uno and it starts working again. It's just that I'm trying to use it as a 24/7 solution

You have drawn a relay coild directly connected to pin 13, which is a very bad idea.  Use an NPN transistor to drive the relay, and give it a catch diode.

I've had a lot of serial hanging issues with my Arduino and Pi3. There seems to be a lot of issues with USB serial interfaces on the Pi. I've also noticed that my Pi seems to connect to the Arduino just fine after a reboot, but if I disconnect and then reconnect the Arduino (which should be fine), then it's able to connect initially, but the connect hangs after a few minutes.

A "1A" means 1 amp? I know the RPi 3 doesn't run reliably with less than 2.5 amps supplied by itself. Is it possible your power supply is overheating and dropping voltage?

@wilsotc Probably shouldn't be replying to a 4 year old thread. The Pi 3 didn't exist back in 2014. I was referring to a Original Raspberry Pi. Unless you're replying to Cerin.
Just so anyone finds this issue, I don't think I ever found a fix for it. It might be better now though.

If none of the code is yours, and all code from the Firmata library, then the most possible cause that comes to mind after reviewing the library code is memory leak, which makes the next allocation to fail and by thus breaking the code.
The Firmata library does perform dynamic memory allocation, checkout Firmata.c, so it is realistic - I would suggest to take it with the Library's author.

Yeah. None of the code on the Arduino is mine. It's all Firmata's. So it's probably Firmata?

logically, it must be. Perhaps they didn't take into account running indefinitely.

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


text:
control a jack/cylinder to open/close a window
I want to open the window to let the cat enter or go out, but the mecanism of the window may me think that the best way should be to use a jack/cylinder (I don't know what term is more appropriate in english for that) to open and close the door.
I will use rfid or another wireless think to know it the cat is in the place and then open the wondow but I want to close the window and let the wndow close event if there is little bit of wind, so I need domething robust.
Do you know a good hardware with (this would be the best) piece of code that can help me for that?
Thanks in advance

Something like this http://www.window-openers.com/ks3040_electric_window_opener.html maybe

Check out this instructable - for opening a window for a cat :)
The guy used a servo, Towerpro MG995 with 10 kg torque for opening/closing the window, and a 10cm distance sensor for sensing the cat (he used Pololu Carrier with Sharp GP2Y0D810Z0F Digital Distance Sensor, but I believe that any proximity sensor will do).
This is a pictrure of the mechanism, seems quite robust:

I think it's safe to say that this would fall under "fair use".

so @IgnacioVazquez-Abrams you woundn't recommand it? too cheap?

@clement: See the revisions of the answer.

and what about a Actuator? @Ignacio ?

Servo is a type of actuator.


text:
avrdude: stk500v2_ReceiveMessage(): timeout with ADDAC VCC
I am getting the above error message uploading the ADDAC VCC, and the only thing that's changed I think is the patch is bigger.
Is there a fix for this or will I have to send it back? Hope my formatting is OK
Binary sketch size: 12,330 bytes (of a 258,048 byte maximum)
/usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega2560 -cwiring -P/dev/ttyUSB0 -b115200 -D -Uflash:w:/tmp/build953252908946386724.tmp/comps.cpp.hex:i
avrdude: ser_recv(): programmer is not responding
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]

avrdude: Version 6.0.1, compiled on Oct 21 2013 at 17:07:18
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/usr/share/arduino/hardware/tools/avrdude.conf"
         User configuration file is "/home/luke/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB0
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
avrdude: wiring_open(): releasing DTR/RTS
avrdude: wiring_open(): asserting DTR/RTS
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

avrdude done.  Thank you.

avrdude: ser_recv(): programmer is not responding
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]

As a first step in tracking this down, you should enable the "Verbose Upload" option in the Arduino preferences. That will give you considerably more output to let you know whether the upload is failing right away, or in the middle of communication.
Depending on your board, you might want to try hitting the RESET button on your board just before starting the upload, in order to force the boot loader to run.

Your log is showing that communication is failing right away (avrdude never gets a proper response). This can mean that

the VCC is not resetting
there is no bootloader installed
there is some other defect

You can test case is by manually hitting the reset switch around the time that avrdude starts. If the necessary pins are available, you can exclude case 2 by installing a new boot loader with a programmer, which also tests scenario 3 a bit.


text:
Is there a radar - like sensor that can tell me the distances of multiple things around the sensor?
I'm trying to develop something that requires accurate distance measurement of objects around the center of the contraption. However, I cannot find any way to achieve this other than using a bunch of infrared distance sensors. Really, I'm looking for something that costs at most $200 and is compatible either with arduino, PC, or raspberry pi.
This may not be the place for this, if not, please inform me.
Thanks in advance!

If seen people put an ultrasonic sensor on a serve. By moving the servo you can "scan" the surroundings. It is however a bit slow.

What you're looking for is called lidar - but it's not cheap. RPLIDAR is the current price leader for non-hacky solutions, and I haven't seen it for much less than $400 anywhere.

Wait so would you suggest just using the infrared distance sensors then?

I don't know your application, so I can't answer that.


text:
Can an Arduino Micro receive commands from another microcontroller when hardwired together?
I plan to build functioning reaction wheels, controlled by an Arduino Micro. Ideally, I'd like to have the reaction wheels, and the micro, be a single unit which would receive external commands from another microcontroller.
I know you can link Arduino microcontrollers, and every time I've seen it done it has been with a RC module such as XBee. Is it possible to link units using something like the micro-usb on the Arduino Micro?
If this is possible, is it as simple as connecting the micro-usb ports on my microcontrollers, and then working out the programming?

Eh, I didn't know there was an Arduino.SE... I probably should've looked harder.

You cannot do this with the micro USB ports.  You will need to use I/O pins.  Either serial or I2C would be good options.  It might be advisable to use I2C if you want to control multiple 'slave' microcontrollers as they can all sit on the same bus.  Using the serial port would require multiple transmit and receive pins on the master controller, likely requiring software serial ports (high overhead).  Also, if you don't use the serial port for comms, then you can use it for debugging.

It might be worth explaining WHY you can't "just connect the micro-usb ports". There are two issues here:

USB is not symmetric, and an Arduino micro is only designed to act as a client. One of your microcontrollers would need to have USB OTG support to act as a host.
Even though there are microcontrollers that do have USB OTG support, you'd still have a nontrivial hurdle writing the software for them (Pretty sure the Arduino USB code is client specific as well, though I'm not familiar with the details of the serial over USB protocol).

In short, your basic idea is not physically or technically impossible, but would be fairly difficult to execute, while there are much simpler solutions available.

Usually the RF links (xbee included) just replace a set of wires connecting two serial ports. You can very easily connect the serial ports on two arduino's and communicate between them without any special hardware in between. You will only need 4 wires (power, ground, transmit, receive).

For me, it would be easier (I know now that the other way is easy too) to just connect the micro-usb ports. Would that work just as well?

No, you cannot just connect the usb ports

You can use a USB connector (micro) (mounted on a custom PCB) for whatever you want and route the connector's pins to whichever Arduino pins you want. It will not be USB, but you could, at least, use USB cables for ease-of-connection.
This is un-wise, at best, because someone is, eventually, going to plug in a real USB cable.


text:
Servo motor swinging back to 0°
I just got my arduino and servo. But my servo may be acting strangely.
Whenever I tell the servo to go somewhere it keeps going to 0 than to that position and stops after 10-15 seconds or more.
This is the code used in this video
#include <Servo.h>

    Servo myservo;

    void setup()
    {
      myservo.attach(11);
      myservo.write(50);
    }

    void loop()
    {
    }

https://www.youtube.com/watch?v=rsikknT7z6g
It is connected like this:
Ground from Arduino to breadboard row 3
Ground from external power supply to breadboard row 3
Ground from SERVO to breadboard row 3
Power supply positive to servo VCC
Servo signal to pin 11

how is this being powered?

Try with something like:
#include <Servo.h>

    Servo myservo;

    void setup()
    {
      myservo.attach(11);

    }

    void loop()
    {
        delay(2000);
        myservo.write(50);
        while(1);
    }

and let us know.
But more important: disconnect the servo +5V wire from Arduino and use another power supplier!!!


text:
RCSwitch on Attiny85
I would like to use my Attiny85 as an remote controlled relay switch.
I have already tested the sketch on my Atmega328 and it worked.
Now I wanted to burn the sketch on my Attiny85 using ArduinoISP but I get the following error in the ArduinoIDE:
sketch_dec25a.ino: In function ‘void setup()’:
sketch_dec25a:13: error: ‘class RCSwitch’ has no member named ‘enableReceive’
sketch_dec25a.ino: In function ‘void loop()’:
sketch_dec25a:20: error: ‘class RCSwitch’ has no member named ‘available’
sketch_dec25a:21: error: ‘class RCSwitch’ has no member named ‘getReceivedValue’
sketch_dec25a:22: error: ‘class RCSwitch’ has no member named ‘getReceivedValue’
sketch_dec25a:25: error: ‘class RCSwitch’ has no member named ‘resetAvailable’

That's my code:
#include <SoftwareSerial.h>
#include <RCSwitch.h>

int RELAY_PIN = 2;

RCSwitch mySwitch = RCSwitch();
SoftwareSerial mySerial(1, 3); // RX, TX

void setup()
{
  pinMode(RELAY_PIN, OUTPUT);
  mySwitch.enableReceive(0);  // Receiver on inerrupt 0 => that is pin #2
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
  if (mySwitch.available()) {
    Serial.println(mySwitch.getReceivedValue());
    if(mySwitch.getReceivedValue() == 1234567){
      digitalWrite(RELAY_PIN, HIGH);
    }
    mySwitch.resetAvailable();
  }
}

I am using these cores: https://code.google.com/p/arduino-tiny/
I am using the SoftwareSerial just for debugging.
Sorry for my bad english and thanks for your help!

The issue you face is that RCSwitch does not seem to support receive mode for ATtiny.
This is what you can find in RCSwitch.h:
// At least for the ATTiny X4/X5, receiving has to be disabled due to
// missing libm depencies (udivmodhi4)
#if defined( __AVR_ATtinyX5__ ) or defined ( __AVR_ATtinyX4__ )
#define RCSwitchDisableReceiving
#endif

Then all methods related to receptions are not defined in RCSwitch class for ATtiny MCUs:
#if not defined( RCSwitchDisableReceiving )
void enableReceive(int interrupt);
void enableReceive();
void disableReceive();
bool available();
void resetAvailable();

unsigned long getReceivedValue();
unsigned int getReceivedBitlength();
unsigned int getReceivedDelay();
unsigned int getReceivedProtocol();
unsigned int* getReceivedRawdata();
#endif

I am really not sure if there is a way to work around it, I have not looked at the code in RCSwitch.cpp.
Maybe you best option would be to find another RC library.
For instance, if you can use Infra-Red RC, then there are libraries out there that could work for ATtiny:
https://github.com/shirriff/Arduino-IRremote

Arduino-IRremote is not compatible with ATTiny as well.

According to this issue https://github.com/shirriff/Arduino-IRremote/issues/97 it seems there are some options for ATtiny.

I have tested with Digispark ATtiny85 and https://github.com/sui77/rc-switch work perfect
just comment #define RCSwitchDisableReceiving
than use in setup code enableReceive(0); and external pin 7 PB2(int0) as RF source
Or you can use other software pin interrupt
in setup:
PCMSK |= (1<<PCINT0);//here pin number
GIMSK |= (1<<PCIE);
interrupt function

ISR(PCINT0_vect) {
  rd.handleInterrupt(); // you need also put handleInterrupt() in public section in RCSwitch.h
}

Yes, as akaJes addition working great!
I move handleInterrupt() do public in RCSwitch.h, comment #define RCSwitchDisableReceiving and adding interrupt function like akaJes. Thanks! :-)


text:
Serial debug output looking messy
I've got this quite basic code running on an Arduino Mega 2560, and the output is looking like I have the serial settings wrong, though I can't work out what to change.
void setup()
{
  Serial.begin(9600);
  Serial.println("test123");
}

void loop()
{
  Serial.println("test" + millis());
}

The output looks like this:
ð¦·Z©÷
×ï¾üÿ7ß^|ïüûÿVÏuØëo~ìÿÓûzëýÿ{ßþ©×xñ×¤¿ïßûÏûýoÏ¿îãõI
õfwi÷`p¬½Ïª»QáÀª»¦·ð¦·Z©÷
test123
D

4ñjü¯÷~µÞMz¹Ý~¼
Ûþ}iû}ÒÖ¦Ç¿÷ÿÂï½Õ¾;îö

I'm using the inbuilt "Serial Monitor" in the Arduino suite with settings 9600 baud and no line endings.
I see that the first println in setup() is sending the data as expected but all other comms are coming through as nonsense.
Any suggestions of what to do?

This is unfortunately not valid in C++:
"test" + millis()

Rather than concatenating two strings, it's actually doing pointer arithmetic. It's taking the memory address where "test" is stored, and offsetting by the value retrieved from millis(). The result is a totally arbitrary memory location which gets treated like a string.
Generally speaking, it's arguably best to avoid string concatenation on Arduino anyway unless absolutely necessary. The reason is that it can use more memory than you might expect.
A simpler approach would simply be to do the serial output as a sequence of individual operations, e.g.:
Serial.print( "test" );
Serial.println( millis() );

Note the difference between print() and println(). The first one doesn't add a line break at the end, but the second one does.

Great, thank you. Can you also explain why string concatenation per http://arduino.cc/en/Tutorial/StringAdditionOperator isn't working how I expected it would in this instance, when one of their examples on the page is specifically stringThree = stringOne + millis();?

@bdx You can concatenate String objects like that because they overload the plus (+) operator. String literals in C/C++ (anything in double quotation marks "like this") work differently. You can read more about the difference here: http://arduino.cc/en/Reference/String

I see. My assumption that a string literal would create a String object was false, it creates a null-terminated character array, and the String type also has an overload on the = operator to coerce a char[] to a String.

You can explicitly construct a String object by doing this: String("test"). It uses more memory than a string literal alone though, so it's important to be careful how you use it.

Just as a minor addition to Peter's excellent answer and comments on concatenation and implicit typecasting with String objects:
Alternatives to construct the message (as a char[]) to be send might be:

use sprintf()

char buffer[80];  // for the complete output
char value[4];    // for millis(), which returns an unsigned long

sprintf(buffer, "I'm running for %u ms now", millis());
Serial.println(buffer);

Note that sprintf() uses quite some memory!

build the message 'manually':

 char buffer[80] = "I'm running for ";

 itoa(millis(), value, 10);
 strcat(buffer, value);
 strcat(buffer, " ms");
 Serial.println(buffer);


text:
Why does Arduino use USB A-B plug, instead of A to micro USB plug?
I understand that A-B plug used to be common but they could have switched to micro without issues.
My questions:

Why does Arduino use USB A-B plug, instead of A to micro USB plug?
What are the challenged Arduino would be facing if they switched to micro USB?

Note:
By "Arduino" I'm referring to Arduino models that do not come with a micro USB port such as the most common Uno & Mega.

Are you talking about any particular Arduino?

Arduino leonardo has a micro USB. What is your question?

Just a legacy thing. Micro usb didn't even exist until april 2007.

UNO was first released in 2010 I think.

Obviously I'm referring to Arduino models that do NOT come with a micro USB here. But I will edit nonetheless. Thanks.

Please note that this answer is based on speculation and some common sense rather than on insider information:
If you take look at the hardware index, you'll notice that significant parts of the layout (drill holes, pin spacing, and position and type of the USB jack) haven't changed between the Arduino Extreme and the current Arduino UNO R3), while other improvements have been made. For changes between the UNO R2 and R3, please see Arduino UNO FAQ at adafruit (link provided by jfpoilpret).
It is thus reasonable to me that keeping the USB jack was a deliberate design decision: Improve if possible, but keep the layout changes to a minimum and allow for maximum backwards compaptibility.
But again, this is just the guess of a user!

I am not sure, even including your comment, that it would consitute a serious answer to the question, it looks more like a lead to follow and check.

Then you should improve your answer by changing the question into something like "It is probably for backward compatibility between UNO revisions". You could even refer to https://learn.adafruit.com/arduino-tips-tricks-and-techniques/arduino-uno-faq#uno-r2-and-r3 which mentions backward comaptibility albeit it does not explicitly mention USB socket compatibility. Merry Christmas to you too!

That makes absolute sense @KlausWarzecha, thanks! And thank you as well jfpoilpret !

Durability is also a factor. The big standard USB-B is a lot more durable than Micro-USB. Though in practice it probably doesn't make such a huge difference, you don't connect/disconnect your Arduino THAT often.
But I guess its one of the components that could die first, if you don't built a bad circuit with your UNO, the connector could indeed die first after years and years of usage.


text:
How to rotate a servo continuously?
I'm new in robotics. I bought a mini robot ( Link ), which i rebuilt a little. Now it has legs and arms. This little robot has 4 little servos (Link). There are two wheels attached to two of these servos. I'd like to spin them, so the robot will "roll", but unfortinatly it is trickier than i tought. The servos can rotate in 360 degrees(i can manually turn them), no problem with that. The problem is, that no matter how i try, the servo will turn only 180 degrees. So obviously i am making something wrong. If i write myServo.write(0) the servo rotates 180 degrees, and if i write myServo.write(180), the servo rotates 180 degrees but in the other direction. How can i make it spin in only one direcvtion(360 degrees, more than 360 degrees)?
Thanks in advance!

Normally servos are not supposed to rotate continuously. However, now you can buy some "continuous rotation" servos that do. You can even transform your own servos into continuous (but this is not a super easy manipulation); check this link: http://www.instructables.com/id/How-to-modify-a-servo-motor-for-continuous-rotatio/

@jfpoilpret: thanks, but i think you misunderstand me. I can rotate the servo manually. So basicly it can be rotated continuasly, i just don't know how to code it. Or is there something else i need to do?

If this was a continuous servo, that would be indicated in the link you mentioned, and using Servo library would work with it, except that the value passed to myServo.write() would not specify an angle but a rotation speed, making it turn forever, until myServo.write(90). The fact you can force it turn more than 360° does not mean it can do it programmatically.

@jfpoilpret: thank you! I thought if i can turn it around manually means that it is a continuous servo. So i have to solder and hopefully it will work then.


text:
What are the benfits of global variables over static class members?
On an embedded system we use global variables often to keep dynamic memory consumption on heap and stack low. But global variables are also considered bad programming practice if they aren't used in a global sense, i.e. they are used only inside one or two functions.
So I really want to make use of the possibilites to protect my code from myself. Of course, the instantiation mechanism of c++ is to avoid on an embedded system with low resources, like an arduino. So I write classes with static members (and member functions) only. Many of the libraries shipped with arduino seem to work this way, too.
I'm curious if there's a single drawback of moving static variables or even const arrays (designed for deposit in progmem) from global namespace to a class namespace and making them private?
I'm primarily interested in drawbacks arising from the combination of OOP with the arduino platform (using an arduino uno) with avr-gcc.

I can see no specific drawback in using static class members instead of global variables on Arduino. They will be managed the same in the end program.
The only difference I can see may arise based on how you design your classes (if design is correct, then no special problem shall arise):
Let's suppose you decale a class A:
class A {
    public:
    void f();
    void g();
    ...
    static void z();

    private:
    static int myStaticField;
    ...
};

if you need an instance of A for method f(), which does not need myStaticField, then that field exists anyway in your SRAM space.
But this is a corner-case, as in good OOD, myStaticField should be needed as soon as you need to work with class A (whatever method youwant to use).

But if I make instances of A, myStaticField will get reserved in RAM (or wherever) once only, won't it?

Yes, of course, that is the difference between static and non static members.


text:
SD Initialization Failing
I am using a SEEED SD Card Shield. Everytime I attempt to write the card, I get
When Using File> Examples> SD > CardInfo:
initialization failed. Things to check:
* is a card is inserted?
* Is your wiring correct?
* did you change the chipSelect pin to match your shield or module?

Or when using File>Examples> SD> Files:
Initializing SD card...initialization failed!

I even tried SdFat (IDE couldn't find anything), the "SD Library" by Adafruit (No change), and other things.
I'm using a Funduino MEGA 2560. Could that be the problem?!

Are you using an Ethernet shield as well? I have had problems with chip select line definitions on a Freetronics EtherMega2560 which is basically a standard 2560 with an inbuilt Ethernet shield.

I also use a Seeed Studio SD Shield, and used to have the same problem. To rectify this I have to insert the SD card into my PC and Format it. This almost always helped. If you have a card that has too large of storage, the Arduino will take too much time to check the full memory for information stored on it (initialize). Some SD card readers require a card of 2 gigabytes or less to work. Check the Data Sheet for this limit (if there is one). That should do it for you.

I spent ages failing to get my SD card working. Then installed an earlier version (1.0.8) of the SD library which fixed the issue for me.


text:
Photoresistor is not working, is there something wrong in the code?
I am trying to make the photoresistor work in a simple project.
The project is as follows:
The LED light should light up brighter and brighter as the photoresistor reads less light in the room.
The problem:
The reading is fixed on 1023. Therefore the LED never lights up. I cannot understand why.. Sometimes if I cover the sensor the readings go down to 900- 950 but never less even though it is completely dark around the sensor. Is there something wrong in the code? What could have gone wrong?
Please note that the resistor connected to the sensor is 10k Ohm as is the one connected to the LED.
Here is the code
int photoPin = 0;
int pReading; // analog readings

int LED = 11; // red LED connected to pin 11
int LEDbrightness; //

void setup()
{
  //set up the serial connection
  Serial.begin(9600);
}

void loop()
{
  pReading = analogRead(photoPin);
  Serial.print("Photocell reading = ");
  Serial.println(pReading); // Analog reading

  pReading = 1023 - pReading;
  //map 0-1023 to 0-255
  LEDbrightness = map(pReading, 0, 1023, 0, 255);

  analogWrite(LED, LEDbrightness);
  delay(50);
}

Here are the connections

thank you!

The code looks OK. It looks like it's your circuit which is the problem.
The main role of a photoresistor is to restrict the amount of current flowing through it when the light level is reduced. It won't directly affect voltage the way you're expecting (the analog pins respond to voltage).
However, it's pretty easy to make it affect voltage with a slightly different circuit. Try creating a voltage divider circuit, such that the supply voltage (5V) goes through the photoresistor, then through another resistor, and then to ground. The Arduino's analog pin should be connected between the photoresistor and resistor. (See the image below, although the resistor on the output probably isn't necessary in this case.)
This should cause the voltage on the analog pin to decrease when the light level decreases. You may need to experiment a little to find a suitable resistor value on the ground connection, although 2K Ohms is probably a good starting point. It basically affects the sensitivity of the circuit.

Image credit: Morteza Lahijanian (source)

Thanks, your comment was very useful, I fixed the problem using the circuit you suggested and everything works! thank you very much!

Your wiring is wrong.
Analog inputs are high impedance and probably the impedance isn't really linear. So what voltage do you expect on your analog input, if its inner impedance is one or more orders of magnitude greater than that of your sensor and series resistor?
The inner impedance builds up the lower part of a voltage divider and your sensor and series resistor the upper part. The voltage measured will almost anytime almost 5V.
How to fix this?
You will have to make a suitable voltage divider outside your arduino. Simly connect your input via another resistor to ground. So, how to determine the right value of the additional resistor? It strongly depends on your sensor and the brightness range you want to perceive. I recommend starting with 1kΩ. Let us know,
what your readings are for full light and darkness. Then we can give some more hints.


text:
Arduino Yun RFID-RC522 module not working
I have tried to use Arduino Uno with RFID-RC522 module. It is good work[1] and read rfid cards. But Arduino Yun doesn't work with RFID-RC522 module.
What is diffrent Uno and Yun?
1- http://www.grantgibson.co.uk/2012/04/how-to-get-started-with-the-mifare-mf522-an-and-arduino/

According to the link you provided, we can see that the RFID-RC522 uses SPI to communicate with Arduino.
On Arduino UNO, the SPI pins are located as follows:

pin 11: MOSI,
pin 12: MISO,
pin 13: SCK

On the Arduino YUN, this is different though; as stated there (bold highlight is mine):

SPI: on the ICSP header. These pins support SPI communication using
  the SPI library. Note that the SPI pins are not connected to any of
the digital I/O pins as they are on the Uno, They are only available
  on the ICSP connector. This means that if you have a shield that uses
  SPI, but does NOT have a 6-pin ICSP connector that connects to the
  Yún's 6-pin ICSP header, the shield will not work.

Hence you can not wire the RFID-RC522 module the same on UNO and Yun.
For the Yun, you'll have to follow this wiring picture:

Pin 1 in image above is the pin that is marked with a dot on the Yun PCB.
Also see the ISP-header layout, at the lower-right corner of the yun_by_pighi Yun pinout diagram.

I wired as described, (but I wired the 3.3v on the rc522 to the 3.3v on Yun, not the icsp pin because apparently the voltage isn't specified in icsp .) Unfortunately even after installing the library, successfully uploading their example, it doesn't seem to do anything - only shows a red light on the device, and blank serial monitor when tag is right on it. I think there's a step missing somewhere here.

I had the same issues Thanks for help .However I made the  following connections then above mentioned
RC522 RFID borad     Arduino YUN  (as per the github example code dumpinfo)
chip select (nss ) - Pin 10
Rst                - Pin 9
Link for Gihub RFID RC522
Hope it helps someone who is stuck


text:
arduino wifi shield not present error
I'm using an HLK-RM04 WIFI shield and arduino uno R3 board. whenever I mount my shield on the uno board and connect it to the pc using a usb only the power led(red) of my wifi shield glows. I tried to upload the example code on wifi(provided by arduino)but whenever I run the code it shows "wifi shield not present". Looking into the previous discussions on this website I even tried to connect my arduino with usb+9v supply. In that case my trackpad of the laptop ceases to work. whenever I power my system(arduino+shield) using a 9v external supply all the 3 leds(power,link,wan led) on my wifi shield glow but still the same error of "wifi shield not present" persists.
What is going wrong?
Has anyone configured an HLK-rm04 wifi shield with uno r3 before?
Thanks

unfortunately i gave up using hlk-rm04 wifi module for my application.
it was too power hungry and there was very little online help available.

I DON'T have experience with the shield you are mentioning, but it sounds to me that no data is being sent from the WiFi shield to the Arduino.  I suggest you do a bit of debugging with:
1) Print Statements
2) A multimeter (better yet, an oscilloscope)
3) Check that the pins you are connecting the shield to are not blown

Welcome to Arduino SE! Can you expand your post a bit to explain how to use these to debug the problem of the OP? To me, it doesn't seem like these would fix a computer error, but feel free to elaborate on how this would help. Thanks!

Might be because of a non-compatible version of the Arduino IDE? (latest version isn't always the fittest, apparently).
I found evidence for this weird behavior in various forums around the web - even when using the Uno R3 board with its official WiFi shield, I had to go back to version 1.0.3 of the Arduino IDE (and to flush its compatible firmware version for the WiFi shield) in order to get the sample code to work. Later versions just didn't work!

Welcome to Arduino SE! Do you have any evidence that this works for wifi shields? If so, can you please edit your post? Thanks!

Yes I do have, but I couldn't comment in the original post :(

Ok, if you have evidence, can you please edit your post? Thanks.

Is it ok now? :)


text:
Arduino Pro Micro clone not recognized, flickering RX LED
I have an Arduino Pro Micro clone that seems to be in some sort of reset loop. The RX LED is flickering very fast and very dim. The power LED also seems to flicker at the same frequency but has normal brightness.
The Arduino is not recognized by the PC at all anymore. It was working fine before. It doesn't matter if I try to go into the bootloader, by pressing reset twice, or not. Nothing happens. It feels like it is constantly resetting. The flickering stops if the reset pin stays connected to GND.
Another clone from the same shipment is still working fine. Both running the blink sketch. Just this one started to malfunction all of the sudden - after probing the pin I set in the blink sketch with my multimeter to see if the flashing was a success.

See if it's bricked. I put this on YouTube last month http://youtu.be/RZH_qGautqM

It's an Atmel with USB onboard, not usb to serial chip in between.

I've heard of a fix where you hold down the reset button until right before the Arduino uploads. The goal is to catch it in the bootloader state before it starts the sketch. You might need to try it a few times...

Well the PC doesn't even recognize it so I can't upload anything.

When  you say the PC doesn't recognise it, do you mean that you get the USB device not recognised message in the system tray, or do you get nothing at all on the PC end, if you hit reset for example?

Nothing at all. Windows sees nothing connected to the usb cable.

But, can't you use other Arduino or FDTI USB brick to upload code via serial link (I'm talking from distant memory.) i.e. to use the method you would otherwise use to upload Arduinos having no usb port (like Mini)

It has native USB, it doesn't recieve code via UART

If your pro micro does not have a reset button, wire one between reset and ground.
Press reset twice, quickly, and immediately hit upload on the IDE.
Secondly, make sure you've downloaded and installed the Sparkfun board files for the pro micro.

I can't upload anything as the board is not recognized in Windows. Doesn't matter in which mode the board is in.

You've installed he Sparkfun boards as well?

Yes but that wouldn't make a difference, thats just description files. The problem ist that the serial device is not coming up at all. The usb communication part is completely dead.

+1 for the Sparkfun Pro Micro board files. I did wonder why the board wasn't listed in the Board menu.

I bricked my Pro-Micro within ten minutes of ripping it out the packet. I didn't realise that (a) it's not so brilliant on USB 3.0 - or in my case, unuseable, and (b) it's not actually an Arduino board - the Pro-Micro is a SparkFun product, and any clones thereof are from SparkFun's schematics.
The latter was only a problem to begin with, while I was scrabbling around on the Arduino website in vain trying to find answers. Once I realised to visit SF's website everything calmed down. Read this section on bricked/unrecognised pro-micros, and then have a look at the rest of the page as further reading.

Tried that but unfortunately the Pro Micro doesn't stay in bootloader mode nor does it ever connect to the PC when trying that double click reset.

+1 for the link, very informative. I have the same issue, a bricked Pro Micro. All three LEDs are lit (Rx, Tx and Power). I can get mine into the 8 seconds bootloader mode, but the IDE won't upload Blink on to it.

Try this: unplug the Arduino, hold down the reset button, and then plug it in to power. Hold down the reset button a few seconds after you power it on. If this works, you should get the "blink" sketch, and be able to reprogram it.
Alternatively, if you have an ICSP programmer (I use the FreeTronics USBASP), plug this in (you will need to wire up the appropriate 6 pins), and then use the Arduino IDE to burn the bootloader - select the board, serial port, and programmer,then select "burn bootloader" - all from the "Tools" pull-down menu.

The holding of the reset button down doesn't seem to work for me. Do I keep it held down during the uploading? If not, at which point should I release the reset button? I'm going to have to resort to using my USBasp I think. Also, for a Pro Micro 3.3V, I will need to reduce the voltage levels, I guess. The USBasp => Pro Micro connections are as follows: MOSI = 16, MISO = 14, SCLK = 15, RESET => RST, plus Vcc and GND obviously.

Try this:

Connect a push button switch to ground and reset (RST) pin;
Click upload then push the button twice (fast) = it doesn't matter if your computer does not recognize the pro micro;
Repeat this if it failed (repeat until you are successful).

After this the Pro Micro port will comeback to life.
I tested it. The reason I think that you bricked it, is because you uploaded using the wrong board setting - commonly the 3.3 V and 5 V (or vice versa)

This is a very common problem. See my answer to Arduino Micro just blinks, won't connect to PC.
As Asenkhan says in his answer, it is often caused by attempting to upload to a Pro Micro using the wrong board setting 3.3 V en lieu of 5V, or vice versa.

I have written two lengthy blogs about the whole experience:

The case of the broken Pro Micro
The case of the broken Pro Micro (reprise)

This does help but unfortunately not for this one. I could revive another Pro Micro that I programmed with the wrong settings using that method but in this case, no matter how often I try, it does not go into bootloader mode. I have the feeling something is causing it to constantly reset, hence the flickering that only stops when I keep the reset pin connected to GND.

@ProfessorSparkles - Hmmm, that does sound unusual. Sorry, that I couldn't help.

You can make it work but only if you use a ISP programmer and burn the bootloader. The internal serial programmer would not work still some HID functions are retained. To me everything works fine except the Mouse functionality.
This a pain in the acc* but it will work for other options. The other thing I have not tried is setting an old arduino ide and use the old addon for pro micro board to see if there a was a change in those files that caused it to fail.
So my next step would be as follow:

Setup the old arduino environment, download the old addon files and burn the bootloader.

Edit: While writting my findings I came with the solution. Just as I thought! You need to use the old files to make this work completely.
Steps:
You'll need to buy an ISP Programmer for burning the bootloader or use another arduino board as an ISP Programmer
I used the USBtinyISP Programmer. In specific:

Download the old sparkfun files (zip) version
Sparkfun Old Addon Files
Download the old Arduino IDE - I used the 1.0.6 portable (zip) version
[Old Release Files] (https://www.arduino.cc/en/Main/OldSoftwareReleases#previous)
Extract the Arduino IDE to Desktop. After doing so open the Sparkfun addon zip file and extract it to the Desktop. Then rename the extracted folder from:

SF32u4_boards-pre-1.6

To

sparkfun

Alright copy that folder and if you do as I mentioned above now you'll head for the Arduino IDE we just downloaded. When you see the arduino files move into the hardware folder and paste the sparkfun folder inside of it (don't navigate any further than this).
Then connect the ISP following this diagram: Always double check the connections!

Now the next steps would be:

Open the Arduino IDE v1.0.6
Select your programmer under Tools (mine was USBtinyISP)
Select your Sparkfun Pro Micro board either the 3.3v or 5v version
Now under Tools select Burn Bootloader

If you do this right after a couple of seconds or minutes you will see a message that the process of burning the bootloader was completed. Depending on your hardware speed, if you store things in a flash drive or system is running on a linux live session you will need to wait a bit so just relax.
If things go according to plan then you can disconnect the ISP programmer and upload a simple sketch to corroborate the board is now working.
int ledPin=10; // let to pin 10

void setup() {
   pinMode(ledPin, OUTPUT);
}

void loop() {
   digitalWrite(ledPin, HIGH);
   delay(1000/2); // 1/2 a second
   digitalWrite(ledPin, LOW);
}

Upload as you normally would! Double check the board version!!
Perfecto! If the steps were followed in order you'll now have a working device

It can be problem with bootloader.
You can try to burn bootloader again.
See for example:
http://angryelectron.com/how-to-update-the-bootloader-on-arduino-pro-mini-328/
Or use google

-1 Because it's a Pro-Micro - with an ATmega32u4.


text:
Attiny85 and 433Mhz RF
I have this cheap RF link that I had working with the Arduni UNO, but I wanted to make it smaller and ATTiny85 should do the trick. The RF module is connected (data pin) to PB3 on the ATTiny.
But I am having some problems. It does not work, and I don't know why. My code:
#include <SoftwareSerial.h>

// PINS
#define SERIAL_TX PB3

SoftwareSerial mySerial(-1, SERIAL_TX);

void setup() {
  pinMode(SERIAL_TX, OUTPUT);
  mySerial.begin( 1200 );
}

void loop() {

  mySerial.write(0xAA);
  mySerial.write(0xAA);
  mySerial.write(0xAA);

  delay(1000);
}

The code you presented does not fit for working with the RF 433Mhz. I'm not sure what you think this code should do, but this is not the way to go with a 433Mhz transmitter.
I would suggest using a dedicated library for transmitting information using the 433. There are many libraries out there for doing that; two popular libraries would be the ManchesterRF and the VirtualWire, both includes code samples.
For example, sending data with ManchesterRF:
#include "ManchesterRF.h" //https://github.com/cano64/ManchesterRF

#define TX_PIN 3 //any pin can transmit
#define LED_PIN 13

ManchesterRF rf(MAN_4800); //link speed, try also MAN_300, MAN_600, MAN_1200, MAN_2400, MAN_4800, MAN_9600, MAN_19200, MAN_38400

uint8_t data = 0;

void setup() {
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, HIGH);
  rf.TXInit(TX_PIN);
}

void loop() {

  rf.transmitByte(++data, data*data);
  digitalWrite(LED_PIN, digitalRead(LED_PIN)); //blink the LED on receive
  delay(100);
}

In addition, there are many other blogs around going step-by-step how to use 433Mhz Tx/Rx with ATtiny85, google is your friend :)

Hi Omer, thanks for your reply! I tried the Manchester, but it outputs error when I try to compile it: "Manchester library doesnt support your microcontroller"

see this project as an example for working with Manchester and ATTiny85: http://m.instructables.com/id/Attiny85-RF-Transmitter-to-Arduino-Uno-Receiver-Ma/

I've just deployed the code on my UNO (I was using it as a programmer for the ATTiny85) and on the UNO i works like a charm. I've my own dataprotocol, so the problem here is getting the ATTiny to do serial with the SoftwareSerial on PB3.

In that case, I suggest you edit your question strictly to SoftwareSerial, or ask another question. My answer apply to 433Mhz and ATtiny which I've done many times before.


text:
Arduino UNO GPS module
I am thinking about buying a gps module for Arduino UNO.
I would like to install it on a self-build RC-car which is also controlled by Arduino.
The problem is, I cannot install the gps module on the top of the car (on the surface), only the bottom and or/middle space is "free".
My questions are:
1)Is there a module which can overcome a small layer of steel (max 2cm thick) and some plastic and still get a good signal?
2)It would be nice to be able to store the data into a memory card.
3)It would be a great plus to be able to gather data real-time through some kind of connection. Sadly I do not know how to do here. Is there some place where I can look up any of this?
Do you think that this http://www.adafruit.com/products/1272 is what I need?
thank you

1) Just break out the headers on the GPS module to make for connections to the UNO.
2) Add a SD expansion slot on top of the GPS Module and break out the pins for those as the required pins for those as well.
3) I am not sure what you are asking exactly, but it seems to me that you want to analyze the data real-time.  Get a network shield and make sure you can SSH into it through another computer.
Note: When I say "break out the pins", I am simply saying either solder on some extra headers, or wires.


text:
Powering Arduino from a shield
I'm designing a shield for Arduino which drives two stepper motors. They are small and require 5V but their max combined current is around 1A, way too much for the USB supply. Therefore I will have external 5V power supply connected to my shield.
The entire device will usually operate being connected to a PC through USB, but still I'd like to have a possibility to run it separately.
The question is: how to power Arduino itself?

From my external PSU through the pins: Sounds as the simplest solution but I'm bit worried about the onboard regulator of Arduino while reverse powered.
Separate power circuits for electronics and motor: My L293D chips allow for separate power and even different voltage for the motors. It could even be an advantage for my shield, as I could use other motors and different power for them in the future. I will, however, lose the possibility of running the device without USB connection.
Same as above with additional barrel jack power connection to supply Arduino when USB is disconnected. This, however, could fail with 5V supply, because of the voltage drop of the regulator which handles power coming from barrel jack.

Option 1 is by far the simplest. Just have one 5V power supply for everything.  Make sure you have enough capacitance on there to absorb the noise of the motors - maybe separate the digital side from the drive side with an inductor.
You can add a diode connected backwards between the 5V and VIN pins to bypass the regulator when reverse powered.  That is, anode to 5V and cathode to VIN.

What I am doing for similar is powering 7.2v to motorshield EXT_PWR and same to RAW pin of Arduino mini pro, where taking 5v out from vcc and input to motor shield 5v. It works for my car well.


text:
Daisy Chaining USB Communication over Arduino Due
I have two Arduino Due boards. I would like to connect one to my computer through the programming port as USB Serial so that I can send it commands, but I would like it to also be able to communicate to a second Arduino Due as the host on the native USB port.
I see in the manual that it has drivers for acting as a host to USB Mice and Keyboards, but is having it load appropriate drivers for communicating with another Due doable? I've done plenty with the USB ports, but never as a host so I'm not really sure how to start.
The goal is to have one "master" Due connected to the computer that controls a complicated piece of equipment with a lot of supporting electronics, and a second "peripheral" Due that acts as an interface for the user. The master would accept commands either from the computer, or from the peripheral. Reason is that the peripheral has to have fast interrupts to handle rotary encoders and the like (the "master" Due is quite busy so those interrupts can be troublesome) and be physically located in a different place.

Have you considered exposing one of the USARTs over USB, and connecting it to the other Due?

Using Serial (UART) or SPI would be a lot easier, and less burdensome on both the Arduinos


text:
Is SoftwareSerial left out for the ATTiny85/84?
I want to use SoftwareSerial with my ATTiny85 and when I google it several projects claim that they are using it... I downloaded the hardware from https://code.google.com/p/arduino-tiny/, but when I try to add SoftwareSerial and compile I get:
fatal error: SoftwareSerial.h: No such file or directory

Switching the board to UNO makes the problem go away, so did they leave it out? How can I fix this?

Cannot duplicate.

I did duplicate with Arduino IDE 1.6.3 and found an answer (below).

Short answer - no. It's not left out, on the contrary.
But before addressing to the compiler error you mentioned, a small clarification:

I downloaded the hardware from https://code.google.com/p/arduino-tiny/

The link you provided is not hardware, but software called the ATtiny core files. It contains the necessary files that will help you compile and upload code from Arduino IDE to the ATtiny (even when using ArduinoISP as programmer).
The SoftwareSerial is a library that comes with the Arduino IDE zip/installation. If you have downloaded the latest version of Arduino IDE from the Arduino Website, you should be able to find the SoftwareSerial library files located at:
[Path to Arduino installation folder]\libraries\SoftwareSerial

Example for SoftwareSerial library files you should expect to find there are SoftwareSerial.cpp and SoftwareSerial.h.

fatal error: SoftwareSerial.h: No such file or directory

The compiler error you receive seems to imply that the compiler cannot find the header file (SoftwareSerial.h) for SoftwareSerial library. This indeed seems quite odd, since this library does not require any special installation, and as mentioned, is part of the libraries that are built into the Arduino IDE installation.
So, to mitigate this, I would recommend that you will:

Make sure the library folder exists in the location mentioned above
If it doesn't, then you should probably re-download the Arduino IDE installation, and after that install the ATtiny core files as per the instructions (important!). Installation instructions are located in the README file inside the ATTiny core zip file
(tiny\avr\README).
If it does exist, and you still get this compiler error, then you must have a corrupted installation (perhaps the compiler include folders is messed up). I would still recommend following the re-installation as mentioned in the previous bullet.
Make sure that you can find the ATtiny 85 in the board list, at Tools->Board and that it is selected.
Another angle that might shed more light on this error, would be to turn on the verbose output for the compiler (you can do it in the Arduino IDE, by choosing File->Preferences-> "Show verbose output during" and checking "compilation"). Verbose output can help you track down any compiler command line errors, like missing include folders.
Last but not least, if the SoftwareSerial folder exist, you could use the Arduino IDE to check if the IDE can identify its existance, by going to Sketch->Import Library, and looking for SoftwareSerial. If it's not there, then the folder is not located properly under the 'libraries', verify the path as mentioned above (did you move it?)

Finally, when you will be able to compile your code, try using the SoftwareSerial example that comes with the library to check it. Note that it is not going to work 'out-of-the-box' as with the Arduino Uno; The ATtiny does not have the same FTDI hardware for communicating directly with USB, so for sending and receiving serial messages using the ATtiny you will have to either use the Arduino Uno as a proxy (using the Uno's pins 0 & 1) or to use dedicated USB to Serial hardware similar to this one.

Switching the board to UNO makes the problem go away

As a side note, switching to the Uno will make most ATtiny problems 'go away' since the Uno is much more equipped than ATtiny85/4, both on the MCU level and on the breakout board level, which you get with the Uno (and which you don't get when working directly with a chip like ATtiny). Also, most of the code base out there is targeting the Uno and not ATTiny.
So if you are doing your first steps with the ATtiny, be prepared that many things that 'just worked' with the Uno will require extra/different code before they could work with the ATtiny (and some won't work at all).
You can use my simple Analog to Serial code :
/*
Takes an input on the AtTiny85 from the VERY TRICKY analogue input pin 2 (as labeled in HLT tutorial)
 and outputs these with Software serial to the arduino uno, or Duemillanove
 Hookup
 ATTINY85 pin 3 -> Arduino Uno pin 0
 ATTINY85 pin 4 -> Arduino Uno pin 1

http://www.instructables.com/id/Easy-ATTiny-Serial-Communication-with-Tiny-AVR-Pro/
 */

#include <SoftwareSerial.h>
// Definitions
#define rxPin 4
#define txPin 3
SoftwareSerial mySerial(rxPin, txPin);
int sensorPin = 7; //ACTUALLY PIN LABELED AS "2" on the HLT tutorial
int sensorVal = -1;

// the setup routine runs once when you press reset:
void setup() {
  pinMode(sensorPin, INPUT);
  mySerial.begin(9600);
analogWrite(0,1); // This is kind a heart beat to show the ATTINY is "alive"
}

// the loop routine runs over and over asensorpingain forever:
void loop() {
  sensorVal = analogRead(sensorPin);
  mySerial.print("Input Val: ");
  mySerial.print(sensorVal);
  mySerial.println();
}

Below you can find the code for a minimal bit-bang send serial implementation ideally suited for debugging. Code size is about 60 bytes.
It gives 38400 baud for 1 MHz or 230400 baud on 8 MHz Attiny clock.
I wrote it for an Attiny 85.
ArminJo/AttinySendSerial_1Mhz_38400Bd

Yes, in IDE 1.6.x, libraries are defined "per board", they reside in special folders and are provided by the atuhor of the board-bundle.
Digispark's library is named SoftSerial and is included. In IDE Check File/Examples/DigisparkSoftSerial. Also check https://digistump.com/wiki/digispark/tutorials/debugging
In short, you have to include:
   #include <SoftSerial.h>
   #include <TinyPinChange.h>

and then define RX and TX pins (could be also the same in special cases):
   SoftSerial mySerial(SOFT_RX_PIN, SOFT_TX_PIN); // RX, TX

Then use mySerial.println() & co.

will it allow to use more than one serial?

I had the same problem and it appears that with Arduino IDE 1.6.x, libraries are defined "per board" and not shared any more.  At least, not all libraries are shared, and SoftwareSerial appears to be one of those.
So the solution is to copy the SoftwareSerial library from the Arduino installation at [programs]/Arduino/hardware/arduino/avr/libraries/SoftwareSerial to your ATTiny hardware folder at [documents]/Arduino/hardware/tiny/avr/libraries/SoftwareSerial, and restart the IDE, as per [this thread].1


text:
5 Switches 1 AI pin
Im starting to get into Arduino a little. Ive got a Small project to start me off,
To keep it simple its: 5 level Switches, 1 flow switch and 3 solenoid valves.
This question is for the Level Switches.
Now Im wanting to save Pins as I'm using a Arduino UNO.
So would I be right to use the method ive seen around here a few times of Making a Resistance  ladder.
Question is. 1- Will the method of using the same value of resistors (2k2) work? I dont think so..
As multiple "buttons" ie the flot switches will be pressed at once it will end up having no idea whats happening correct?, I need to be able to Identify each one (0%,25% etc etc)
If I was to use different vales of resistance would that make a difference ?
Cheers

Just look at this answer. When you press the LEFT switch, the SELECT button has no effect when pressed (i.e. it doesn't get detected, but also doesn't hinder detecting the LEFT button press). So in your case, you aren't really interested in the 0% button, when the 25% is pressed.
I wouldn't use same value resistors, as the resulting voltages would be non-linear, making it difficult to differentiate between the button at the far end ladder. If you'd use 2k2 everywhere, the voltages would be

100% 0.00v
75% 2.50v
50% 3.33v
25% 3.75v
0% 4.00v
no value: 5v

In the answer provided above, voltages would be: 0, 0.71, 1.61, 2.47, 3.62, 5v


text:
Audio Frequency White Noise generation using Arduino Mini Pro
For DIY, how to program Arduino Mini Pro to act as an Audio Frequency White Noise generator?
Presumably,
a) using one Digital Output pin
b) feed to a simple passive RC low pass filter to reduce out of band signal
c) feed to a simple class-D IC chip audio amplifier and speaker
d) since it is DIY and noise, lo-fi (not hi-fi) is good enough.
Specific questions,
a) How to program?
b) Wonder if it is better to use to chip act a Pulse Width Modulated 'digital to analogue converter'?
c) How to calculate value for RC filter (assume amplifier has high input impedance)?
Many years ago, I have programmed a hardware sound generator chip as part of a game machine. It has two registers for amplitude and 'frequency' control (band of 'white' noise). It worked very well. I once looked at the output using oscilloscope and it was square wave. I believe that it works, basically, using the above principles. Since I do not have the chip now, I cannot verify it. Now, I would like to duplicate its function using Arduino in software.

I don't know that you need all that - just an Arduino and a piezo speaker and a pot if you want to play with the volume.
byte speakerPin = 1;

void generateNoise() {
  static unsigned long int reg = 0x12345678; //seed
  unsigned long int newr;
  unsigned char lobit;
  unsigned char b31, b29, b25, b24;
  b31 = (reg & (1L << 31)) >> 31;
  b29 = (reg & (1L << 29)) >> 29;
  b25 = (reg & (1L << 25)) >> 25;
  b24 = (reg & (1L << 24)) >> 24;
  lobit = b31 ^ b29 ^ b25 ^ b24;
  newr = (reg << 1) | lobit;
  reg = newr;
  digitalWrite (speakerPin, reg & 1);
  delayMicroseconds (50);  // Changing this value changes the frequency.
}

After reading your answer, I did some searching and realize that your answer is based on, quoted from wikipedia, "pseudo-random binary sequence (PRBS) generated by a linear feedback shift register (LFSR)". Any pointers to non-pure-maths (and simple) information on how to choose the "polynomial" (bit 24, 25, 29 and 31 in your example) so as to achieve the white-noise property?

The https://en.wikipedia.org/wiki/Linear_feedback_shift_register article points to tables of good polynomials for different bit-length shift registers at http://www.xilinx.com/support/documentation/application_notes/xapp052.pdf .  The main difference between a good polynomial and a less good one is whether the length of the cycle until it repeats is as long as possible (2^n-1 is the max).  http://users.ece.cmu.edu/~koopman/lfsr/index.html points to a table with 67,108,864 equally good 32 bit alternatives.

I think you need to edit unsigned long int newr; to be unsigned long int reg, newr; (and add const int speakerPin = 8;)

I'd really like to understand this anwser, but there is no explanation as to whats going on here. I don't know what the "reg" keyword is, nor what these bitwise operations are accomplishing, or why they aren't just defined, as they appear to be constants. On an Arduino, how is this better than using the "random" function with the values between the min and max frequency?

Also the shift register reg must be (a) defined as either a global or as static and (b) assigned an non-zero value. I used global: uint32_t reg = 0xfeedfaceUL ; . The solution in the answer by Dave X works without changes.

Mike's answer uses a Fibonacci Linear Feedback Shift Register configuration, but the compactness Galois Linear Feedback Shift Register Configuration could be faster:
#define speakerPin 8

unsigned long lastClick;

void setup() {
  // put your setup code here, to run once:
   pinMode(speakerPin,OUTPUT);
   lastClick = micros();
}

/* initialize with any 32 bit non-zero  unsigned long value. */
#define LFSR_INIT  0xfeedfaceUL
/* Choose bits 32, 30, 26, 24 from  http://arduino.stackexchange.com/a/6725/6628
 *  or 32, 22, 2, 1 from
 *  http://www.xilinx.com/support/documentation/application_notes/xapp052.pdf
 *  or bits 32, 16, 3,2  or 0x80010006UL per http://users.ece.cmu.edu/~koopman/lfsr/index.html
 *  and http://users.ece.cmu.edu/~koopman/lfsr/32.dat.gz
 *  or generate a one with https://github.com/hayguen/mlpolygen
 */
#define LFSR_MASK  ((unsigned long)( 1UL<<31 | 1UL <<15 | 1UL <<2 | 1UL <<1  ))

unsigned int generateNoise(){
  // See https://en.wikipedia.org/wiki/Linear_feedback_shift_register#Galois_LFSRs
   static unsigned long int lfsr = LFSR_INIT;  /* 32 bit init, nonzero */
   /* If the output bit is 1, apply toggle mask.
                                    * The value has 1 at bits corresponding
                                    * to taps, 0 elsewhere. */

   if(lfsr & 1) { lfsr =  (lfsr >>1) ^ LFSR_MASK ; return(1);}
   else         { lfsr >>= 1;                      return(0);}
}

void loop() {
      /* ... */
      if ((micros() - lastClick) > 50 ) { // Changing this value changes the frequency.
        lastClick = micros();
        digitalWrite (speakerPin, generateNoise());
      }

}

For a 16 bit implementation (faster, but only a cycle of 2^16) try:
#define LFSR_MASK 0x8016
static uint16_t lfsr = LFSR_INIT;  /* 16 bit init, nonzero */

Written in a more compact form:
#define speakerPin 8

#define LFSR_INIT 0xfeed /* non-zero seed value for generateNoise() */
#define LFSR_MASK 0x8016 /* magic number from http://users.ece.cmu.edu/~koopman/lfsr/ */

unsigned long lastClick;

void setup() {
  // put your setup code here, to run once:
   pinMode(speakerPin,OUTPUT);
   lastClick = micros();
}

unsigned int generateNoise(){
   // Return 1 bit of noise using a Galois Linear Feedback Shift Register
   // See https://en.wikipedia.org/wiki/Linear_feedback_shift_register#Galois_LFSRs

   static uint16_t lfsr = LFSR_INIT;

   if(lfsr & 1) { lfsr =  (lfsr >>1) ^ LFSR_MASK ; return(1);}
   else         { lfsr >>= 1;                      return(0);}
}

void loop() {
      /* ... */
      if ((micros() - lastClick) > 50 ) { // Changing this value changes the frequency.
        lastClick = micros();
        digitalWrite (speakerPin, generateNoise());
      }

}

For an 8 bit implementation (faster than 32 bit, slightly slower than 16, but only a cycle of 2^8) try:
#define LFSR_MASK 0x8e

static byte lfsr = LFSR_INIT;  /* 8 bit init, nonzero */

Where the mask constants are from the 8.txt and 16.txt files at http://users.ece.cmu.edu/~koopman/lfsr/index.html
The https://github.com/hayguen/mlpolygen program can search for maximum length feedback polynomials of various bit sizes.

be great for this to have more comments on this code to explain whats going on here for people still learning bitwise. I'm getting throw off because if "lfsr" is defined by the constant every time the function is called and then bitwised by another constant, how is this generating random numbers. why is the definition for LFSR_MASK so complex if its just a constant? please help?

@dprogramz: In C, the static keyword in the declaration protects against just what you are worried about--the initialization with the constant only happens once on the initial declaration of the function, and the changing lfsr state is maintained through successive calls to the function.   The bit-shifting definition of LFSR_MASK looks complicated, but it is easier to check, explain, change, and maintain than constants like 0b10100010100000000000000000000000UL  The actual selection of the mask is more complicated, so see the refs.

Thanks for the reply, that makes total sense now. I had a misunderstanding of the use to the Static keyword, but it's much more clearer now how it functions, thanks again!

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


text:
too few arguments to function 'void setColor(int, int, int)'
When I put "c" inside setColor(c);
it tells me:
error: too few arguments to function 'void setColor(int, int, int)'.

I understand that I should put 3 arguments. What I don't understand is that the serial is correctly displaying the 3 arguments (255, 000, 000) so why it keeps telling me this error. What am I doing wrong ?
int rPin = 11;
int gPin = 9;
int bPin = 10;

void setup() {
    Serial.begin(9600);
    pinMode(rPin, OUTPUT);
    pinMode(gPin, OUTPUT);
    pinMode(bPin, OUTPUT);
}

void loop() {
    if (Serial.available() > 0) {
            delay(100);
            while (Serial.available() > 0) {
                char c = Serial.read(); // serial will display an rgb code, for exemple: 255, 000, 000 (red color)
                setColor(c);
            }
        }
}

void setColor(int red, int green, int blue) {
    analogWrite(rPin, red);
    analogWrite(gPin, green);
    analogWrite(bPin, blue);
}

You understand that c can only contain a single character, right?

c is what the serial is displaying, in this case an rgb code like 255, 000, 000 am I wrong ?

In the context of C/C++, the type char refers to a primitive type that can contain exactly one byte of information, or 8 bits if you like.

the serial is correctly displaying the 3 arguments (255, 000, 000)

In your question, you do not specify how you verify that this is indeed the information that returns from Serial.read. Serial.read returns one byte, which can be cast or parsed to an Integer but cannot be interpreted as the triplet (255,000,000) in no way. If you keep calling it repeatedly, however, as long as there is data (meaning that the result is greater than -1 or Serial.available returns a number greater than 0) - you can accumulate the characters to a meaningful string, which you can later split to three different int values. For example:
String incomingData = "";

void loop()
{
    if (Serial.available() > 0) {
         delay(100);
         while (Serial.available() > 0) {
             char c = Serial.read();
             incomingData.concat(c);
         }

         // now, the string incomingData will contain "255,000,000" which you can split into 3 different integers and send to setColor.
         // so, assuming the format "ddd,ddd,ddd":

         int color1 = incomingData.substring(0,3).toInt();
         int color2 = incomingData.substring(4,7).toInt();
         int color3 = incomingData.substring(8).toInt();
         setColor(color1, color2, color3);
    }
}

This result in error error: cannot convert 'String' to 'const char*' for argument '1' to 'int atoi(const char*)'

please see my edit.

now it tells me error: 'setColor' was not declared in this scope by the way I forgot to mention that I am totally beginner at C++ and i'm very grateful for your help. I'm actually studying you piece of code. Thank you

You're welcome. The code above is not complete; do not forget to include the 'setColor' function which I omitted.

Ok It works but I need to make some tweaking, I need to make some adjustments, including the fact that I can not change the color without reloading the script. Thank you Omer.


text:
How to attach interrupts to Arduino UNO timers?
I understand there are 3 timers on the Arduino UNO.  What specific registers do I need to use to access them?
My goal is to use these timers to poll different sensors I am using with a ms period. Are there any pre-made libraries out there to do this?

Have you had a chance to look at the datasheet yet?

The datasheet for the ATMEL SOC, or the Arduino breakout board itself?

For the MCU (not SoC).

For the UNO, use Timer1.
An example of the way you can use it is as follows:
Download the TimerOne library: https://code.google.com/p/arduino-timerone/downloads/list
/*
 *  Timer1 library example
 */

#include "TimerOne.h"

void setup()
{
  pinMode(10, OUTPUT);
  Timer1.initialize(500000);         // initialize timer1, and set a 1/2 second period
  Timer1.pwm(9, 512);                // setup pwm on pin 9, 50% duty cycle
  Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt
}

void callback()
{
  digitalWrite(10, digitalRead(10) ^ 1);
}

void loop()
{
  // your program here...
}

Timer 0 is use'd by the arduino core libraries for functions like millis(). It is best left alone. Leaving timer1 and 3 are available for general use. Both 1 and 3 have well established libraries, for simple implementation, without the need to know the mechanics under the hood, about the registers and such.
You can find links and general explanations at timer1. I always recommend the github versions.
And if you are still wanting to know the details the source is quite readible.

Note you don't need 3 timers to read 3 sensors. One timer on a multiple of the the 3, should suffice which can then implement a statemachine to sample at the correct periods.

I think you mean timer2, not timer3.


text:
how to make arduino as mind thought reader?
I'm trying to create arduino base mind reader... And for that I thought that EEG electrode connected to arduino and then the data send to arduino in 01 form .. But I facing problem in how to convert this or which wave (alpha, beta,delta)give very high or acutrate result.

Even if the answer provided by Mike is really doable and can be implemented you should really think about what you want to reach and what is your goal.
The big difference between EEG and mind readers is that the process of thinking, even if you can record all that waves: alpha, gamma,... can be never decoded to get useful informations. I mean: you can record and get a confirm that you have more gamma waves when you are doing meditation. Or that aplha and beta wave are going to be much more present when waking up or in particular hours of the days, but you never get an image of what the person is thinking or what are its emotions... That because you can get some waves coming from the brain but you cannot reconstruct the billion of processes that are happening inside the brain.
A lot of researcher are trying to decoder those informations to move as an example an arm or a leg. But it is the front edge of the reasearch really not doable with an Arduino....
Anyway good luck!

And to add to that - the cheap way of getting alpha/beta/gamma etc. is VERY unreliable. A real EEG would have several dozens of electrodes connected directly to the head's skin, as oppose to a single metal functioning as a voltage detector, that needs to handle too much noise.

You could hack an existing device like the Mattel Mind Flex ($20-50 on Ebay).
There have been a number of projects that do exactly what you have described - there's even an arduino library: https://github.com/kitschpatrol/Brain
http://frontiernerds.com/brain-hack


text:
Discrete H-Bridge very low current output
I have built two parallel H-bridges from "Design 1" on this page as you can see in the attached schematic.
However when I apply the external power (VCC1 in the center of the diagram) the two motors do not spin.
Using my multimeter, I can see that the entire circuit is working: the motor is getting a 'forward' and 'backward' current as the Arduino sets the pins high. The multimeter is reading +/- 5.54V with the motor replaced by the multimeter. (Across the motor this drops to 0.13V)
So then I measure the current by putting my multimeter both in series with the motors and replacing the motors. There's only 40mA available! Looking around the web I found the suggestion to reduce the 220Ω resistors at R2, R3, R5 and R6. So I switched in (randomly) 27Ω resistors and the output current is still only 40mA.
What else should I try to bring up the current enough to drive the motors?
Edit: So my uneducated guess is that it's likely that the limitation is coming from the transistors. The Ns are BC549 and the Ps are BC559. The datasheets list "low current" as a feature, but I figured that was the collector.
Edit 2: The motor is this one which requires 70mA when running (and presumably more during startup)

Edit 3: Code driving the Arduino:

// Pin setup
int pinLeftMotorFwd   = 5;
int pinLeftMotorBck   = 6;
int pinRightMotorFwd  = 10;
int pinRightMotorBck  = 11;

// Directions for the {left, right} motors to achieve the four directions
int FORWARD[]   = {  1,  1 };
int BACKWARD[]  = { -1, -1 };
int RIGHT[]     = { -1,  1 };
int LEFT[]      = {  1, -1 };

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

    pinMode(pinLeftMotorFwd,  OUTPUT);
    pinMode(pinLeftMotorBck,  OUTPUT);
    pinMode(pinRightMotorFwd, OUTPUT);
    pinMode(pinRightMotorBck, OUTPUT);
}

void loop() {
    go( FORWARD, 10 );
    go( RIGHT,    3 );
    go( FORWARD, 10 );
    go( LEFT,     6 );
}

// Move the bot in a particular direction from the array above for a given number of seconds
void go ( int dir[], int dur ){
    leftMotor(  dir[0] );
    rightMotor( dir[1] );
    delay( dur * 1000 );
}

// Sill both motors (OK, so stop both motors. But stop is a keyword in C)
void still(){
    leftMotor(  0 );
    rightMotor( 0 );
}

// Set the left motor to Backward (-1), Forward (1), or Stop (0)
void leftMotor( int dir ){
    // Pull both pins low
    digitalWrite(pinLeftMotorFwd, LOW );
    Serial.println("pinLeftMotorFwd LOW");
    digitalWrite(pinLeftMotorBck, LOW );
    Serial.println("pinLeftMotorBck LOW");

    // If we're going forward, pull the Fwd pin high
    if( dir == 1 ){
        digitalWrite(pinLeftMotorFwd, HIGH);
        Serial.println("pinLeftMotorFwd HIGH");
    }

    // otherwise, pull the Bck pin high
    else if( dir == -1 ) {
        digitalWrite(pinLeftMotorBck, HIGH);
        Serial.println("pinLeftMotorBck HIGH");
    }
}

// Set the right motor to Backward (-1), Forward (1), or Stop (0)
void rightMotor( int dir ){
    // Pull both pins low
    digitalWrite(pinRightMotorFwd, LOW );
    Serial.println("pinRightMotorFwd LOW");
    digitalWrite(pinRightMotorBck, LOW );
    Serial.println("pinRightMotorBck LOW");

    // If we're going forward, pull the Fwd pin high
    if( dir == 1 ){
        digitalWrite(pinRightMotorFwd, HIGH);
        Serial.println("pinRightMotorFwd HIGH");
    }

    // otherwise, pull the Bck pin high
    else if( dir == -1 ) {
        digitalWrite(pinRightMotorBck, HIGH);
        Serial.println("pinRightMotorBck HIGH");
    }
}

Design 1 would not have been my first choice.

What is the VCC1's power source. Is it a battery? By the way, 220 Ohm is pretty low value. That will result in 22mA of current (at 5v) going into the base. With a gain of 270 that would result in a collector current of around 6A. I'd try using increasing the resistors to 1 kOhm to 5 kOhm.

@Gerben: Ahh .. I see I may have messed up. I reduced the resistance. I'll try increasing it before I switch to a different circuit per Mark Williams below

Design 1 wouldn't be my first thought on how to do this either! The transistors aren't a great choice, but are cheap & common.
The layout here is more conventional, and you can physically link 1-2, & 3-4 to connect to your arduino without the risk of short circuits.
I suspect your code may be setting both lines high together - the only advantage I can see to the posted circuit is that this does not necessarily cause smoke (but may well do as you describe). This is why posting the code is recommended!

Thanks for the suggestion. The transistors were on-hand. Ultimately once I understand the concepts from "first principles" / discrete components, then I'd just replace the whole lot with either a motor driver circuit or a dedicated H-bridge.  The table at the bottom of the circuit you suggest indicates I need to switch pins between VCC/GND/Disconnected. How can linking 1-2 attached to a pin and 3-4 attached to another pin give me full control? (Code isn't setting both high, but I'll attach it anyway)

The point of the H-Bridge is that the transistors work in pairs - so you would have 1&2 or 3&4 on together, but never 1&3 or 2&4 - if you go back to 'Design 1' you will observe that a single input has been put through an inverter stage to ensure this doesn't happen - your re-design replaces that with software - OK 'til a bug sets up a short.. So with the standard arrangement on that link, the truth table at the bottom (disregard the not-connected options) shows you the combinations. You have off/brake/forward/backward and possibly PWM as well..

No diodes at home, so I built it on circuit.io: http://123d.circuits.io/circuits/511807-h-bridge where I had the exact same problem as my original circuit. Until I realised the NPNs were in backwards. Then everything came good. Going to check my original circuit tomorrow and see if I did the same there before I rebuild.

Turns out my actual problem was having the transistors around the wrong way. I couldn't get my circuit to work so I built yours and got exactly the same thing. The above circuits.io result gave me a clue so I played with them and got them around the right way. Turns out that the side that appears flat in Fritzing is the round side and vice-versa.


text:
Read temperature (DS18B20) with the ATTiny85
I'm trying to read the temperature of a DS18B20 with my ATTiny85 - but I'm getting rubbish data :D
I should have gotten ~22 degrees, but I'm getting 129! I followed this tutorial i found here, but maybe there is something funky with the ATTiny85?

Do you have a 4K7 Ohm pullup resistor between the DQ and 5v pins of the DS18B20?

Hi Omer! I'm using a 4k7 between DQ and 5v source. Does it need to be the 5v pin of the ds18b20? It's on my breadboard so just attached it to the power rail on the side, and not the same as the 5v pin for the sensor

it needs to be between the ds18b20's 5v and DQ.

Try to connect the VDD-pin of the sensor to +5V instead. This makes sampling easier.

I just rewired to my UNO and it works like a charm. I add a blinking led to the attiny, so I know its doing something :P it's running on 8mhz, does it matter?

I would suggest it has to be the clock speed or memory. Whilst you can program the ATTiny85 with the Arduino IDE, it will take up quite a lot of its flash memory. There is a thread on the Arduino form here which might help pinpointing the issue.
One solution is to write it in AVR-C but I don't know if there is an easy way (or a library) for the 1-wire. I think you'll have to do it with the 1-Wire library alone as the DallasTemperature library is too much for the 8Kb of memory you have to play with.
Please feedback any breakthroughs you make as this is a nice project, the ATTiny is an awesome little chip...

The code in the link that Jason94 attached to his question works perfectly with ATtiny85, I used it many times. No need to re-implement OneWire in pure AVR-C :)

Apologies for my assumptions. Just to clarify @Omer, you can run the ATtiny85 with both the 1wire and DallasTemperature libraries (and of course, the sketch provided in the original post)? It might be time I got the breadboard out again ;)

Yes. leaves almost no room for other code. Don't forget to make sure the ld.exe is fixed, to enable 8kb sketches (otherwise it will allow only 4kb) - https://github.com/TCWORLD/ATTinyCore/tree/master/PCREL%20Patch%20for%20GCC

Thanks for all the replies! I've found dozends of project where the ATTiny does one or the other, but not both... so maybe there are memory issues. Have some ATTiny84, but they have the same spec but more pins so would not do me any good... sad

@Jason94 was this issue solved?