text:
Difference between void setup() and void setup(void)
As it says in the title. I have been searching but I cant seem to find the answer.
What is the difference between void setup() and void setup(void) as well as void loop() and void loop(void)?

Absolutely nothing, in modern versions of C and C++. Specifying no arguments is the same as specifying void.
In old versions of C a function with no arguments took a single implicit int argument or allowed you to specify the arguments on a separate line, but no one uses anything like that nowadays.

Thanks. This is for the case of the Arduino. But what about other boards like say the Sparkcore? No difference as well?

It depends on the compiler, not the platform. But most are like this.

Up to C99, an empty parentheses meant any number of arguments (not just one int). Though obsolete in C99, it is still supported.


text:
Arduino software won't open in Mac OSX 10.10.1
I am having trouble opening the Arduino software on my mac, since I have updated Java to version 8 the Arduino software won't open. It does not give an error just closes instantly.
I have tried getting the newest version of the Arduino.cc site but no change.
Can anyone tell me how to open Arduino using an older version of Java?

Perhaps this should go on the Arduino Stack Exchange?

There are two versions available. One for java 6 and one for java 7. Did you try both?

Download and install the Apple version of Java (6): http://support.apple.com/kb/DL1572
If you need Java 8 SDK for some reason, the two can coexist because the Arduino IDE will explicitly ask for the (Apple Version) of Java 1.6 using 'JavaApplicationStub':
$ ./JavaApplicationStub
[JavaAppLauncher] Requested [1.5*], launching in [1.6] instead.
Experimental:  JNI_OnLoad called.
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7

Note however that if you have both Apple Java and Oracle installed, running 'java' or 'javac' form the command line will run the Oracle version.
$ java -version
java version "1.8.0_25"

If you need to switch the 'command line' version, change the symlinks in:
/System/Library/Frameworks/JavaVM.framework/Versions/

'JavaApplicationStub' will use the Apple version located in /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java.
As such, 'normal' java programs will generally use the Oracle version, while applications running in your browser or using JavaApplicationStub explicitly (like Arduino) will use the 'Apple' version.

Yeah that works sweet did have to open terminal to the Contents/MacOS of the Arduino app before JavaApplicationStub worked cheers

I just clicked on the apple icon => about this Mac => software update => Mac Sierra update.
now to get the USB port to work
numbatmark

source: Stack Exchange

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

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

sort: votes


text:
Feeble click in relay but it doesn't get activated when connected to Arduino circuit
I have an Arduino uno board and I have a soil moisture sensor

connected the digital output pin of the sensor to Arduino input pin
connected an output pin of Arduino to the INPUT pin of the relay board
programmed the Arduino such that if input is HIGH then the OUTPUT should be HIGH as well
connected 5 v pin of Arduino to vcc of the relay board
connected gnd pin of Arduino to gnd of the relay board

When my sensor outputs a HIGH DO (digital output), the relay only creates a feeble click sound and does not get activated. The Relay board LED does light up but the relay itself does not work (NC remains closed and NO remains open).
Do I need to supply an external VCC to the relay board? If yes then how should I set up the circuit?
A picture of the relay board is attached. You are right ... it is a 12 v relay. Do I need a 12 v external power source with IN1 coming from Arduino? Any help will be much appreciated.

What relay do you use? if this one http://www.hobbyist.co.nz/sites/default/files/pictures/dancing-lights/dancinglights_step2.png then yes you need to add power to the board. There are GND and VCC pins. Ground and +5V

Yes. The relay is the one that you have shown except that it is single channel. So instead of connecting the VCC of the board to the 5v from the ARDUINO, I should connect the VCC of the board to an external 5v source and similarly I should connect the GROUND of board to GROUND of the external source?

no. Realy shield Vcc > Arduino +5V. And IN1 to arduino digital pin. If this not works, provide the code. Also, one of the gold rule, 99% there is no connection where it should be, or there is a connection where it shouldnt :) Check the wiring. Check this http://www.hobbyist.co.nz/?q=interfacing-relay-modules-to-arduino

Sounds like you are using a 12v relay. Can you provide a link to where you bought it, or a part number?

40mA (max output current for arduino port) isn't a lot for a relay. Obviously we can't see what you're using to check that - but I would expect you to need a transistor for reliable operation.

Mark and Gerben ... Please see the picture of the relay board I am using. You were right ... it is a 12 V relay ... should i simply use IN1 from arduino and VCC and GND from an external power source? Or do I need to somehow connect the external power source with Arduino?

You need to join the ground of the external supply to the ground being supplied from the Arduino.  The 12V supply must be capable of at least 100ma
There appears to be a transistor and resistor on the board.  This is probably to drive the relay coil from the Arduino.  However, I would need to look at the circuit diagram of the board to be certain.  Can you supply images of the copper side and component side of the board to see what the connections are.
Ideally the circuit diagram from the manufacturer would be even better.

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


text:
AVR ATmega328p-pu operating circuit?
I used to work with PIC micro-controller so i know what it needs to work from operating circuit to crystal oscillators needed and other components to power it up , my question here where can i find the operating circuit for ATmega32p-pu and other AVR models . or all i need to do is to give it +5v and gnd and it will work ?

Just 5v, crystal (with caps), and probably a pull-up on the reset pin. Just make sure you connect all the 5v pins and all ground pins. PS you can skip the crystal if you use the internal RC oscillator. PPS blank chips have their fuses set, so it runs at 1mHz from the internal oscillator. With some programmers you need to select a slower speed, to program the AVR running at only 1mHz.

You're looking for this I think? How to set up an Arduino on a breadboard.

thanks man but not exactly i don't need the complete functions of arduino i just want to power up and make the chip work no more no less

So, just take the bits you need from that page - it  is quite modular.


text:
What's the difference between different Ethernet Shields?
I am working on a project with Arduino and I need an Ethernet shield. but after searching in some electronics shops I found there isn't only one but a lot. I don't know which one is better and what are the differences.
Arduino Ethernet with PoE module
Ethernet Pro
Ethernet Shield for Arduino - W5200
Arduino Ethernet Rev3 Without PoE Module
Ethernet Shield W5100 For Arduino
in DFRobot Online Shop.

Clearly the 'best' one is the one that meets your requirements (or is the most expensive - that's always the best, right?).
You say you need an ethernet shield - can you explain why? Without that information, it's almost impossible to tell you which is the most suitable.
If you are looking at IoT applications, it may be that an Ethernet shield isn't the 'best' thing for you. If you just want access to the local IP network, you could use any of those. If you want the 'best' library of functions to support your application, that may affect which module you use.
For me, I think the best module is the cheapest one that gives me connectivity: http://www.aliexpress.com/item/Hot-Sale-ENC28J60-Ethernet-LAN-Network-Module-For-Arduino-51-AVR-STM32-LPC/32254842414.html
The W5100 is also a good choice, but only if it is under $7

What one that is the best is highly subjective.
Though my personal experience is that arduinos original is the one with the best support. Where you can find alot of documentation about the other ones, you might need to do some legwork updating the code to the latest version of the arduino ide or use an older ide.
Be aware that some Arduinos has integrated ethernet, and others are SHIELDS, you recognize the arduinos with ethernet by the power-connector, and the shields by the distinct name containing "Shield", though shields require an arduino to work. The arduino with integrated ethernet does not.
Also be aware that not all shields fits arduinos boxes if you want to encase it. And of cause, buying arduinos original products, cost a bit more - but you support the arduino foundation, and further development of the products.


text:
74HC595N in series error
I want have 2 74HC595N shift registers in series.
I built this schematic

When I send a value to the first register, it is sent to the second one. I have same value on both. I change them (master/slave) but the result is the same.
I connected pin 9 on the first SR first with pin 14 on the second. I am using Johnny Five on Galileo Gen 1 with shiftRegister.send(25) to send the data.
What am I doing wrong because several days ago I made it and it worked?

I am very curious about the 3 leds on the right - the clock, overflow, and data/digital pin 2 should go at much too high a rate to be able to see anything. I have a very similar circuit (Arduino Uno, connected to 2x7 segment displays), so it should work.

If you had it working and it has changed, I would suggest trying a few changes to track down the issue. The schematic seems OK so assuming that all connections are sound, I would look towards proving the code. Maybe try a simple pure Arduino sketch designed for the 74HC595N and see if the results are the same. If not, the culprit is almost certainly Johnny Five.
Perhaps try this sketch which should work with your schematic (remap the I/O though to your 2,3,4 configuration). If the problem persists, throughly examine your connections because there is very little else which would prevent it from working - especially given that it did work a few days ago. Also, have you got another Leonardo to test with?
Finally, the schematic for the Arduino-only example shows a cap on the latch line - presumably for debouncing - which is missing from your schematic. I don't think you've damaged your registers but I wouldn't rule it out.


text:
How to pass value of a function from the RFID-RC522 library into a variable then be sent into either serial or ethernet?
I'm using an RC522 RFID reader with an Arduino UNO. There is a function?? (or whatever it's called :)) in Miguel Balboa's new MFRC522.h library which is mfrc522.uid.uidByte[i] that prints the bytes of the unique ID. The repetition of the function results in 8 piece of HEX digits that are from the 2 numbers that each function outputs (2+2+2+2=8). Whenever I use the line of codes that are commented out, the serial monitor outputs them successfully. So for example, 12345678 is the unique id, each array displayed 12, then 34, then, 56, then 78 which is 12345678 in the serial. which is fast and unnoticeable besides that there are no spaces included when on output. The thing is, I want to output all of these into a single variable.(Please help me also on how to concatenate) How can I do this? An attempt was done below (not commented out) but it outputs only the number 16, consistently, which is I think due to a data type problem. The variables are initialized as int. The "function" which I found in the library is initialized as byte (correct me If I'm wrong). But when the variables are initialized as byte, I cannot upload the sketch since there are errors. Please help. :( (The reason I need it to be saved into a single variable is because I am placing it in the GET method of an Ethernet Client. I don't think the bare function can do that. (Or if it can, can you please help with the code? :)) Thanks

// Dump UID
        //Serial.print("Card UID:");

            //Serial.print(mfrc522.uid.uidByte[0], HEX);
            //Serial.print(mfrc522.uid.uidByte[1], HEX);
            //Serial.print(mfrc522.uid.uidByte[2], HEX);
            //Serial.print(mfrc522.uid.uidByte[3], HEX);

            serNum0={mfrc522.uid.uidByte[0], HEX};
            serNum1={mfrc522.uid.uidByte[1], HEX};
            serNum2={mfrc522.uid.uidByte[2], HEX};
            serNum3={mfrc522.uid.uidByte[3], HEX};
            Serial.print(serNum0);
            Serial.print(serNum1);
            Serial.print(serNum2);
            Serial.print(serNum3);

As far as I can understand, you expect to receive byte data from the RFID reader, you would like to store this data into a single variable, and eventually print its content, or manipulate it in some way. You could do this maintaining a byte array (or uint8_t array).
Let's suppose, for example, to receive a unique ID of length 4 from the RFID reader. In this case you could simply store it into a serNum[serNum_size] array, where serNum_size is just the number of data you are expecting to receive, and later access its content for whatever manipulation you would like to do.
int serNum_size = 4;        // reader data size
byte serNum[serNum_size];   // reader data content

for(int i = 0; i < serNum_size; i++){
 serNum[i] = mfrc522.uid.uidByte[i]; // store reader data block
 Serial.print(serNum[i], HEX);       // hexadecimal form
}

As far as the print is concerned, you can simply print the byte entry and apply the HEX format. In this way, the stored value will be considered as its hexadecimal value.

Welcome to Arduino SE! Can you add a bit of explanation to your answer explaining how this works, etc.? Thanks!


text:
Using multiple timers and avoiding conflicts
I would like to use three timers in CTC mode to launch three Interrupt Service Routines at different frequencies.
In this application I need to use the servo library, millis() and micros() functions.
Timer3 (Working)
Thanks to this question, Timer3 has been set up in the following way:
  cli();          // disable global interrupts
  TCCR3A = 0;     // set entire TCCR3A register to 0
  TCCR3B = 0;     // same for TCCR3B

  // set compare match register to desired timer count:  @~744 Hz
  OCR3A = 20;
  // turn on CTC mode:
  TCCR3B |= (1 << WGM32);
  // Set CS10 and CS12 bits for 1024 prescaler:
  TCCR3B |= (1 << CS30) | (1 << CS32);
  // enable timer compare interrupt:
  TIMSK3 |= (1 << OCIE3B);
  // enable global interrupts:
  sei();

  ISR(TIMER3_COMPB_vect)
  {
     cont++;
  }

Timer4
I've tried with this configuration:
cli();          // disable global interrupts
TCCR4A = 0;     // set entire TCCR3A register to 0
TCCR4B = 0;     // same for TCCR3B

// set compare match register to desired timer count: @ ~744 Hz
OCR4A = 20;
// turn on CTC mode:
TCCR4B |= (1 << WGM42);
// Set CS10 and CS12 bits for 1024 prescaler:
TCCR4B |= (1 << CS40) | (1 << CS42);
// enable timer compare interrupt:
TIMSK4 |= (1 << OCIE4B);
//TIMSK4 |= (1 << OCIE4A); same issue
// enable global interrupts:
sei();

ISR(TIMER4_COMPB_vect) //TIMER4_COMPA_vect same issue
{
  cont++;
}

But the compiler returns an error caused by the servo library conflict:

Servo\Servo.cpp.o: In function '__vector_42': C:\Program Files
  (x86)\Arduino\libraries\Servo/Servo.cpp:117: multiple definition of
  '__vector_42' Timer4B_800Hz.cpp.o:C:\Program Files
  (x86)\Arduino/Timer4B_800Hz.ino:49: first defined here c:/program
  files
  (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe:
  Disabling relaxation: it will not work with multiple definitions

As Gerben suggested in a comment in this question:

They are just hogging all timers. I guess you have to alter the
  library slightly by removing the #define _useTimer3 line, or try
  putting a #undef _useTimer3 right after the include. –  Gerben

I would avoid changing the servo library since motors play a critcal role in the application.
Timer 5 Same issue
Which timers and output compare registers can I use to set up the three ISR correctly?

Whichever you like, as long as you're willing to dump the Servo library and do it by hand.

Is it the only solution? There must be another way to use these timers...

Have you tried the undef suggestion?

Related: Setting the frequency of a timer interrupt

The problem is the Servo library. This library is claiming all the timers, so you can't use them yourself. What I do to fix this is edit the Servo.h (or ServoTimers.h) file.
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
//#define _useTimer5
#define _useTimer1
#define _useTimer3
//#define _useTimer4
//typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers }   timer16_Sequence_t;
typedef enum { _timer1, _timer3, _Nbr_16timers } timer16_Sequence_t;

This will remove the 2 timers (4 and 5) for the Mega boards, but you can still attach 24 servo's. If you need more, you should edit this file again.


text:
Controlling LED delays via keypad
I'm trying to turn on LEDs based on delays entered by keypad and the same for turning them off, but the LEDs are not responding. Here is the code I'm using:
#include <Keypad.h>

const byte ROWS = 4;//four Rows
const byte COLS = 3;//three columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = {13,10,9,8}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7,6,1}; //connect to the column pinouts of the keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

int x;
int y;
int z;
int e ;
int w;
int r;
int Pin1 = A0;
int Pin2 = A1;
int Pin3 = A2;

void setup() {
  // initialize pins A0,A1 and A2 as an output.
  pinMode(A0, OUTPUT);
  pinMode(A1, OUTPUT);
  pinMode(A2, OUTPUT);

}

void loop ()
{
  char key = kpd.getKey();

l1:  if (key)  // Check for a valid key.
  {
    switch(key)
    {
      case '1':
      w=1;
      break;
      case '2':
      w=2;
      break;
      case '3':
      w=3;
      break;
      case'4':
      w=4;
      break;
      case '5':
      w=5;
      break;
      case '6':
      w=6;
      break;
      case '7':
      w=7;
      break;
      case '8':
      w=8;
      break;
      case '9':
      w=9;
      break;
    }
  }
  else { goto l1;} // To guarantee that a key is pressed before moving on with the rest of code

  delay(w*1000*60); //To reach the time specified by the user before moving on
  digitalWrite(A2,HIGH);

l2: if (key)
{
  switch (key)
  {
    case '1':
        r=1;
        break;
        case '2':
        r=2;
        break;
        case '3':
        r=3;
        break;
        case '4':
        r=4;
        break;
        case '5':
        r=5;
        break;
        case '6':
        r=6;
        break;
        case '7':
        r=7;
        break;
        case '8':
        r=8;
        break;
        case '9':
        r=9;
        break;
      }
}
else {goto l2;} // To guarantee that a key is pressed before moving n with the rest of code

delay ((r-w)*1000*60); //To reach the time specified by the user before moving on
digitalWrite (A2,LOW);

l3: if (key)
{
  switch(key)
  {
    case '1':
        x=1;
        break;
        case '2':
        x=2;
        break;
        case '3':
        x=3;
        break;
        case '4':
        x=4;
        break;
        case '5':
        x=5;
        break;
        case '6':
        x=6;
        break;
        case '7':
        x=7;
        break;
        case '8':
        x=8;
        break;
        case '9':
        x=9;
        break;
      }
}

else { goto l3;} // To guarantee that a key is pressed before moving n with the rest of code
delay ((x-r)*1000*60);//To reach the time specified by the user before moving on
digitalWrite (A0,HIGH);

l4: if (key)
{
  switch (key)
  {
    case '1':
        y=1;
        break;
        case '2':
        y=2;
        break;
        case '3':
        y=3;
        break;
        case '4':
        y=4;
        break;
        case '5':
        y=5;
        break;
        case '6':
        y=6;
        break;
        case '7':
        y=7;
        break;
        case '8':
        y=8;
        break;
        case '9':
        y=9;
        break;
      }
}
else {goto l4;} // To guarantee that a key is pressed before moving n with the rest of code
delay((y-x)*1000*60); //To reach the time specified by the user before moving on
digitalWrite (A0, LOW );

l5:
if(key)
{
  switch(key)
  {
    case '1':
      z=1;
      break;
      case '2':
      z=2;
      break;
      case '3':
      z=3;
      break;
      case'4':
      z=4;
      break;
      case '5':
      z=5;
      break;
      case '6':
      z=6;
      break;
      case '7':
      z=7;
      break;
      case '8':
      z=8;
      break;
      case '9':
      z=9;
      break;
    }
}
else {goto l5;}// To guarantee that a key is pressed before moving n with the rest of code
delay ((z-y)*1000*60); //To reach the time specified by the user before moving on
digitalWrite(A1,HIGH);

l6: if (key)
{
  switch(key)
  {
    case '1':
        e=1;
        break;
        case '2':
        e=2;
        break;
        case '3':
        e=3;
        break;
        case '4':
        e=4;
        break;
        case '5':
        e=5;
        break;
        case '6':
        e=6;
        break;
        case '7':
        e=7;
        break;
        case '8':
        e=8;
        break;
        case '9':
        e=9;
        break;
  }
}
else{goto l6;}// To guarantee that a key is pressed before moving n with the rest of code
delay((e-z)*1000*60); //To reach the time specified by the user before moving on
digitalWrite (A1, LOW );

}

You'd probably find the code a lot easier to follow if you looked at some of the Arduino libraries, for example that last case statement could be replaced by toInt to convert a string to an integer. Goto statements are also best avoided and there's rarely any good reasons to use them.

@peterJ thanks for responding, but i used Goto statement so i guarantee that a key is pressed before moving on with the rest of code,,

Your goto statements do not guarantee anything because key is just read once during the whole loop(). There are logical flaws in your code, you'd better think it over from scratch and just forget those damn gotos. Goto is not needed in any Arduino program!

I would start with a much simpler design just to make sure you've got the fundamentals down.  Can you turn any of the LEDs on in your program at all? Make them blink?


text:
Comparing a char with the symbols '.-'
I'm using the Arduino software to create a Morse code decoder using the  serial monitor.
I enter a Morse code such as .- as a text string and it's displayed in the LCD as a alphanumeric text. So if I enter .- into the serial Monitor, A is displayed on the LCD. But it only works for single symbols, not the dot and dash together.
Is there a way to make the if statement as seen below accept both the dots and dashes together?
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  lcd.begin(16, 2);

 Serial.begin(9600);
}

void loop()
{
  char schar;

  if (Serial.available())
  {
    schar = Serial.read();

    Serial.write(schar);

    if (schar== '.-' ){
      Serial.write('A');
      lcd.print('a');
    }
  }
}

Your first problem is that there is no way for schar to contain two characters in the first place; Since schar is declared as a char, it can only contain one character.
You need to make a String out of the serial input. Serial.read() only returns one character at a time, so you will need to make sure you iterate over all the input. Then you can compare the whole String with another, and see if both characters match at once. Just look at this code to see different ways of manipulating Strings: http://arduino.cc/en/Tutorial/StringComparisonOperators
Notice that string literals use double quotes, not single quotes like characters.
Also, be aware of the fact that string and String are different things. lowercase 's' is an array of characters, capitol 'S' is the class that has those useful string comparison member functions. The class is more resource intensive, but I think in your case the readability and convenience are worth it.

i'm still new but should i use char schar[2];

That would be equivalent to a string (lowercase) on arduino, sometimes called a "c style string". It can work, but using the functions built in to arduino's String class might be easier. that would be String schar;

A string seems like overkill here. The lowercase one would use much less memory (if(data[0] == '.' && data[1] == '-') would be more efficient)

You could use C strings, (type char*) or C++ String objects (type String). Both would work.
If you use C strings, you'll need to use functions like strcmp() from the C library to see if your input string matches a particular morse sequence.
If you use C++ String objects, you'll need to use the methods of that class. I'm less familiar with that class.
If you have single Morse characters, matching them up is pretty easy. If you have a continuous stream of dots and dashes, though, it's a much thornier problem. You need a way to figure out the boundary between characters. Morse characters can be sequences of between 1 and 5 dots and dashes.
Unless there are extra delays between the dots/dashes for a character, I'm not sure how you figure out where the boundaries are. There are already computer Morse code readers, though, so this must be a "solved problem". I'd do some googling.

morse code does in fact require a delay or a break character to be uniquely decipherable, see Is Morse code without spaces uniquely decipherable?

schar is a char variable of size 1. It makes no sense to compare it with '.-', which is supposed to be a string. Declare a char[3] array, fill it as string and use the strcmp function. It's elementary C knowledge.


text:
Sweep with two shift registers
I am working with 8 dual color LED's and 2 shift registers. My connections are in place. But I do not understand how to work with 2 shift registers.
So I am trying to make this: turn the first led on, turn the first led of, go to the next led, turn it on, turn in off, etc...
I do not know how to jump from the first shift register to the second shift register when the last LED of the first shift register is turned off.

Exactly the same as when you're trying to keep them dark when lighting an LED with the first register: shift two bytes.
The first byte shifts into the first register to begin with, and then out of the first register and into the second register when you shift the second byte into the first register. Just make sure only the appropriate bits are set in both bytes and you're good to go.


text:
Oil Pressure / Water Pressure / Boost Pressure ( Turbo Engine )
I'm an automotive enthusiast and I want to build some gauges by myself using Arduino.
I was taking a look at this pressure transducer or sender, 100 psi, stainless steel, for oil, fuel, air, water and I was thinking if I can use this sensor to do all of the these tasks: Water, Boost and Oil Pressure.
Look at the Signal output vs read PSI chart of the sensor

I came out with this equation for the PSI calculation:
Since it is a Y = bx + a, where:
a = 0.5
b = y2 - y1 / x2 - x1 = (4.5 - 0.5 ) / (100 - 0) = 4/100 = 0.04
x = PSI
y = Signal's Voltage

This means that
Voltage Reading = 0.04PSI + 0.5
So we have :
PSI = (Voltage Reading - 0.5 ) / 0.04
Am I correct? Can I use this sensor?

You math checks you to me.
When you code it, You will probably read a voltage using an analog pin (or external ADC) that will return an integer between 0 being 0 volts, and 1024 = vin volts. vin will be 5 if you don't wire up the vin pin, and 1024 could be different if you use an external ADC.
Anyway you should be aware that the raw readings will probably not be 0-5, and they dont have decimal points. You will need to first convert the reading into the voltage with something like this:
float voltage = ((float)reading)/1024.f;

notice that the datatype float is used (enables decimal points) and that the constant being divided by is also a float so that the calculations will definitly happen between floating point numbers.

float calculation is slow on an arduino. You could just use regular integers. byte psi = (analogRead(A1)-102)/8 would be a pretty good aproximation. Or if you need more precision; int psi = (analogRead(A1)-102)*100/819.

integer arithmetic is more efficient but I doubt the time difference really matters. When I tested this there was no difference is running times between the two versions given the 4 microsecond resolution of micros().

Careful... the formula for conversion is  float voltage = ((float) rawADC  + 0.5 ) / 1024.0 * Vref (from https://www.gammon.com.au/adc with explanation). In your case 8 bit integers (0-255) are fine, no need of additional precision.

I'd add code to test for voltage between 0.0 to less than or near 0.5 volts. Disconnected pressure transducer won't present 0.5v, 0 PSI transducer voltage; not output 0.5 v @0 PSI shows a lower voltage indicated a fault or open circuit in transducer wiring. My experiences, too many times other engineers "borrowed" hardware and I wound up troubleshooting a non-fault but theft ;} Only a few lines of code to ensure connections are correct.
The floating point vs integer arithmetic compute time is outweighed by settling time of A/D converter and transducer. The auto part was my solution to show HOA board stats for my wildly varying water pressure at Condo Assn,  very cost effective too.


text:
Get the uploaded code from arduino by using arduino IDE 1.0.6
Recently bought a arduino device which already have program,
it is model AR-293D and I have already connect it with my PC(windows 7) through usb
when I open the IDE , It seems there is no function that read the uploaded program?
And after searching a while , like some beginner tutorial , it only tell you how to upload the program but not how to get the uploadded program
http://www.forefront.io/a/beginners-guide-to-arduino
So, I wonder how to get the code? Thanks a lot for helping, I worried erase the uploadded program so I need to take caution about this

The problem is the uploaded code will be machine code and while you might be able to disassemble it there won't be a way to get the C++ code back out of it.

sorry for being new for this, Is that mean if I write the new code then it will overlap and erase the old code? thanks

Yes that's right it will erase the old code and replace it, so you just keep your C++ code on the PC.

You can use khazama to read the chip, and then write it to a hex file. There are tons of other ways, but that's the one I've used previously, that was pretty easy.

You can download the hex machine code from the Arduino by using an ISP programmer, like this one:

A command like this could be used to read the flash memory and save it into myfile.hex:
avrdude -c avrisp -p m328p -U flash:r:myfile.hex:i

However be warned that this file will look like this:
:100000000C945C000C946E000C946E000C946E00CA
:100010000C946E000C946E000C946E000C946E00A8
:100020000C946E000C946E000C946E000C946E0098
:100030000C946E000C946E000C946E000C946E0088
:100040000C9488000C946E000C946E000C946E005E
:100050000C946E000C946E000C946E000C946E0068
:100060000C946E000C946E00000000080002010069
:100070000003040700000000000000000102040863
:100080001020408001020408102001020408102002
:10009000040404040404040402020202020203032E
:1000A0000303030300000000250028002B000000CC
:1000B0000000240027002A0011241FBECFEFD8E043
:1000C000DEBFCDBF21E0A0E0B1E001C01D92A930AC
:1000D000B207E1F70E94F1010C9401020C940000B8

As you can see, you haven't really got "the program" back.

As Mikael Patel points out, you can at least turn it into assembler by doing this:
avr-objdump -j .sec1 -d -m avr5 myfile.hex

However the output is still not C code like you see in the IDE:
  d4:   0e 94 f1 01     call    0x3e2   ;  0x3e2
  d8:   0c 94 01 02     jmp 0x402   ;  0x402
  dc:   0c 94 00 00     jmp 0   ;  0x0
  e0:   61 e0           ldi r22, 0x01   ; 1
  e2:   8d e0           ldi r24, 0x0D   ; 13
  e4:   0c 94 81 01     jmp 0x302   ;  0x302
  e8:   61 e0           ldi r22, 0x01   ; 1
  ea:   8d e0           ldi r24, 0x0D   ; 13
  ec:   0e 94 ba 01     call    0x374   ;  0x374
  f0:   68 ee           ldi r22, 0xE8   ; 232
  f2:   73 e0           ldi r23, 0x03   ; 3
  f4:   80 e0           ldi r24, 0x00   ; 0
  f6:   90 e0           ldi r25, 0x00   ; 0
  f8:   0e 94 f5 00     call    0x1ea   ;  0x1ea
  fc:   60 e0           ldi r22, 0x00   ; 0
  fe:   8d e0           ldi r24, 0x0D   ; 13
 100:   0e 94 ba 01     call    0x374   ;  0x374
 104:   68 ee           ldi r22, 0xE8   ; 232
 106:   73 e0           ldi r23, 0x03   ; 3
 108:   80 e0           ldi r24, 0x00   ; 0
 10a:   90 e0           ldi r25, 0x00   ; 0
 10c:   0c 94 f5 00     jmp 0x1ea   ;  0x1ea

Unless you are an assembler expert, making sense of that would be pretty hard, and the time taken to do it would be better spent simply rewriting the code from scratch.

The magical command for converting from hex to asm seems to be "avr-objdump -j .sec1 -d -m avr5 myfile.hex". Found this in http://www.avrfreaks.net/comment/158180#forum-topic-top

Amended to incorporate your comment, thanks!

But there are decompilers that can convert machine code to C, but I assume those do not work with this kind of assembler?

I don't see why they wouldn't work with this type, however there are limitations to what they can achieve. For one thing, they can't possibly know the variable names (apart from processor registers, I suppose) so your variables would become v1, v2, etc. The C compiler possibly inlines some function calls, so you might see functions turned into inline code. The compiler moves things around (or omits them, even) for efficiency, so that would be hard to get back. Anyway, re-reading the question, it doesn't seem like some very important stuff is there.

For a more complete backup of everything on the ATmega328p chip, avrdude -v -p m328p -c avrisp -U flash:r:m328p_flash.hex:i -U efuse:r:m328p_efuse.hex:h -U hfuse:r:m328p_hfuse.hex:h -U lfuse:r:m328p_lfuse.hex:h -U lock:r:m328p_lock.hex:h -U eeprom:r:m328p_eeprom.hex:i captures EEPROM data and fuse settings, as well as the executable flash object code. Restore backup by replacing all of the :r: with :w:.


text:
How to return the value in Arduino function (that can be read by the connected device)?
Right now I have an RC car program for Arduino. The code is like this:
void loop() {
  distance = Dist.getDistanceCentimeter();
  if(distance<=5 & distance>1)
  if(Serial.available()) {
    lkf = Serial.read();
  switch(lkf) {
  case 'a':
     forward();
     servoX.write(90);
     lkf=0;
     break;
  }
}

I wrote a TCPclient that can order the RC car to move forward by connecting through TCP and sending the message "a" to the Arduino board.
The problem is how to return the distance to the cilent? Is it simply return distance; or something like system.println(distance);? Thanks for helping.

Use serial.println(distance);.

You are using the USB interface, right? So you just use Serial to send data back. For example, this would send the distance every second:
unsigned long lastSent;
void loop() {
  distance = Dist.getDistanceCentimeter();
  if (millis () - lastSent >= 1000)  // every second
  {
    lastSent = millis ();
    Serial.println (distance);
  }

  if (distance <= 5 & distance > 1)
  {
    if (Serial.available()) {
      command = Serial.read();
      switch (command) {
        case 'a':
          forward();
          servoX.write(90);
          command = 0;
          break;
      }  // end of switch
    }
  }
}


text:
Button reading not going off
I made a circuit which in my intentions would allow me to toggle a LED dimming loop.
Problem is that once I push the button the first time pushing it a second time doesn't toggle the LED loop off.
Here is the code:
const int LED = 9; // the pin for the LED
const int BUTTON = 7;

int val = LOW;

int old_val = LOW;
int state = 0;
int i = 0;

void setup()
{
  pinMode(LED, OUTPUT);
  pinMode(BUTTON, INPUT);

}

void loop()
{
  val = digitalRead(BUTTON);

  if ((val == HIGH) && (old_val==LOW))
  {
    state = 1 - state;
    delay(10);
  }

  old_val = val;

  if (state == 1)
  {
    for (i = 0; i < 255; i++)  // loop from 0 to 254 (fade in)
    {
      analogWrite(LED, i); // set the LED brightness
      delay(10);           // Wait 10ms because analogWrite
      // is instantaneous and we would
      // not see any change
    }

    for (i = 255; i > 0; i--) // loop from 255 to 1 (fade out)
    {
      analogWrite(LED, i); // set the LED brightness
      delay(10);           // Wait 10ms
    }
  } else
  {
    analogWrite(LED, 0);
  }

  if ((val == LOW) && (old_val == HIGH))
  {
    delay(10);
  }
}

Here is the circuit scheme:

I would be interested both in learning what the problem is AND learning any mental methods I can apply to debug in such situations.

Is the 10kohm resistor really connected to A5, A4, A3, A2, A1, A0, VIN, and GND?

No, only to GND1. It is a problem with the rendering in 123d circuits.

Then you should consider fixing your wiring diagram.

There! I fixed it.

While the led is fading in and out (which takes 5 seconds), the state of the button is never checked. So you'd need to have the button released for at least 5 seconds (so old_val becomes LOW), and then pressed exactly we the led is faded out (again, 5 seconds later). So try keeping the button pressed for at least 5 seconds. PS you probably want to rewrite your code, so the button is more 'responsive'.

You are right @Gerben! Thank you for the explanation. Any hints on how to make it more responsive?

While the led is fading in and out (which takes 5 seconds), the state of the button is never checked. So you'd need to have the button released for at least 5 seconds (so old_val becomes LOW), and then pressed exactly we the led is faded out (again, 5 seconds later). So try keeping the button pressed for at least 5 seconds.
You probably want to rewrite your code, so the button is more 'responsive'. Below I added an example of how to do this.
const int LED = 9; // the pin for the LED
const int BUTTON = 7;

int val = LOW;
int old_val = LOW;

bool fadeLed = false;
int brightness = 0;//current pwm value
int direction = 1;// 1 is brightness is increasing, -1 if brightness is decreasing

void setup()
{
  pinMode(LED, OUTPUT);
  pinMode(BUTTON, INPUT);
}

void loop()
{

  /* check the button */
  val = digitalRead(BUTTON);
  if ((val == HIGH) && (old_val==LOW))
  {
    // button pressed ( called only once per press )
    fadeLed = !fadeLed;// invert boolean
  }
  old_val = val;

  /* update the leds brightness */
  if( fadeLed )
  {
    // fade led in and out
    if( brightness==0 )
      direction = 1;//change direction is minimum value reached
    if( brightness==255 )
      direction = -1;//change direction is maximum value reached
    brightness += direction;// increase/decrease brightness
  }
  else
  {
    // fadeLed is disabled, so only decrease brightness till it reaches zero
    if( brightness>0 )
      brightness--;
  }

  analogWrite(LED, brightness); // set the LED brightness
  delay(10);           // Wait 10ms because analogWrite
                       // is instantaneous and we would
                       // not see any change

}

Any questions about the code; just let me know.


text:
how to block Arduino code until a certain event?
i am tring to enter a series of numbers using "keypad" to different variables..when simulate the code on proteus it only took the first "getkey()" function and ignored the rest ..
SO,
How can i block an arduino code until a key is pressed by keypad, in other words prevent the rest of code from being executed before a key is pressed

Please post your code here. We don't have crystal balls here :)

And a wiring diagram or schematic, since this is hardware-based as well.

It depends on how the "keypad" is implemented. If you've got it hooked up to a hardware interrupt, then you only need to add an interrupt handler for that event.
On the other hand, the more "straight-forward" implementation is that you have to poll the pins to see if a key was pressed.  Simply do that in a loop until you see a key press, call your event-handler method, and then continue to loop.

thanks a lot, I used waitForKey() function from keypad library and it worked correctly :)


text:
Newbie needing help with debounce errors in arduino
So I found a code I would like to use and not sure how to edit the code properly.
#include <Debounce.h>

void matrix(char matrix[7]) {
  int map[10];
  map[0] = 2;
  map[1] = 3;
  map[2] = 4;
  map[3] = 5;
  map[4] = 6;
  map[5] = 7;
  map[6] = 8;
  map[7] = 9;

  int i=0;
  for(i=0;i<=7; i++) {
   if(matrix[i] == 0x30) { // 0x31=1, 0x30=0
      Serial.println(map[i]);
      digitalWrite(map[i],LOW);
   }
   else digitalWrite(map[i],HIGH);
  }
}

void show(int number) {
  switch(number) {
    case 0:
      matrix("11111100");
      break;
    case 1:
      matrix("01100000");
      break;
    case 2:
      matrix("11011010");
      break;
    case 3:
      matrix("11110010");
      break;
    case 4:
      matrix("01100110");
      break;
    case 5:
      matrix("10110110");
      break;
    case 6:
      matrix("10111110");
      break;
    case 7:
      matrix("11100000");
      break;
    case 8:
      matrix("11111110");
      break;
    case 9:
      matrix("11110110");
      break;
    default:
      matrix("00000010");
      break;
  }
}

#define t1 13
#define t2 12

Debounce debouncert1 = Debounce( 20 , t1 );
Debounce debouncert2 = Debounce( 20 , t2 );

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

  // initialize the digital pin as an output:
  pinMode(13, INPUT);
  pinMode(12, INPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
}

int setCountPlus(int count){
  if(count == 9){
    count = 1;
  }
  else{
    count++;
    count %= 10;
  }
  return count;
}

int setCountMinus(int count){
  if(count==1){
    count = 9;
  }
  else{
  count--;
  count %= 10;
  }
  return count;
}

void loop()
{
  int i=-1;
  show(i);
  while(1){
    debouncert1.update();
    debouncert2.update();
    if(debouncert1.read()){
      i=setCountPlus(i);
    }
    if(debouncert2.read()){
      i=setCountMinus(i);
    }
    if(i==10){
      i=1;
    }
    show(i);
    delay(250);
  }
}

as for the errors.
sketch 65: error: 'Debounce' does not name a type
sketch 66: error: 'Debounce' does not name a type
sketch .ino: In function 'void loop()':
sketch 108: error: 'debouncert1' was not declared in this scope
sketch 109: error: 'debouncert2' was not declared in this scope
Any help would be great on fixing the code to stop getting errors.

Where did you believe that Debounce was supposed to be found?

You need to install the Decounce library first.

In the description of Debounce, you'll find the hint that this library is outdated and no longer maintained.
Its successors, Bounce1 and, more recently, Bounce2 are available from a github repository by Thomas Fredericks, Bounce-Arduino-Wiring.
Instead of simply downloading and unzipping the archive to ${HOME}/sketchbook/libraries, you might want to consider that this is the right moment to get familiar with git repositories as an easily updatable source for third-party libraries.
Supposed that you're on a GNU/Linux system with git installed, you would
cd /${HOME}/sketchbook/libraries
git clone https://github.com/thomasfredericks/Bounce-Arduino-Wiring.git

to obtain a clone of the necessary data.
If the name of the directory of the library contains dashes (-), you'll have to change this name: remove the dashes or replace them with underscores (_). Names with dashes aren't valid!
Once in a while, you would change to the directory of the respective library and simply run git pull to update your local copy to the latest version of the repository.

Depending on the switch type:
-SPDT (SIngle Pole Double Throw) - You would use a Cross Coupled NAND Gates (Flip Flop, Set Reset) This will set true to the side it sees power at from the switch and if it bounces it can't change state until the switch touch the other contact.
-SPST (Single Pole Single Throw) - You can use a software debounce where you would detect a signal and then wait for 10ms then read again and if there is a signal still, it is a debounced signal.  --OR--  You can use capacitors to help extend the life of a signal.
so debounce code
bool sw13=false;
bool sw12=false;
while(1){
if(digitalRead(13)==HIGH && !sw13){
  delay(20); //Delay For 20ms
  if(digitalRead(13)==HIGH){
    i=setCountPlus(i);
    sw13=true;
  }
}else{
    sw13=false;
}
if(digitalRead(12)==HIGH && !sw12){
  delay(20);
  if(digitalRead(12)==HIGH){
    i=setCountMinus(i);
    sw12=true;
  }
}else{
    sw12=false;
}
if(i==10){
  i=1;
}
//show(i);
delay(250);
}


text:
How can I tell which pins I will have left available by looking at a shield?
I'm very new to Arduino and came to a point where I'm interested in playing with shields, such as LCDs.
For example, I really like the looks of "LCD 1602 with keypad" module, but it seems to be using a lot of pins.

By looking at a module / shield, how can I tell (or at least estimate) which pins will be used and which ones I will have left if I stack them with my Uno or Mega without printed schematics?

look at datasheet

My question is asking about figuring out (or estimating) by looking at a module.

If you look in the 'Tutorials' section of this page you can see the pins used. All of the buttons come through in one analogue input and you'll need a further 7 digital I/O pins. So 8 in total which would leave 5 analogue and 4 digital (I think) pins on an Uno.
As for how to tell which ones, does it matter in advance? I would just map the I/O in the sketch to suit. If you need to plan that far in advance though, it seems that J5 in this schematic shows which pins travel through the shield (i.e. are available to use in conjunction with the shield). Also J6 shows the 5 remaining analogue pins.

why dont you use an i2c adapter for this type of display?
search for i2c display module.
i2c only needs 2 wires for data and clock and 2 for power.
you can also easily locate the SDA and SCL pins on your arduino


text:
Where can I see the output of printf?
I would like to know where I can see the output when I use the command printf. I am programming using the Arduino interface.
Update
I'll add a few lines of code for better understanding:
#include <stdio.h>

int main(void)
{
    printf("Hello World");

    return 0;
}

your goal is to print something out in your console of the Arduino IDE?

there is no main in Arduino. You have the setup for initialization and the loop for the continuing loop

@letsjak there is a main in Arduino, but it is hidden http://www.seeedstudio.com/wiki/Where_is_Main_Function

If you're working with the standard Arduino environment and libraries then printf() won't display anything anywhere. The reason is that microcontrollers could be connected to any number of different output/communication devices in any way. stdio would have no idea how or where to send the data.
The most common approach to outputting text from an Arduino (particularly during development) is to send it to the primary UART port using Serial.begin() and Serial.print(). If the Arduino is connected to your computer via USB then the Arduino IDE's serial monitor should display the result.
If you really want to use printf() though then it is possible to make it work (or implement similar functionality). A full explanation is on this page:

http://playground.arduino.cc/Main/Printf

In setup(), start serial and choose your speed:
Serial.begin(9600);

Wherever you want to write to serial:
Serial.write("write this");

Wherever you want a newline:
Serial.println();

example
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.write("Hello World");

}

void loop() {
  // put your main code here, to run repeatedly:

}

my question is actually where am I printing if I don't define Serial in void setup() and just type printf in void loop()?

@ironzionlion if you read the printf documentation.. you will find it...

@ironzionlion it's an LCD... tadaaaaaaa http://playground.arduino.cc/Main/Printf


text:
Why my RTC module doesn't return the right date/time?
I have a RTC module DS1307 (MR005-001.2) on my Arduino Uno.
I use the Wire.h / Time.h / DS1307RTC.h libraries.
The date and time returned is completely wrong ("17:18:9 2 4 2036") ... What do I do wrong ??
Thanks !
Here is my partial code for setup() :
    setSyncProvider(RTC.get);
  if(timeStatus()!= timeSet)
     Serial.println("Unable to sync with the RTC");
  else
     Serial.println("RTC has set the system time");

This writes "RTC has set the system time", so I guess something is happening right...
Here is my partial code for loop() :
    Serial.print(hour());
  Serial.print(":");
  Serial.print(minute());
  Serial.print(":");
  Serial.print(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year());
  Serial.println();

Just as in the example ... and the date/time returned is "17:18:9 2 4 2036"

Have you ever set the time?

I guess if TimeStatus() returns TimeSet, it's because the time has been set ? Documentation says for "TimeSet"  as a return value : "The time is set and is synced. Time and Date values are not valid if the status is timeNotSet. Otherwise values can be used but the returned time may have drifted if the status is TimeNeedsSync. ". Am I misunderstanding something ? I thought the point of an RTC clock was to sync with computer's clock, so why set the time ?

It's doesn't sync by magic. You have to add code to do that (at least once). The timeNotSet is only if the library can't access the RTC module. The RTC module thinks it's 2036, and just keep incrementing the time, every second.

Can you at least confirm that the clock runs as expected, i.e. current time increases as expected?

You setup interpretation should be more like:
 setSyncProvider(RTC.get);
 if(timeStatus()!= timeSet)
   Serial.println("RTC has never been set");
 else
    Serial.println("RTC has a time");

To conditionally sync the clock to the compilation time if the clock is not running:
if (! RTC.isrunning()) {
   Serial.println("RTC is NOT running!");
   // following line sets the RTC to the date & time this sketch was compiled
   // uncomment it & upload to set the time, date and start run the RTC!
   RTC.adjust(DateTime(__DATE__, __TIME__));
}
// following line unconditionally resets the RTC to the date & time this sketch was compiled
// uncomment it & upload to set the time, date and start run the RTC!
// RTC.adjust(DateTime(__DATE__, __TIME__));

To unconditionally sync it to the compilation time, uncomment the last line and reload for one cycle, then re-comment it and reload to let the clock run itself.


text:
Going from one shift register to two shift registers
I am able to control one shift register with this shift function:
void shift (int pin) {
  shiftOut(ds,shcp,MSBFIRST,pin);
  digitalWrite(stcp,HIGH);
  delay(100);
  digitalWrite(stcp,LOW);
}

but when I move to 2 shift registers it does not add up.. how do I need to adapt this method to make it work with 2 shift registers when I am going from 8 leds to 16 leds?
My second register now just copies the first register.. I want the second register to continue instead of repeat

It sounds like the primary issue is how you've connected the two shift registers.  You just need the bit shifting out of the first one to shift into the second one so they act, together, as one longer shift register.

The example pictured is described in full here, under the heading "Example 2":
http://arduino.cc/en/tutorial/ShiftOut
As Klaus mentioned, you want to first ShiftOut the byte you intend to wind up in the second resister, then ShiftOut the byte for the first register.  This will push your first byte through to the second register.

split the data into 2 bytes, and then send those, one after the other
void shift (int pin) {
  byte data1 = 0;//shift register 1
  byte data2 = 0;//shift register 2
  if( pin<8 )
    data1 = (1<<pin);
  else
    data2 = (1<<(pin-8));
  shiftOut(ds,shcp,MSBFIRST,data2);//note that you send the data for shift register 2 first
  shiftOut(ds,shcp,MSBFIRST,data1);
  digitalWrite(stcp,HIGH);
  delay(100);//why wait this long?
  digitalWrite(stcp,LOW);
}

I think the OP's pin parameter was actually the raw binary pattern being sent to the shift register (rather than the number of the pin to be brought high).

In that case you'd use, byte data1=lowByte(pin) byte data2=highByte(pin).

Configure SPI
Hook up your shift registers

common SS
common CLK
QH* of the first shift register to SER of the next

In order to transfer the bytes

Pull SS low
ShiftOut first byte
ShiftOut next byte
Pull SS high again to finish the SPI transfer

UPDATE
This is untested, just out of memory!
#include<SPI.h>
// note that the pins for CLK and MOSI are defined here

unsigned int ledPattern = 0b1111000011110000;
// store the state for 16 LEDs here

void setup(void)
{
    pinMode(SS, OUTPUT);
    digitalWrite(SS, HIGH);
    SPI.setDataMode(3);
    SPI.setClockDivider(4);
    SPI.setBitOrder(MSBFIRST);

    // let's transfer 2 bytes
    digitalWrite(SS, LOW);
    SPI.transfer(ledPattern & 0xff00;) // high byte
    SPI.transfer(ledPattern & 0x00ff;) // low byte
    digitalWrite(SS, HIGH);
}

UPDATE II
You are by no means limited to 2 shift registers! In 2013, we did a 8x11 LED display for an upcycling art project. Eleven 74HC595 were chained to display some patterns. Each 'pixel' consisted of 3 12V SMD LEDs on a stripe. Consequently, each shift register was connected to an ULN2803.
I just uploaded a video from the construction phase, showing a test pattern.

could you give me an example how to transfer bytes?

@letsjak Done, but Gerben was faster :D

void shift(int pin) {
  digitalWrite(stcp, LOW);

  // shift the bits out:
  shiftOut(ds, shcp, MSBFIRST, pin >> 8);
  shiftOut(ds, shcp, MSBFIRST, pin);
  // turn on the output so the LEDs can light up:
  digitalWrite(stcp, HIGH);

  delay(100);
}


text:
Homemade soil moisture analog value reading jumping from 0 to max
I made a soil moisture sensor out of two metal poles, adjustable resistor, for a project I am making. The first run with the project the sensor worked amazing and gave clear and concise readings, 0-800 depending on water. I then unhooked the sensor and left it in the soil while I fine tuned the code (added warnings to the areas that would read to low), and while testing the code without the sensor being hooked up my arduino uno (Sparkfun Pro Mini) would read a value of 330(area). I thought this strange but didnt worry about it.
Well I hooked up my sensor (just power, ground, and to the A1 pin) and now my readout for the readings jump from 0 to 800, 0 to 512, 0 to another random number. I commented out everything in the code BUT the part that sets up the pin and displays the analog reading and its still the same issue. I also checked all my wires, changed the resistor setting, changed to a 10k single resistor, nothing changed.
Does anyone have any idea on what could be wrong?

Could you post the simplest code that is effected by the error?

The sensor could be oxidized. I don't quite get how you've wired the sensor. It sound like you have not connected it in a voltage dividers configuration.

I will post code a bit later (At work now). But here is how the probe is wired up. https://arduinodiy.files.wordpress.com/2012/03/build-your-moisture-sensor.jpg
I doubt the sensor is Oxidized after 30mins of overall use, I have even cleaned the probes and the same effect happens. I will create a video tonight and upload code during lunch hours.

@BrettM Here is a really simplified part of the code.
    #include <serLCD.h>
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
int moistpin = A1;  //Moisture Sensor pin
int moistreading;
int pin = 1;  //SerLCD pin
serLCD lcd(pin);  //SerLCD pin

void setup(){
lcd.clear();
lcd.print("Welcome to");
lcd.selectLine(2);
lcd.print("Water-Me 1.0!");
}
void loop(){
moistreading = analogRead(moistpin);
lcd.clearLine(1);
lcd.print(moistreading);
delay(350);
</code>

Have you tried using Serial.print() to print the value to a serial console? Could be a valid check to eliminate possible errors with the lcd.

@CalebBramwell
Yes, I have even had it just display on my computer and the output still jumps. I think I will buy a moisture sensor that I know will work.
I tried to use different type of wire, different spacing, different resistor values, nothing.

Everyone, I got it to work. After rebuilding the hardware again I found out I had my voltage divider backwards.

You are constantly running .5mA through 2 nails in wet earth. What are they made of, that won't undergo some electrolysis in 1/2 hour? Gerben appears to have hit the, er, nail on the head in one, above.
You can avoid this to an extent by using a.c. drive to the probes, which reverses the effect so they only tarnish at about the normal rate for metal X in soil.


text:
RTC MCP7940M not counting up
I'm able to set a time and to read it back without any problems but it doesn’t tick up. It stays the same. Even if I restart the serial monitor and thereby resets the buffer(?). So it seems to me that I'm able to set the registers but somehow the oscillator isn't working, do I have to tell it to use the external oscillator? Datasheet.
Using Uno Rev3.
I've connected it like this:
Never mind the BAT54 diode and the "RTC+MCU_VCC" node, its all just backup power from a capacitor. The supply voltage is alright.
The code I've been using is a modified version of this.
// SDA analog pin 4
// SCL analog pin 5

#include <Wire.h>
const int MCP7940 = 0x6F; // Address of MCP7940 see data sheets
const char* days[] =
{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
const char* months[] =
{"January", "February", "March", "April", "May", "June", "July", "August","September", "October", "November", "December"};

// Initializes all values:
byte second = 0;
byte minute = 0;
byte hour = 0;
byte weekday = 0;
byte monthday = 0;
byte month = 0;
byte year = 0;

void setup() {
  Wire.begin();
  Serial.begin(9600);
  delay(2000); // This delay allows the MCU to read the current date and time.

  Serial.print("The current date and time is: ");
  printTime();
  Serial.println("Please change to newline ending the settings on the lower right of the Serial Monitor");
  Serial.println("Would you like to set the date and time now? Y/N");

  while (!Serial.available()) delay(10);
  if (Serial.read() == 'y' || Serial.read() == 'Y')

  // This set of functions allows the user to change the date and time
  {
    Serial.read();
    setTime();
    Serial.print("The current date and time is now: ");
    printTime();
  }

  Serial.println("Thank you.");
}

// Continuous function for converting bytes to decimals and vice versa
void loop() {
}
byte decToBcd(byte val) {
  return ((val/10*16) + (val%10));
}
byte bcdToDec(byte val) {
  return ((val/16*10) + (val%16));
}

// This set of codes is allows input of data
void setTime() {
  Serial.print("Please enter the current year, 00-99. - ");
  year = readByte();
  Serial.println(year);
  Serial.print("Please enter the current month, 1-12. - ");
  month = readByte();
  Serial.println(months[month-1]);
  Serial.print("Please enter the current day of the month, 1-31. - ");
  monthday = readByte();
  Serial.println(monthday);
  Serial.println("Please enter the current day of the week, 1-7.");
  Serial.print("1 Sun | 2 Mon | 3 Tues | 4 Weds | 5 Thu | 6 Fri | 7 Sat - ");
  weekday = readByte();
  Serial.println(days[weekday-1]);
  Serial.print("Please enter the current hour in 24hr format, 0-23. - ");
  hour = readByte();
  Serial.println(hour);
  Serial.print("Please enter the current minute, 0-59. - ");
  minute = readByte();
  Serial.println(minute);
  second = 0;
  Serial.println("The data has been entered.");

  // The following codes transmits the data to the RTC
  Wire.beginTransmission(MCP7940);
  Wire.write(byte(0));
  Wire.write(decToBcd(second));
  Wire.write(decToBcd(minute));
  Wire.write(decToBcd(hour));
  Wire.write(decToBcd(weekday));
  Wire.write(decToBcd(monthday));
  Wire.write(decToBcd(month));
  Wire.write(decToBcd(year));
  Wire.write(byte(0));
  Wire.endTransmission();
  // Ends transmission of data
}

byte readByte() {
  while (!Serial.available()) delay(10);
  byte reading = 0;
  byte incomingByte = Serial.read();
  while (incomingByte != '\n') {
    if (incomingByte >= '0' && incomingByte <= '9')
      reading = reading * 10 + (incomingByte - '0');
    else;
    incomingByte = Serial.read();
  }
  Serial.flush();
  return reading;
}

void printTime() {
  char buffer[3];
  const char* AMPM = 0;
  readTime();
  Serial.print(days[weekday-1]);
  Serial.print(" ");
  Serial.print(months[month-1]);
  Serial.print(" ");
  Serial.print(monthday);
  Serial.print(", 20");
  Serial.print(year);
  Serial.print(" ");

  Serial.print(hour);
  Serial.print(":");

 Serial.print(minute);
 Serial.println();
}

void readTime() {
  Wire.beginTransmission(MCP7940);
  Wire.write(byte(0));
  Wire.endTransmission();
  Wire.requestFrom(MCP7940, 7);
  second = bcdToDec(Wire.read());
  minute = bcdToDec(Wire.read());
  hour = bcdToDec(Wire.read());
  weekday = bcdToDec(Wire.read());
  monthday = bcdToDec(Wire.read());
  month = bcdToDec(Wire.read());
  year = bcdToDec(Wire.read());
}

Okey, I've been very tired when doing this but I think the problem was with bit 7 at adress 00h. The "seconds byte". That bit is called ST and turns on or off the oscillator. Doing a bitwise OR like this: Wire.write(decToBcd(second) | 128); sets it to "1" (128 = B10000000) and it's running now.

Most external RTCs have a bit that must be set in order to activate the oscillator. In the MCP7940M this is ST.

you have a small flaw in your readTime function. If you don't want very strange seconds from the device you should combine the two nibbles packed into the seconds byte. Like this:
void readTime() {
  Wire.beginTransmission(MCP7940);
  Wire.write(byte(0));
  Wire.endTransmission();
  Wire.requestFrom(MCP7940, 7);

  int rawsecond = Wire.read();
  second = bcdToDec( rawsecond & 112) + bcdToDec(rawsecond & 15);
  minute = bcdToDec(Wire.read());
  hour = bcdToDec(Wire.read());
  weekday = bcdToDec(Wire.read());
  monthday = bcdToDec(Wire.read());
  month = bcdToDec(Wire.read());
  year = bcdToDec(Wire.read());
}

Thanks for the sample - helped me quite a bit.

found another one. When accessing the weekday you also need to cut the correct bits out of the byte like this: weekday = bcdToDec(Wire.read() & 7);


text:
Arduino PWM malfunctioning
I am controlling 4 motors using the PWM ports on an Arduino Uno (3,9,10,11). For some reason, the motor hooked up to port 11 doesn't move with my current code. I know it's a code issue because I can create a new basic code that just moves the motor and it works fine, but for some reason it doesn't in this code.
#include <SPI.h>
#include <Pixy.h>

Pixy pixy;

int personX = 0;
int offCount = 0;

void setup()
{
  pinMode(3, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  Serial.begin(9600);
  while (! Serial);
  pixy.init();
}

void loop()
{
  static int i = 0;
  int j;
  uint16_t blocks;
  char buf[32];

  blocks = pixy.getBlocks();

  if (blocks)
  {
    personX = pixy.blocks[0].x;
  }

  if (blocks){
    Serial.println(personX);
    if (personX < 110){
      analogWrite(11, 130);
      analogWrite(3, 130);
      analogWrite(9, 250);
      analogWrite(10, 250);
    } else if (personX > 190){
      analogWrite(11, 250);
      analogWrite(3, 250);
      analogWrite(9, 130);
      analogWrite(10, 130);
    } else {
      analogWrite(11, 190);
      analogWrite(3, 190);
      analogWrite(9, 190);
      analogWrite(10, 190);
    }
    offCount = 0;
  } else {
    if (offCount < 1000){
      offCount = offCount + 1;
    } else {
      analogWrite(11, 190);
      analogWrite(3, 190);
      analogWrite(9, 190);
      analogWrite(10, 190);
    }
  }
}

Also, when I take the motor and swap it with another, the old one works in the new PWM port, but the new one stops working once I put it in port 11.

Pin 11 is shared between both PWM and SPI. By activating SPI you've disabled PWM from working on that pin. Either use another PWM pin instead, or switch to software SPI on different pins.

Thanks for the info! I realized that I can just split the PWM from 3 to also control the motor previously hooked up to port 11, but because I will need to use 11 at some point in the future, I will need to know how to use SPI. I am new the Arduino so I had to google what SPI is, but how do I switch to software SPI, and will it still work with the Pixy camera?

I recommend not using software SPI if you can help it. Instead either pick a MCU with more PWM channels (e.g. the ATmega1280 in the Arduino Mega or the ATmega128A found in... no Arduino that I know of), or find an external PWM controller that can be controlled via SPI or I2C.


text:
Why is this spitting giberish instead of serial numbers?
#include <TrueRandom.h>

void setup() {
  char* ss= (char*)TrueRandom.random(111111111,999999999);
  char* finalss;
  Serial.begin(9600);
  finalss[0] = ss[0];
  finalss[1] = ss[1];
  finalss[2] = ss[2];
  finalss[3] = '-';
  finalss[4] = ss[3];
  finalss[5] = ss[4];
  finalss[6] = '-';
  finalss[7] = ss[5];
  finalss[8] = ss[6];
  finalss[9] = ss[7];
  finalss[10] = ss[8];
  Serial.println (finalss);
}

void loop() {
  ; // Do nothing
}

This is supposed to output a randomly generated number in this format nnn-nn-nnnn.
Updated Code (Doesn't seem to output anything):
#include <TrueRandom.h>

void setup() {
  String ss;
  ss = (String)TrueRandom.random(111111111,999999999);
  String finalss;
  Serial.begin(9600);
  finalss[0] = ss[0];
  finalss[1] = ss[1];
  finalss[2] = ss[2];
  finalss[3] = '-';
  finalss[4] = ss[3];
  finalss[5] = ss[4];
  finalss[6] = '-';
  finalss[7] = ss[5];
  finalss[8] = ss[6];
  finalss[9] = ss[7];
  finalss[10] = ss[8];
  Serial.println (finalss);
}

void loop() {
  ; // Do nothing
}

That's still casting.

I don't understand what you propose I'm new to C and have always used Python where casting would work.

Arduino uses C++, not C. And Python doesn't have casting.

str parentheses anything parentheses in python turns anything into a string it also works for turning str to int or int to float

It passes the argument to the str constructor, but that is not casting.

or it doesn't print you because it is in loop??? :) add line in void loop Serial.println("Already printed"); delay(1000);

I mean to see what it printed you have to reset each time. Just in case you missed that :)

Casting a number to a char* doesn't convert the number to a string. Instead it converts the number to a pointer and starts reading chars from that location.
Either pass the number to a String constructor, or pass it through ltoa().
EDIT:
String ss(...);

or
char ss[11];
ltoa(..., ss, 10);

Also, don't forget to allocate memory for finalss and NUL-terminate it.
char finalss[12];
 ...
finalss[11] = 0;

I tried to the best of my knowledge to follow your advice but seemingly I didn't understand what you meant. I updated the code.

I am really assuming you are doing this on a arduino, do you have the serial terminal switched on, you are putting that entire code in setup, means it executes only once and that maybe before you can get your serial terminal on.
So if you are putting it on setup, you need to push the reset button to get a number.
check the code at -
https://code.google.com/p/tinkerit/wiki/TrueRandom and see if that works
A better way to write your code may be -
#include <TrueRandom.h>

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

  Serial.print(TrueRandom.random(111,999));
  Serial.print('-');
  Serial.print(TrueRandom.random(11,99));
  Serial.print('-');
  Serial.println(TrueRandom.random(1111,9999));

}

void loop() {
  ; // Do nothing
}

void setup() {
  long longrand = TrueRandom.random(111111111,999999999);
  char ss[9+1], finalss[13+1];

  Serial.begin(9600);
  (void)ltoa(longrand, ss, 10);

  finalss[0] = ss[0];
  finalss[1] = ss[1];
  finalss[2] = ss[2];
  finalss[3] = '-';
  finalss[4] = ss[3];
  finalss[5] = ss[4];
  finalss[6] = '-';
  finalss[7] = ss[5];
  finalss[8] = ss[6];
  finalss[9] = ss[7];
  finalss[10] = ss[8];
  finalss[10] = '\0';

  Serial.println (finalss);
}

void loop() {
  ; // Do nothing
}

TrueRandom.random() returns a long, not a string, so you need to assign the value to a long variable while you translate it.
Your code didn't allocate any memory for the arrays you tried to use, so the third statement does that. I made them larger than the number of characters you used because the range you gave to TrueRandom.random() is a set of 9-digit numbers. I don't know how you need to punctuate your numbers so I allocated finalss[] larger yet. You should confirm that the array sizes will be sufficient for your needs.
The fifth statement, ltoa() converts a long to an ascii string in the ss[] array.
I left your finalss[x] = ss[x];' statements alone except to add the necessary NUL terminator at the end offinalss[]`.

I haven't tested this but it compiled with no errors other than my not having TrueRandom.h. But it should get you a lot closer to (what it looks to me as if) you intended.


text:
Is this set up appropriate?
Hello Internet Arduino enthusiasts!
I'm totally new to Arduino and as my first project, I'd like to make a controller connected to computer A (the master) and computers B and C as 'slaves'.
The master would simply send commands as USB mouse and USB keyboard inputs to slave computers through an Arduino controller. Think of it as a hardware KVM switch (without the V(ideo)).
Now, I'm planning to work on that during the Christmas vacations, so I need to order the parts now to receive them in time.
I was thinking I could use these parts:

Arduino Due (because it has the capability to send keyboard and mouse input)
2 SparkFun FTDI Basic Breakout - 5V, one for the mouse, one for the keyboard (per target computer) (https://www.sparkfun.com/products/9716) (because I can convert it to a 3.3v, what the Due is using)

Please consider:

The price is not really an issue for now.
I'm not worried to much about the programming.
I'll figure out how to make it work once I have the time and the items.
I know someone who has a starter kit from SparkFun, and there is an electronic store closeby, so I'm not worried about the wires.

Will I be able to make what I'd like with those basic parts, or am I missing something?
Thanks!

You need:

two MCUs that can act as USB devices (one per slave),
some way of getting the commands from the master to the MCUs

That means two Arduino Dues (or Arduino Leonardos, or SparkFun ATmega32U4 breakout boards, etc.) and one USB device of some sort that you can talk to and have send commands to the MCUs.
And perhaps something to transport the commands from the master to the slaves, but you need to think about the programming for that first since the transport and the programming will be very closely connected.

Ok, so if that someone I mentioned earlier has an Arduino Uno, I would need two Due/Leonardo, and a bunch of wires and something like this (http://arduino.cc/en/Tutorial/MasterWriter) to make them communicate together? Computer A would tell Uno to tell Dues/Leonardos to tell computer B and C how to move the mouse/keyboard, right? Thanks for your input!

I2C is not the right protocol to use for this. Normally it would be done via UART, with conversion to RS-485, ZigBee, etc. if called for.


text:
Where do serialport names come from?
I'm currently writing a tool that automatically detects connected arduinos and provides a one-button solution for flashing new firmware.
I've got a couple of arduinos at home (Diecimilla, Uno R3 SMD and some nanos from china) and each type presents with a different serial port name.
Questions

Can someone explain where these port names come from?
Can I assume that /dev/cu.usbserial-A9UPDRZB is, atleast in most cases, an arduino nano?
Are there other ways to identify the type of the board?
Is the name of the serial port some kind of hash generated from informations retrieved from the device?

They come from your OS.

You might get a lot of useful information from this question https://arduino.stackexchange.com/questions/3680/in-linux-how-to-identify-multiple-arduinos-connected-over-usb

Thanks, but this doesn't really answer my questions.

It does tell you where you can find them though.

It doesn't. It tells me where to get more information about the connected hardware. But that doesn't answer the questions about how the names are generated.

http://apple.stackexchange.com/

That answer does tell you how to make linux create names you want, or, if you prefer, to invoke programs when you plug in specific devices. You might want to indicate which OS you want to use, of course.

You cannot assume anything about serial port names. It's a choice of the operating system, and even if you find the algorithm, there's no guarantee it won't change in the future.
As a reference implementation, the Arduino IDE 1.5.x uses VID (Vendor ID) and PID (Product ID) to identify a board.
Because accessing such information depends on the underlying operating system, the IDE uses three strategies: on windows, it runs a program called ListComPorts.exe, on macosx it uses CLI tool /usr/sbin/system_profiler, on linux CLI tool udevadm


text:
Checking connection/ communication
Can I ping or “hello world” an Arduino.
Background:  My son and I bought a 3-D printer kit.
(EZ-3D)
We are having some issues talking with it.  (Well we can't talk at all.)  So we thought to upload the firmware,
It’s an Arduino Mega 2560, and when we upload the Arduino times out… but it takes a minute or two.  Can I try some simpler program just to try and talk to the Arduino?
I’m almost a “virgin” Arduino user so be gentle.

Do you have an actual programmer or do you only have the on-board USB?

@IgnacioVazquez-Abrams, Ahh.. I don't think we have a programmer, but I'm not sure.  (We downloaded the Arduino software... is that what you mean by programmer?)  I mostly an idiot in these types of things.

Something that can access the MCU at a low level, such as this or this.

Adafruit has a good set of guides to getting started with arduino:
https://learn.adafruit.com/series/learn-arduino
The "Blink" program is the equivalent of "hello world".
When testing you probably should disconnect the Arduino from the 3D printer.

Thanks Craig,  It's all built in so I can really remove anything.  (We (my son and I) did do some simple Arduino projects last year... talking to it was very easy.  Which surprised me at the time.

Blink is about the most basic Arduino program there is - it just flashes the on-board LED. But once you get that far you will have proven the Arduino software on your computer, the USB connection between your computer and the Arduino, and the basic functioning of the Arduino itself. It is a really useful step to take because you'll know that much of your system works and any troubles must be in the Arduino sketch, the Arduino itself, or the hardware connected to it. I do this whenever I update my Arduino software, connect to a new Arduino or to test a newly-built board.


text:
Unable to connect to Intel Edison Arduino kit
I just received my new Intel Edison with Arduino Breakout Kit and after hours trying to connec to it, I just can't.
I connected two USB cables to my computer, the switch between the power suply and the nearest usb cable is set to be near the usb cable as explained here : https://software.intel.com/en-us/articles/startup-guide-for-linux-intel-edison-users
And when I connect the two cables, here's dmesg:
[  +1,675635] usb 2-1.2: new high-speed USB device number 24 using ehci-pci
[  +0,098861] usb 2-1.2: New USB device found, idVendor=8086, idProduct=e005
[  +0,000008] usb 2-1.2: New USB device strings: Mfr=2, Product=1, SerialNumber=3
[  +0,000005] usb 2-1.2: Product: MERRIFIELD
[  +0,000003] usb 2-1.2: Manufacturer: INTEL
[  +0,000004] usb 2-1.2: SerialNumber: 10692CA2BC827B2B148DBA29FF184150
[  +9,018609] usb 2-1.2: USB disconnect, device number 24
[  +0,769033] usb 2-1.2: new high-speed USB device number 25 using ehci-pci
[  +0,100256] usb 2-1.2: New USB device found, idVendor=8086, idProduct=e005
[  +0,000010] usb 2-1.2: New USB device strings: Mfr=2, Product=1, SerialNumber=3
[  +0,000005] usb 2-1.2: Product: MERRIFIELD
[  +0,000005] usb 2-1.2: Manufacturer: INTEL
[  +0,000004] usb 2-1.2: SerialNumber: 10692CA2BC827B2B148DBA29FF184150
[  +0,082352] usb 2-1.2: USB disconnect, device number 25
[  +2,538308] usb 2-1.2: new high-speed USB device number 26 using ehci-pci
[  +0,086453] usb 2-1.2: New USB device found, idVendor=8087, idProduct=0a99
[  +0,000012] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  +0,000006] usb 2-1.2: Product: USB download gadget
[  +0,000005] usb 2-1.2: Manufacturer: Intel
[  +2,657426] usb 2-1.2: USB disconnect, device number 26
[déc.16 21:14] usb 2-1.2: new high-speed USB device number 27 using ehci-pci
[  +0,087183] usb 2-1.2: New USB device found, idVendor=8087, idProduct=0a9e
[  +0,000010] usb 2-1.2: New USB device strings: Mfr=2, Product=3, SerialNumber=4
[  +0,000005] usb 2-1.2: Product: Multifunction Composite Gadget
[  +0,000005] usb 2-1.2: Manufacturer: Linux 3.10.17-poky-edison+ with dwc3-gadget
[  +0,000004] usb 2-1.2: SerialNumber: 6c1877a6e8f1f5671214d752ae622b8a
[  +0,004451] rndis_host 2-1.2:1.0 usb0: register 'rndis_host' at usb-0000:00:1d.0-1.2, RNDIS device, 96:16:2c:fe:eb:a3
[  +0,001898] cdc_acm 2-1.2:1.2: This device cannot do calls on its own. It is not a modem.
[  +0,000085] cdc_acm 2-1.2:1.2: ttyACM0: USB ACM device
[  +0,002327] usb-storage 2-1.2:1.4: USB Mass Storage device detected
[  +0,000287] scsi host13: usb-storage 2-1.2:1.4
[  +0,057754] rndis_host 2-1.2:1.0 enp0s29u1u2: renamed from usb0
[  +0,008595] systemd-udevd[11838]: renamed network interface usb0 to enp0s29u1u2
[  +0,937753] scsi 13:0:0:0: Direct-Access     Linux    File-CD Gadget   0310 PQ: 0 ANSI: 2
[  +0,001719] sd 13:0:0:0: Attached scsi generic sg1 type 0
[  +0,013953] sd 13:0:0:0: [sdb] 1572864 512-byte logical blocks: (805 MB/768 MiB)
[  +0,001413] sd 13:0:0:0: [sdb] Write Protect is off
[  +0,000009] sd 13:0:0:0: [sdb] Mode Sense: 0f 00 00 00
[  +0,001013] sd 13:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[  +0,005279]  sdb: sdb1
[  +0,008088] sd 13:0:0:0: [sdb] Attached SCSI disk
[  +0,391987] FAT-fs (sdb1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[  +0,000018] SELinux: initialized (dev sdb1, type vfat), uses genfs_contexts
[  +3,143835] rndis_host 2-1.2:1.0 enp0s29u1u2: unregister 'rndis_host' usb-0000:00:1d.0-1.2, RNDIS device
[  +0,031230] sd 13:0:0:0: [sdb] Synchronizing SCSI cache
[  +0,025797] usb 2-1.2: USB disconnect, device number 27

Here, there is first something that bothers me :

Volume was not properly unmounted. Some data may be corrupt. Please run fsck.

Is this "normal" ? When running fcsk it talks about the dirty bit, I assumed it was a specific reason for Intel.
Reading the dmesg, I can see that the module will be available at ttyACM0, so I try to conenct using:
screen /dev/ttyACM0 115200

But nothing, a blank screen. I can try to hit enter one, two or millions times, nothing changes.
I'm stuck here for the moment, I don't know what to do more.
For information I'm using Fedora 20 64bits.
Thank you for your help.

Uninstall brltty if it's installed and see if that helps.  Also, I find minicom is better than screen.

Thank you for your comment. I finally found my issue ... and it's dumb as f**k. One of the USB cables is only a power supply cable, it doesn't contain the data cables inside which is needed. I switched the cables and I was able to connect easily...

D'oh. TBH I fell foul of that once.  I chopped that cable up and used it for something else so I'd never do it again.

Yeah, I don't understand the interest of removing a few cables, the cost difference is so low!


text:
Creating arduino library linking question
I know how to create my own arduino library and use it. I am using Xcode to create a c++ project. I have the arduino library files(Servo, Wire, Keypad, etc). If I want to include the Servo.h library file in my created library, how do I go about linking that? For some reason, I can't just add the Servo.h/.cpp files in my project because then I get other linking file problems that Servo.h references and are not linked in my project. Has anyone done this before?

I can't speak for Xcode, but in general with Arduino IDEs (UECIDE excepting) if you use a library within another library, that library also has to be #included in the main sketch.  That is the only way most IDEs determine which libraries need to be compiled into the finished program.
That's one of the first targets I had for UECIDE - to enable fully recursive library compilation.  Any libraries found within the master header of a library will also be included for compilation - and any found in those libraries, etc.  It took a lot of work (and it's by no means 100% perfect), which is why so few others do it and leave it up to the programmer to ensure the inclusion of the right sub-libraries in their sketch.

Yea, I guess I was just asking in general not necessarily with Xcode. If I were using Visual Studios, is there anyway I can use the current arduino library files (h/cpp) in my own library I am creating to be able to compile it before using? If I add, for example, Servo.h to my library it does not compile as there are other files Servo.h links to that I do not. Just seeing if there is an easy way to add other library files to my project to be able to compile.

No, it takes an intelligent IDE that properly understands the concept of the Arduino library to do that.  If the libraries were all pre-compiled code as .a files you'd still need to manually add all the -l... flags to the linker command, so it's not something that's unique to the Arduinosphere.  We just have a different way of telling the IDE what libraries need including (#include) than "normal" systems (which would equate to -lservo -lkeyboard etc)

Believe I have accomplished what I wanted to do. Using the VS Visual Micro plugin.


text:
What are the fundemental differences of different Bluetooth modules for beginners?
I'm a beginner to microcontrollers and electronics, albeit not really to computers and programming.
Starting out with the Arduino, I came to a point whereby I'm really interested in getting my prototype to talk to a mobile device or a computer to send and receive data (for example, send sensor data or receive commands).
Looking out, I've found out that there are different bluetooth modules with varying pricing points. Further research into differences did not reveal much to me as being a beginner, I am struggling to understand what to look out for or how to choose.
My question here is:
What are the fundemental differences of different Bluetooth modules for beginners, such as:

HC-05
HC-06
HC-07

And what should one look for when buying a simple Bluetooth module for Arduino?

As far as simplicity is concerned, HC05 would be the way to go. It is by far the most popular and there are a tonne of tutorials on using it (just a quick google search).
As for the differences:

The HC-05 module can build a connection to other modules. E.g. a Robot being a master and connecting to slave bluetooth module. Or in slave mode to make a wireless bridge to a notebook.
The HC-06 module only can be a slave. This makes it only useful for say connecting a notebook as a master to a robot with a slave module e.g. for a wireless serial bridge.
As for the HC07, support seems low so I would recommend sticking with HC05 or HC06

At the end of the day it comes down to your requirements. If you are only wanting to talk between the phone and your arduino than the HC06 would work fine, however if at some point in time you want to talk to another arduino, than hc05 would be the way to go.

Thanks Caleb, great answer! Do you have experience on Xbee BT modules?

I don't really know the differences but I've used the HC-06 modules. They are slave-mode only but that is what you need to replace a hard-wired terminal to your Arduino, such as your PC and and a USB cable, with a Bluetooth terminal. That probably covers 99% of cases where an Arduino or other MCU-based device needs to communicate to a PC or tablet that already has Bluetooth built in. For device to device communication, one of them would have to be a master, and I think that requires an HC-05.

Thanks @JRobert! Didn't know it was possible, very cool! Are you using your HC-05 to upload sketches, AND share data during operation (such as sensor info)?

The hc05 is master and slave, hc06 is only slave. The only real difference is the firmware which can be flashed, but not an easy task for a beginner.

Yes, I have uploaded sketches but it was too painfully slow to pursue it. But yes, these are designed as drop-in replacements for a wired terminal. @CalebBramwell - thank you for clearing that up. I haven't played with the different HC-0x variants yet.


text:
Arduino DUE and optocoupler 4N25
I'm using an Arduino Due board with an optocoupler 4N25 to simulate a button pressed.
I have to open and close a circuit that drive an actuator. In that circuit, when connected, with the tester I'm measuring 6V.
I connect the anode to the pin 12 and the cathode in series with a 150-ohm resistor to ground, and Collector and Emitter from optocopupler to the circuit (and a normal Blink example with the pin 12).
When optocoupler is fired on and off respectively with a tester I measure 0V and 1.7V in the arduino part, and 4V and 6V.
This is not enough and the actuator is always run. I'd like to read 0-6V instad of 4V-6V. Does this depends on how much current goes to the anode/cathode of the optocoupler? Do I have to change the resistor in the arduino part? Any kind of advice? What can I do?
I don't want to use relay because I have read that in respect to a relay they are faster, smaller, longer-lived and quieter.

Could you add a circuit diagram to your question? It might help people understand the problem better.

@PeterR.Bloomfield : ok, see the edit please

The connection to the Arduino looks OK I think. It could be a problem with how you're trying to use the optocoupler. Could you expand the diagram to show exactly how your actuator circuit is connected (including its power source and ground)?

it is a black box I cannot open sorry. I don't know anything else then the voltage when the button is pressed

I think I can act on the resistence on the arduino side to change the voltage.. am I wrong?

Since it doesn't reach 0v it means the photo-transistor isn't saturated. Try using a lower value resistor (e.g. 80Ohms). But my guess is the external actuator circuit is just connected wrong. This optocouple can sink only 50mA.

@nkint The resistance on the Arduino side only affects the LED inside the optocoupler. The correct resistor value depends on the voltage you're supplying to it.

It sounds like the 4N25 opto-coupler on its own can't do what you need because it's not designed to directly make/break a connection between a power source and its load (i.e. it isn't functionally equivalent to a relay).
Internally, the switching functionality is provided by an NPN photo-transistor. A typical open collector usage would be something like this:

(Image copyright Lewis Loflin: http://www.bristolwatch.com/ele/opto_isolated.htm)
The switch (S1) and the power source (Vi) on the left would be your Arduino. All the connections on the right would be part of your device (the actuator).
As you can see, you need 3 connections on the right: voltage source (Vcc), ground, and the output (Vo, which goes to your device). The circuit basically works by pulling the output (Vo) either up to Vcc to turn it on, or down to ground to turn it off.
It looks like all you have is Vcc and Vo, so this kind of configuration won't work. (Don't try to use the ground from your Arduino instead. That could cause various other problems.)
It should be possible to setup additional circuitry to act more like a Solid State Relay, but without a ground reference point it can be harder than it sounds. A mechanical relay might be the easiest option.

Hi! Thank you for your clear response. I have ho simulate a "press a button" functionality. I have only the 2 wire that goes in and out from the button. Don't know what else can I try to do, I can not open the device (it is under warranty). And I cannot use a Solid State Relay (it make a little "tick" when fired, and everything is for a small concert room: the silence is high priority, we already tried that, does not work). Do you have any advice?

From you clear answer I understand that 4N25 is a Phototransistor opto-isolators and not simply a Opto-isolator as I thought. Can a simple Opto-isolator can be a better solution? In case, can you advice me a model that is good with the Arduino Due?

(I have used a relay like this one: http://store.arduino.cc/product/T010010 and it does not work, too noisy for my porpoise)

@nkint It's a mechanical relay which makes a tick. A Solid State Relay (SSR) is purely electronic; it has no moving parts so it makes no noise. (Some of them even have built-in opto-couplers.) A photo-transistor is very common in opto-couplers, but there are certainly other designs. I can't recommend anything specific, but you might get some good suggestions on a more general electronics site, such as http://electronics.stackexchange.com

If he's replacing a SPST switch in common usage, the opto-isolator will be perfectly satisfactory, as long as it's wired up with the more positive switch terminal on the collector. The transistor will replicate the same behaviour as the switch: either open circuit, or connecting the two pins.


text:
How to choose between AM230x and DHT22 temperature and humidity sensors?
I'm looking forward to getting an accurate humidity and temperature sensor.
Right when I decided to go with a DHT22 module, I saw AM230x (AM2301, for example).

How do I choose between DHT22 and AM2301?

Also check out the AM2320 which uses I2C.

The AM2301 and the DHT22(AM2303) are similar in a number of ways, both in price, specs, ranges and power consumption. They are usually cased a bit of a differently, with the DHT22/AM2303 being packaged with four pins (only three are in use), and the AM2301 (formerly called DHT21) is packaged with three cables and a small plug inside of the case.
I would choose based on the usage, if I'm going to use the sensor on a breadboard or a socket (going for the DHT22 pinned version), or if I'm going to have it standalone (the cabled one).
Here are links to the datasheets:
https://kropochev.com/downloads/humidity/AM2301.pdf
https://www.adafruit.com/datasheets/DHT22.pdf

Thank you @JeanROdegard. Could you please give information on their usage as well? Which one has easier to use libraries, more info on the web in your experience? Which one uses more energy? Etc. Thanks!

They both use the same library, accessible via the arduino.cc site, which makes them identical in the way of usage. That being said, it really seems to me that there is most information on the DHT22/AM2303 around on the web. Searching for the DHTXX series, the most information you're going to find is based on the DHT11 sensor, but I recon that's because it's half the price (its very, very slow thought). I must admit, in my opinion, I go for the DHT22 as it simply looks better. Difference in energy usage between the two, I don't have a clue, sorry to say.

The AM2302 has a built-in pull-up resistor, whereas the DHT22 does not. Apart of that and de different housing they should be technically identical.


text:
What is differences in usage between a HC-05 bluetooth module and a Zigbee HC-05 module?
I have seen commercial Xbee / Zigbee clones using HC-05 integrated inside.
Are they any different than regular HC-05 bluetooth modules?

What is differences in usage between a HC-05 bluetooth module and a Zigbee HC-05 module?

Bluetooth and Zigbee are two different communication protocols. The Xbee clones you are talking about a called BTbee.
As far as im aware the BTbee modules are the same hardware/firmware wise as the hc05/hc06 modules. The only difference being the BTbee modules are in the Xbee footprint, allowing you to plug them into Xbee/Zigbee sockets.

I see! That's precisely what I was wondering though, cheers! Are there any Zigbee clones that do not use Bluetooth?


text:
Did I accidentally short something? My Arduino UNO board does not communicate with the computer anymore
I had my sketch uplaoded and everything was working fine when I tried connecting one of the input pins(pre-configured as digital INPUT) to 12V, just to see if this was being read as a HIGH as well.
It seems to have done something and the board stopped working. Moreover, all pins seem to be stuck at HIGH!
So far Ive tried the following:

reset button: doesnt help
re-upload: doesn't work - it says not in sync

Physically nothing seems to be burnt/blown. What am I missing? Have I fried my board? I hope not. PS: It was connected to a 12V external power source
Any thoughts?

If you have an Uno with the ATMega328 in a socket, you could just replace the chip with a new one (with bootloader pre-programmed). If it's the SMD version, you're out of luck (unless you have a friend that does SMD soldering).

@Gerben :That seems like a good option, do you know where I can get a bootloader programmed ATMega328?

@Gerben : Do you know where I can get a bootloader programmed ATMega 328? I think i can replace it, luckily my board came with an IC socket.

I don't know where you live. But try stores that also sell regular arduino's. E.g. Sparkfun sells them.

@Gerben Thanks Gerben. I found some for a good price on Amazon.   Thank God for Amazon! :-)

Unfortunately, the arduino's input pins are not tolerant of 12 volts, You have likely caused permanent damage to the chip =(. There is a regulator that makes it capable of being powered by 12 volts, but the input pins are different.
If you look at table 30-1 on the datasheet for the Uno's controller here you can see the input characteristics. The arduino is powered at 5v, so the max digital input voltage is 5.5v

Thats good to know. I assumed they could take anything up to 20V!(as rather silly assumption. Looks like I will have to use a voltage divider to sample the input voltage and get it under 5V for my use. Thanks Brett!