text:
Arduino GPRS (GSM) shield (SIM900) no long pins
I have bought a SIM900 shield for an ordinary Arduino Uno board. The problem is that it doesn't have long pins on the bottom side, making it impossible to click on mu Arduino Uno.
The shield I have is this:

As you can see, there are identical pin spaces next to the red and yellow plastic female pin things. Can I just solder new pins in the free spaces and will it work like that?
I notice that the yellow and red plastic female pin holders on my board are on the free spaces in this picture. I supposed I can just use the adjacent foles to solder long pins so I can use it for my Arduino?

It might be wisest to send it back, since it's not functionally an "Arduino Shield" without those.  You could modify it, but if you have to do so to even try to use it, what will you do if it turns out not to work?

Good point... I haven't come around to soldering the pions on yet. However, it took 2 months to receive the package, I am not going to send it back to China... We'll see what happens :).

Yes, you can.
There is two methods of making shields stackable:

Use the quite hard to source extra long pinned headers to go right through and down (such as these https://www.adafruit.com/products/85) , or
Use separate headers and pins and (if you are using through hole) offsetting them.

Your shield uses the second method, but the descending pins haven't been populated.  By populating those pins you are just completing the build.

Thanks, then I will solder some pins to the board so I can stack it on top of my Uno :).

You'll have to clean out the holes first.


text:
Arduino countdown timer preventing rest of program running
have a program that checks to see if an RFID tag has been read, if it has, it runs some code.
I also have a count down timer function (timer) that I'd like to run in the background. It displays the clock on the bottom of the LCD.
The problem I'm having is that when I put timer(); in the main loop, the rest of the program is delayed for the duration of the count down which means that no RFID cards are read.
The timer works, but nothing below timer(); is running. I assume this is because of the use of delay.
Does anyone know how I can prevent this? Thank you.
    #include <SPI.h>
#include <MFRC522.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

int readflag;
int initstate = 1;

int nextred = 4;
int nextblue = 8;

uint8_t readCard[4];

int minutes = 1; //start min
int seconds = 0; //start seconds

MFRC522 mfrc522(10, 9);
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

///////////////////////////////////////// Setup ///////////////////////////////////
void setup() {

    //Protocol Configuration
  Serial.begin(9600);
  SPI.begin();
  mfrc522.PCD_Init();
  mfrc522.PCD_SetAntennaGain(mfrc522.RxGain_max);

  lcd.begin(20, 4);

}

///////////////////////////////////////////////////////////////////////////////
  // Main loop
///////////////////////////////////////////////////////////////////////////////
void loop () {

 do {
   readflag = checkread();
if (initstate == 0) {
  timer(); //start timer - timer works but nothing below timer(); is running.
   lcd.setCursor(0,0);
   lcd.print("Red team next: ");
   lcd.print(nextred);
    lcd.setCursor(0,1);
    lcd.print("Blue team next: ");
    lcd.print(nextblue);

}
  }
  while (!readflag);
  tone(8, 850, 15);
  recordid();
  updatenextteamnumbers();
}

///////////////////////////////////////////////////////////////////////////////
  // Function to update team next numbers
///////////////////////////////////////////////////////////////////////////////
void updatenextteamnumbers() {
//If Blue Tag scanned show team info
  if (*((uint32_t *)readCard) == 0xACB7D573) {

    Serial.println("Blue Tag detected, showing team info");
    initstate=0;

   }

//Red Team (sequence 4, 5, 2, 1, 9)
else if (*((uint32_t *)readCard) == 0x29FDC9F5 && initstate == 0) {
    Serial.println("CARD 4 detected");
    nextred = 5;

      }

else if (*((uint32_t *)readCard) == 0x3FCE7832 && initstate == 0) {

    Serial.println("CARD 5 detected");
    nextred = 2;

}

else if (*((uint32_t *)readCard) == 0x3FCCECE2 && initstate == 0) {

    Serial.println("CARD 2 detected");
    nextred = 1;

      }

  else if (*((uint32_t *)readCard) == 0x3F7AB752 && initstate == 0) {

    Serial.println("CARD 1 detected");
    nextred = 9;

    //activateredrelay

      }

  else if (*((uint32_t *)readCard) == 0x00000000 && initstate == 0) {

    Serial.println("CARD 9 detected");
    redwins();

      }

//Blue Team (sequence 8, 6, 3, 7, 10)

else if (*((uint32_t *)readCard) == 0x00000000 && initstate == 0) {
    Serial.println("CARD 8 detected");
    nextblue = 6;

      }

else if (*((uint32_t *)readCard) == 0x00000000 && initstate == 0) {

    Serial.println("CARD 6 detected");
    nextblue = 3;

}

else if (*((uint32_t *)readCard) == 0x3F7ABA82 && initstate == 0) {

    Serial.println("CARD 3 detected");
    nextblue = 7;

      }

  else if (*((uint32_t *)readCard) == 0x00000000 && initstate == 0) {

    Serial.println("CARD 7 detected");
    nextblue = 10;

    //activatebluerelay

      }

  else if (*((uint32_t *)readCard) == 0x00000000 && initstate == 0) {

    Serial.println("CARD 10 detected");
    bluewins();

      }

 }

///////////////////////////////////////////////////////////////////////////////
  // Stores the ID of the card that's been detected in readCard byte array
///////////////////////////////////////////////////////////////////////////////
void recordid() {
    mfrc522.PICC_IsNewCardPresent();
    mfrc522.PICC_ReadCardSerial();

    for (int i = 0; i < mfrc522.uid.size; i++) {
        readCard[i] = mfrc522.uid.uidByte[i];
        Serial.print(mfrc522.uid.uidByte[i], HEX);
        }
Serial.println("");
    mfrc522.PICC_HaltA();
  }

/////////////////////////////////////////////
  // Returns 1 if a card has been detected
/////////////////////////////////////////////
int checkread() {
   if ( ! mfrc522.PICC_IsNewCardPresent()) {
    return 0; }                                        //no card detected

    mfrc522.PICC_HaltA();
    return 1; }                                       //card detected

/////////////////////////////////////////////
  // Runs if red team wins
/////////////////////////////////////////////
void redwins() {
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Red team wins!");
      lcd.display();
      Serial.println("Red team wins!");
      delay(36000);
}

 /////////////////////////////////////////////
  // Runs if blue team wins
/////////////////////////////////////////////
void bluewins() {
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Blue team wins!");
      lcd.display();
      Serial.println("Blue team wins!");
      delay(36000);
}

 /////////////////////////////////////////////
  // Count down timer
/////////////////////////////////////////////
void timer() {
lcd.setCursor(0,3);
  lcd.print("Time left:");
 while (minutes > 0 || seconds >= 0) {
  lcd.setCursor(15, 3);
 (minutes < 10) ? lcd.print("0") : NULL;
 lcd.print(minutes);
 lcd.print(":");
 (seconds < 10) ? lcd.print("0") : NULL;
 lcd.print(seconds);
 lcd.display();
 decrement();
 delay(1000);
 }
}

 /////////////////////////////////////////////
  // Decrement timer
/////////////////////////////////////////////
void decrement() {
      if (seconds > 0) {
          seconds -= 1;
      }
      else      {
         if (minutes > 0) {
           seconds = 59;
           minutes -= 1;
          }
          else  {
            timeup();
          }
       }
}

 /////////////////////////////////////////////
  // Called when time expires
/////////////////////////////////////////////
void timeup() {
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Time up!");
      lcd.display();
}

Does the timer count at all? Show us an image of what u see on your LCD and in the serial monitor

Of course not - your timer() function is blocking meaning that it does not return, and so does not permit anything else to execute, until its timing is completely done.
You will need to re-design your program.  Some options include:
1) Capturing an initial timestamp from millis() and comparing to it on each iteration through loop() to decide when your time has approximately elapsed, and to update the display with an appropriate value if that point is not yet reached. This is probably the best choice for your application, but be aware that after about 50 days of uptime, the difference calculation can be briefly incorrect, unless you account for overflow.
2) Place a short delay in the main loop (maybe 100 ms), and count iterations of the main loop until you have reached your desired time.  Beware though that your effective time will become longer if other parts of the loop take time (especially variable amounts of it) to execute.
3) Set up an event timer in the background with interrupts.  This is a lot more complex and probably not advisable in your application.

source: Stack Exchange

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

sort: votes


text:
How do I use an AtTiny85 (or other AtTiny) with Arduino?
Please mind that this is an "example" question.
How to make a "tiny arduino"?
I've ordered a bunch of ATtiny85's off E-bay, they're like tiny Arduino's.
I've set up the latest Arduino IDE and would like to run the blink example.
My process so far:
Wiring

Code
(The blink example)
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}

1. The Tiny
The ATtiny differs a little from the Arduino, don't expect it to be "fully compatible". It's a microcontroller which is just a part of an Arduino and not a full Arduino itself.
It's more of a device for "advanced users" and gives some more flexibility (at cost of usability). You can easily add this microcontroller on a breadboard, since putting a full Arduino on a breadboard makes little sense.
1.1 USB?
Since the ATtiny is a microcontroller (like the ATmega on an Arduino) and not a development board (as an Arduino), it does not have an USB connector.
The ATtiny series also does not have hardwareUART (Rx/Tx). The
You'll have to take care for a steady power-supply to your Microcontroller and the programming will be a little more tricky (details further below).
It is however possible to use SoftwareSerial and a customized bootloader. My ATtiny85 runs software serial with 115200 fine, though I have found a post which states that the internal oscillator should be tuned for a reliable connection.
1.2 RAM/program memory
The ATtiny has less RAM and program memory. This essentially means your program can't be as 'big' as on a normal Arduino. It also means that you can't use as much variables. A program for the tiny should be "small" or very efficient.
1.3 "Speed"
My ATtiny came with 1Mhz internal clock set, but if you change the fuse bits you can make it run at 8Mhz. An standard Arduino has a 16Mhz clock on the board. So your code would run 16x slower on default and 2x slower on "max". You could use an external clock for the ATtiny, but that eats up 2 pins.
The cool thing is, when you set it to 1Mhz it can run on about 2.7V (check datasheet first).
Arduino                   16Mhz
ATtiny (standard)         1Mhz
ATtiny (set fuses)        8Mhz
ATtiny (external crystal) up to 20Mhz

Higher Mhz is faster. Keep in mind that 1Mhz is roughly 1000000 instructions per second, which is still blazingly fast and good enough for most occasions, especially on such a tiny device.
2. Programming the Tiny
Most of the ATtiny's don't come with a customized (software serial) Arduino bootloader. This essentially means that you have to burn a custom bootloader by yourself or use another type of programmer. You should really watch the video from Ben Heck. He explains that Arduino boards have an USB converter on board and have custom code that is able to "bootload" your Arduino. But that ICSP/ISP programmers are used to upload programs without a bootloader/uart connection.
2.1 The programmer
You've got a load of options, check the "Programmer" item in the "tools" tab in your Arduino IDE. I'm using an USBasp which can be bought on ebay for as little as 3€. You should get one that has a selectable voltage (3.3V and 5V).
(If your ATtiny85 already has the bootloader, which is unlikely, you can use the software rx/tx pins for uploading)
2.2 Preparation
Check your microcontroller if it really is a ATtiny85 my E-bay reseller actually had one ATtiny45 included, which lead to an "error" when trying to upload.
The Arduino IDE does not know the "ATtiny board" so you can't select it easily. You'll have to let the IDE know that the ATtiny can also be programmed.
I found a very nice tutorial that describes how to do this.

Open the preferences dialog in the Arduino software. Find the
  “Additional Boards Manager URLs” field near the bottom of the dialog.
Paste the following URL into the field (use a comma to separate it from any URLs you’ve already added):
  https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json
Click the OK button to save your updated preferences.
Open the boards manager in the “Tools > Board” menu.
Scroll to the bottom of the list; you should see an entry for “ATtiny”.
Click on the ATtiny entry. An install button should appear.
Click the install button. The word “installed” should now appear next to the title of the ATtiny entry.
Close the boards manager. You should now see an entry for ATtiny in the “Tools > Board” menu.

2.3 Changing the internal clock
Some interesting post I found told me that you can change the internal clock/oscillator to 8Mhz by selecting 8Mhz (internal) as the clock and pressing the "Burn bootloader" button. This won't flash a bootloader (since that makes little sense on a Tiny85) but does change the fuse-bits.
2.4 Code
You'll not get away with the standard blink tutorial. It uses digital pin 13 (the tiny only has 8 pins).
Mind that you might have to upload using Ctrl+Shift+U (or sketch->Upload with programmer).
I used the diagram below to check the pins (from highlowtech.org)

3. Hardware
Your "schematic" isn't complete, I don't see a way to program or power the microcontroller. And you might want to take some precautions.
I personally think a well-drawn schematic looks better as a "breadboard view".

The 10Kohm pull-up resistor on the reset pin is not 100% neccesary according to the datasheet. But the Uno has one in it's reference design (which I use as a reference).
There are two capacitors, one "big" capacitor as a reservoir. If one device suddenly pulls a lot of current, this capacitor will handle that. The smaller decoupling capacitor will damp the noise of other IC's or switching supplies. It may work withouth these, but your circuit will be more reliable with them.
Mind that the decoupling capacitor should be (physically) close to the IC.
You can power the board through the programming header, but mind that you'll need a smooth voltage between (most likely) 3.3V and 5V. If you want to power it with a bigger voltage (9V battery) then you'll need a voltage regulator.

Many of your "you can't" claims with regard to serial and USB are incorrect - there is no hardware support, but both regularly done with software implementations, including for bootloader use.  It's not clear that an incomplete presentation in the necessarily limited form of an answer here is doing people a favor when there are much more developed presentations elsewhere that could be pointed to instead.  Stackexchange does not exist to duplicate the web over again...

@ChrisStratton I've updated the statements, I must agree that they were atleast half-true, since uploading the "custom bootloader" also takes an other type of programmer. I've combined (and referred to) multiple sources which can be of great ease. Another point is that someone who is relatively new can easily find all the important info on one page, and more details if they look a little further.

@ChrisStratton I've made the post "community wiki" so that everyone can contribute (I won't get points for upvotes). I believe it would be better if everyone (who wants to research ATtiny's) can contribute to an open "reference" or "starter guide". Which would work better as everyone creating their own blog ;)

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


text:
What minimal resistance should be between an input and output pin not to burn Arduino?
So, I'd like to put a button between input and output pins to read when button is pressed. What minimal resistance should I add to the scheme not to burn Arduino when the button is pressed? Does this value depend on Arduino model?

Why between an input and output? Have you read the Button tutorial on the Arduino site? https://www.arduino.cc/en/Tutorial/Button

@Majenko I see, it should probably be "what minimal resistance should be between ground and 5V", I guess..

@Majenko to make sure I understand you correctly, I've asked another question: http://arduino.stackexchange.com/questions/22672/is-that-correct-that-input-and-output-pins-are-not-supposed-to-have-current-thro

@YakovL - posting additional closely relations questions is frowned upon, it is better to edit the existing question.

@ChrisStratton I was going to edit this question after I get an answer to that other question, and "correct" question would be "What minimal resistance should be between 5V and GND pins not to burn Arduino?", but as you have answered this first formulation, I'm not sure what would be more appropriate now..

"What resistance should be between 5V and GND" pins  has nothing to do with the Arduino's processor, but only its power supply.  It's also a rather pointless question as putting a resistor there does little but drain the power supply capacitor once the supply is off.

Looking towards the high end of recommended (vs absolute maximum) current and considering Ohm's law at a 5v difference if two outputs are trying to drive each other to opposite values, you would probably get away with as little as 250 ohms.  But in most cases that would needlessly waste power, and in the case of multiple instance you could start totaling towards the limit of power supply current for the chip overall.
Typical values for external pull up resistors are more in the range of 1K-10K though higher is not uncommon - the internal pullup which you can optionally activate by setting the output state of an input pin high has a value of several tens of kilo ohms.  Lower values will consume more power, higher values may be less reliable in a noisy situation.

To read a button, normally you hook one end of the button to ground and one end to a pin in INPUT_PULLUP mode. Normally the pin reads 'high' because it is connected to +5v with a biggish resistor inside the arduino. When you press the button, it shorts out to ground and the input reads 'low'. The chip already has suitable resistors in it to handle this, and you don't need to worry about it. Just connect one end of your button the the pin, the other to the chassis, INPUT_PULLUP and away you go.
Output pins should have no less than 250Ω on them.
Beats me why you are thinking of connecting an output pin and an input pin together.


text:
Is that correct that input and output pins are not supposed to have current through them?
Are input and output pins not supposed to have current through them and only either apply voltage or "measure" it?

An output pin (on an AVR 8-bit board like an Arduino Uno) can pass up to 40mA (absolute maximum). It is recommended not to exceed 25mA.  This is called sinking current when the output pin is set to LOW, and sourcing current when it is set to HIGH.
An input pin is what is known as high impedance. I.e., it looks, to the circuit connected to the pin, like an incredibly high value resistor connected between the input and ground. Because of that only very tiny currents will ever flow through it (unless you do something silly like plug it direct into the mains).

First, you can not apply a voltage to or with an I/O pin connected to a circuit, and have no current flow as a result. There is a limit to the current a given pin on a given device can pass without damage and that is specified in the device's datasheet. How much current a given pin and circuit will pass or try to pass depends on the external circuit and the circuit internal to the device. Majenko's answer (except possibly for the specific limits, depending on the device) is correct.
You haven't specified what device. Is this a generic question or is it specific to the AVR micro-controllers used in most Arduino boards? If the latter, the limits in @Majenko's answer are also correct.

What everyone else said.
It's difficult to measure voltage without taking at least a tiny trickle of current, and that's what input pins do.
Anything that is driven needs current to drive it (power = current * voltage). However, an arduino pin - as someone mentioned - should only ever be used to supply about 25mA. Drawing a heavier current than that can fry the chip.
V=IR, so, the resistance on an output pin should be no less than 200 ohms, hence the 330 ohm current-limiting resistor you put on an LED. Power is IV, so the maximum power you can safely get get is 125mW (oh, you can get more - but you may fry your chip). This translates directly into the maximum safe brightness of a LED, the strength*speed of a motor, the loudness of a buzzer powered by an output pin.
Another big thing when trying to drive coils (motors, solenoids, relays) is that when you switch off the power to a coil, it generates a spike of voltage going the other way. This spike also can fry the chip. This is why relay shields are a thing - they contain electronics to deal with this back-emf. If you want to drive a motor and don't want to buy a shield, look into darlington array chips. I used one to run a stepper - worked perfectly.
So.

Inputs in theory need almost no current - but they do need that tiny trickle.
Outputs must have current to do any work. The amount you can get off the board without frying it is limited.


text:
Signal pin of buzzer is connected with which Arduino uno pin
I bought a 3 pin buzzer. It has positive, negative and signal pin.
I don't understand how this signal pin should be connected with the Arduino.
Here is reported the description page of the buzzer.

As I have read in the page you have linked, I think you should program the Arduino to provide an impulse to the signal (s) pin.
Therefore, to answer your question you can use any digital pin of the Arduino. And I guess that as long as the impulse last as long as the buzzer will produce a sound.
Here an example of code:
int buzzPin =  2;    //Connect Buzzer on Digital Pin3
void setup()
{
 pinMode(buzzPin, OUTPUT);
}
 void loop()
{
 digitalWrite(buzzPin, HIGH);
 delayMicroseconds(50);
 digitalWrite(buzzPin, LOW);
 delayMicroseconds(50);
}

Usually a buzzer only has two wires, positive and negative. The module you have bought though uses a transistor to drive the buzzer, which is a nice thing for very low power boards, which is not your case I believe.
Anyway, the module will take power from the positive and negative connections, allowing you to control it via the signal, from which very little power is drained.
How does a buzzer work? Actually to emit a sound via a buzzer you have to send a series of electrical pulses to the signal pin. The number of pulses per second (frequency, expressed in hertz, Hz) will determine the tone of the sound. higher the frequency, higher the pitch of the sound emitted.
Human ear is capable to detect frequencies between 20 and 20000Hz, but not everybody has such a broad perception, it decreases with age and not everybody is born with full range, so I advice to stay in the 2000-15000Hz range.
There is a nice library called Tone which helps you generate the correct signal for specific notes, allowing to even play some music via the buzzer (don't expect polyphony though!)
So, to play a note on your buzzer, assuming you have the buzzer signal pin tied to digital pin 6, you can just:
void setup() { /* empty */ }

void loop() {
    noTone(6);
    // play a note on pin 6 for 200 ms:
    tone(6, 440, 200);
    delay(200);
}

Also have a look at ToneMelody if you wish to emit specific notes (each note has its own particular frequency)


text:
Flickering LCD backlight with fingerprint scanner
I have the following problem: for some *** reason, my LCD is flashing when my fingerprint scanner turns on. Here is a video of the behavior: https://www.dropbox.com/s/mqk4u0vu8yvhiwz/IMG_3171.m4v?dl=0.
More details: I have a membrane keypad. When I start typing on it, the LCD turns on, and when I type the correct code, the fingerprint scanner turns on, and the LCD prompts the user to press a finger upon the scanner. However, then the LCD backlight starts flashing badly. Interestingly, if I just plug the wall adapter into the arduino and try the scenario, the LCD does not flash. However, if let's say 10-15 have passed since the adapter is plugged in, the LCD flickering becomes visible and irritating (again, when the fingerprint scanner is turned on). So, what could be the reason and how to fix it? Why if I just plug the adapter and execute the scenario, the LCD does not flash, and if I wait some time with the adapter plugged in, and then execute the scenario, the LCD flickers?
Just to add: My fingerprint scanner is GT511C1R (https://www.sparkfun.com/products/13007) and I am using the standard scheme for wiring it (560/1000 ohm for the RX). I am not using lcd.clear() command as I know it's heavy, and even if I don't write any text, the still LCD flickers.
Best regards,
Nike

Sounds like lack of power. What kind of power supply are you using? Is the regulator on the Arduino getting hot?

I have tried with two supplies: 1. simple small wall adapter, can't recall it's exact specs, but given its size, it will not be more than 10 watts 2. big 150 watt supply dedicated to carry a lot on it. If by regulator you mean the stuff surrounding the female 12v plug of the arduino - then, yes, it's hot.

Interesting why at the beginning (first ~10 secs) of the 'life' of the charged Arduino everything seems ok and then little by little, the LCD starts to flicker.

It sounds like you are on the cusp of thermal shutdown. Power the LCD and fingerprint scanner from a separate 5V power supply.

I sooo much wanted to avoid  that if possible, and therefore trying to find another cause of the problem. Interestingly there are tutorials on LCD + FPS on the internet like this one: http://www.instructables.com/id/fingerprint-arduino-with-16x2-LCD/ or this one: http://www.instructables.com/id/DIY-Fingerprint-Scanning-Garage-Door-Opener/ but nobody's talking about flickering in the tutorial, nor getting power from two power supply as far as I can see.

Just to mention that if I only try the FPS on another Arduino board, I get the same effect - in the beginning all seems stable, but next moments further the FPS light starts flashing: https://www.dropbox.com/s/4qe4qrd66x631en/IMG_3168.m4v?dl=0

You can use the same power supply to give a global 12v rail but step that down to 5v separately using a small switching regulator. They are cheap enough on eBay etc and avoids having another brick.

The backlights on these LCDs are just an LED array with a series resistor so the intensity will be directly proportional to the input voltage; flickering voltage = flickering backlight.
Check these things:

Measure the output of the 5V regulator with an AC volt meter to see if the regulator is oscillating when the backlight flickers, i.e. AC voltage >> 0V.  If it is, then you probably need to increase the size of the output and possibly the input capacitors.
Measure the Input-to-Output voltage differential of the regulator and multiply it by the output current.  If you dissipate more power than the thermal design allows this will heat the regulator making (1) more likely as well as driving the regulator into thermal shutdown.

If the regulator is linear, i.e. 7805 etc, you can solve both (1) and (2) by changing the regulator to a drop in switching type.  These will dissipate heat as a percentage of the output power instead of as a function of the input voltage and can be made self contained with regard to input/output capacitors which would be on-board instead of off-board.  A switcher can also do something a linear can't do:  Supply more current than the source.  A 12V 0.5A power supply into a 5V regulator can supply 5V at 0.5A with 3.5 watts of waste heat.  That same 12V supply into a decent switcher can deliver 1.14A at 5V with only 300mW of waste heat!
This PDF is an example circuit that runs about 95% efficient and fits on a 7805 footprint.
This PDF is the circuit of the 1516 switcher linked above configured to replace the NCP1117 linear regulator use on the Uno Rev3.
This PDF is a full thermal analysis of the Arduino Uno NCP1117 regulator running under the conditions stated in your question.  As you can see, you were right on the edge of what the NCP1117 could handle at 200mA (LCD plus scanner).  I have included a thermograph showing the same unit supplying 1.85A at 5V using a drop in switching regulator with no issues.

It looks like the Uno uses a SOT-223 linear regulator that has a 150C/W thermal resistance with a 150C die limit:  (150C-25C)/150C/W = 833mW.  At 12V in and 5V out, this limits the output current to 833mW/(12V-5V) = 119mA max output current.  A typical 2x16 LCD with green backlight draws 115mA at 5V leaving 4mA in your current budget for everything else.

The fingerprint scanner that you indicated has a supply current specification of <130mA, but I'm pretty sure it's closer to 130 than zero!  I'm surprised your circuit runs at all.

A huge thanks for your detailed replies! They lead me into the very right direction. So here is what was it: As I mentioned, the situation gets worse as more time passes with the 12v jack plugged in. At the same time, the regulator was getting damn hot, I could not stick my fingers to it for more than half a second. So, I kind of did what you recommended - got a regulator and put down the voltage to 7V (with 5V the display did not want to show any text). With 7V the regulator is still getting warm, but even if I left it for 10 minutes running it's not getting hot any further further. The display - it's flickering very little and only if you look at it at a specific angle, but it's not flickering overall if you look straight at it. Interestingly, I also took a look at the schemes of the display and the fingerprint scanner and it sounds like it would not be possible for the arduino to feed these two. But, the whole project is running flawlessly (at least looks so). I just hope that math equations in regards to the mA would not cause harm to the fingerprint scanner or the arduino.
So, thanks again, for your kind and detailed replies, much appreciated.
All the best,
Nike


text:
ATTiny85 433Mhz with sleep
I would like to micromize my Arduino project and move it to ATTiny85. The first step was using sleep functions because I just want it to run once a day. Now I need to connect the 433Mhz stuff but I'm getting into a fight with cores vs. libraries vs. missing functions.
No matter what core and library combination I pick, there always seems to be something missing.
/home/thijs/Documents/Arduino/libraries/VirtualWire/VirtualWire.cpp:260:18: error: 'WGM12' was not declared in this scope
     TCCR1B = _BV(WGM12) | _BV(CS10);

I have tried Tiny cores, high lowtech cores and Manchester and VirtualWire libraries. I don't want to dive into the libraries and make them 'suitable' for ATTiny because I have more than one project.
How do I approach this dependency problem?
[edit]
Found a better core here:
https://github.com/SpenceKonde/ATTinyCore

Did you check the error line? That is actually not for ATtiny85 as it does not have that Timer. It looks like there is something wrong in your setup of the IDE.

The error you posted has nothing to do with an Arduino core. This is just plain avr-libc stuff. In order to use this kind of functionality, you need to
#include <avr/io.h>

In the Arduino core, it is common to have this done by default. But if this is not the case with your chosen core, just add the #include yourself in the program.


text:
Not enough pins on Uno?
I'm making touch-sensitive, light up tic-tac-toe board.
That means 9 LEDs + 9 capacitive sensors.
Each LED needs 1 pin and each sensor needs 2...meaning I'd need 27 pins to properly control each touch-and-illuminate sequence.
There aren't enough inputs on the Uno for this, so what sort of workarounds should I explore to pull this off?

You might use "NeoPixels" instead of LED's (or other LED strip IC's). You could then "R/G/B animate" the tic-tac-toe board, using only 1 pin :)

There are a number of common solutions to "not enough pins".

Reduce the number of pins you need. This option is often discarded out of hand, but may be the best. For example, you may be able to reduce the 18 individual pins for the on/off capacitive sensor, with a different part, which may be able to give you an X,Y co-ordinate of where it is touched, with fewer pins.
Multiplex the pins. This seems to be the most likely to work in this case - you will use (for example) 9 Uno pins to power the LED and capacitive sensor on each cell, one at a time. So, for example, you might attach D1 to the top left cell, D2 to the top-center, and so forth. Then you use another pin (e.g. D10) to connect to ALL the cathodes of the LEDs (via a single transistor, to protect the Uno from too much current), D11 and D12 to connect to one of the data pins of ALL of the capacitive sensors. So, you "select" cell one, by switching D1 from LOW to HIGH. Then, you put D10 to LOW, so current will from across the LEDs. Read the capacitive sensor, which is now also powered on. Although all of the censors are connected to D11 & D12, only one will be powered on, so you will only be reading that one. Once read, you probably want to delay a few milliseconds, to make sure the light shows up. Then move on to the next cell. Go round and round all cells. The LEDs will be off 8/9ths of the time, but it will still be visible. NOTE: reading more about capacitive sensors, I see that one is input, the other output. You would need a transistor for each of the "select" pins, used as a switch to connect D11 to the correct sensor.
Do the same thing, but using a decade counter. Connect 2 pins from the Arduino to the decade counter - one to "count", and one to reset. First, strobe the reset - this will set the first output of the decade counter high - connected to cell 1. Then, when you want to move to the next cell, drop the "count" low, then high again. You are now on the next cell. Repeat until you get to cell 9, then send the "reset" (which guarantees you know where you are up to) to get back to cell 1.
Charlieplexing (mostly suitable for output only). This is a somewhat complicated, but very efficient (pin-count wise) way of running lots of LEDs off only a few Arduino pins, by using them in combination. For example, 3 pins could run 6 LEDs - if you have pins A, B and C, run one LED from A to B, one from B to C, and one from C to A; then, run 3 more LEDs in the OPPOSITE direction (don't forget your resistors!). Depending on which LED you want lit, you might want pin A high, B low, and C high impedance (INPUT). 4 pins will get you 12 LEDs, 10 will get you 90 LEDs. If you think this might be useful, check out the Wikipedia
Use chips that are designed specifically for the application you need. For example, TLC5940 chips will run up to 16 LEDs each, controlling the brightness of each LED independently. You set the brightness of each LED, then let the TLC5940 take care of the work. SIPO chips such as the 74HC595 (8 outputs) are similar, but only allow "on" or "off" for each pin. Both of these can be "daisy chained" - with the same number of Arduino pins, you can connect the output of one to the input of the next, to control more outputs.
Use multiple Arduinos. Yes, this might sound expensive, but you can use an AtMega (e.g. AtMega328, which is the same chip used in the Arduino) for a fraction of the cost. You might even use an AtTiny - even cheaper (but less memory). All of these can run the same code. This is the most flexible, but is also the most work - you would need to think about which chip does what, how they interact, and how they talk to each other. This also has the advantage that, rather than a chip that runs at 16mhz, you can now have multiple chips that each run at that speed, and have more memory each. Some applications work well with one "master" chip controlling one (or more) "slaves", whereas other applications work really well as peer-to-peer, either with each node running the same code, or each doing their own thing, and passing information to other nodes. For this example, you might use one AtTiny85 for each of the 9 cells, with an Arduino to be the master. Or, use an AtTiny84, for each row of 3 cells, with one Arduino to rule them all. The AtTiny84 has 14 pins: power, ground, reset, and 11 data pins - 2 is enough for a shared data bus, such as i2c, leaving 3 pins for each of 3 cells.
(not relevant for this example) For multiple on/off sensors (e.g. pushbuttons, switches), you can attach them through different values of resistors, and connect them to an ADC pin as a voltage divider. For example, connect ground via R0 to an analog pin; then connect to the same pin: pin -> resistor 1 -> pushbutton 1 -> +5v; pin -> resistor 2 -> pushbutton 2 -> +5v, and so forth. Build the circuit, and test each combination of switches/pushbuttons on/off, what the output will be. Then, in your code, figure out which combination it is closest to. Each resistor will need to be different resistance. If you only expect one switch to be on at once, it's a lot easier.

Could you, use a pin (or complete port) as output for 90% of the time. And use 10% of the time to sense the pin? If sensing takes a little time (and you're normally powering an LED) you might not notice the LED going off for a real small time :)

For a definitive answer, I suggest you experiment. Since the basis of capacitive touch sensors is to see how much of a capacitor is in the circuit, any component that can act like a capacitor may cause increased or decreased sensitivity

Shift registers. A single shift register is typically 8 bits, so for nine cells you will need two parallel-in/serial-out (for the sensors) and two serial-in/parallel-out (for the leds). You can chain shift registers together to manage any number of bits, at the price of speed. Each chain of registers needs two pins - data and clock, and the parallel input needs a third pin to latch the data. 5 pins all up, for any number of inputs and outputs. You could even combine the clocks by combining 'read the sensors' and 'refresh the display' as a single operation.

same as #5 - I specifically mention SIPO (shift registers) as an example.

@PailMurrayCbr You can use Shift registers via SPI at full clock speed, if they can do it. So speed is not really a problem.

Oh - capacitative sensors. I was fooling about with transistors (BD149s, I think) hooked up into darlington pairs, and I found that just touching the resistor on the base was enough to make them switch. No extra capacitor timing whatsamajig required.

As noted in Paul's comment, you could use NeoPixels instead of ordinary LEDs for the display.  Each NeoPixel contains RGB LEDs and a microcontroller that accepts a serial stream of bits in, cleans up the waveform, and passes what it doesn't need on through, to the next NeoPixel.  This would reduce the necessary number of pins by 8, since a string of NeoPixels uses one signal pin, independent of the number of NeoPixels in the string.
For the touch-sensitive (capacitive) buttons, rather than two wires per button, you can use one sense wire per button, and one drive wire per set of buttons, thus 10 pins to sense nine buttons, rather than the 18 pins mentioned in the question.  A sketch is shown below that samples nine capacitive buttons about 1300 times per second.  Here is some sample output from the sketch:
At t=2354 button 0 on at level 274  xoooooooo  nr= 3121
At t=2975 button 1 on at level 283  xxooooooo  nr= 3943
At t=3056 button 2 on at level 271  oxxoooooo  nr= 4048
At t=3235 button 3 on at level 280  oooxooooo  nr= 4283
At t=3272 button 4 on at level 278  oooxxoooo  nr= 4331
At t=3418 button 5 on at level 284  ooooxxooo  nr= 4521
At t=3460 button 6 on at level 275  ooooooxoo  nr= 4575
At t=3507 button 7 on at level 278  oooooooxo  nr= 4636
At t=3632 button 8 on at level 290  oooooooxx  nr= 4799

Each entry like “level 278” shows the value of a running average of counts for a button; since the program is using 270 as a threshhold value for a button being on, it's reasonable for the numbers to be slightly above 270.  (Note, if the call to secondlyReport() were uncommented, one would see that the running averages go on up into the 300 to 500 count range when a button is pressed.)  The strings of o's and x's show which buttons are on and which are off.  The numbers after nr= are the number of button readings taken so far.
The program implements smoothing (via a running average with exponential decay), debounce (via “holdoff” counts, as explained in detail in a previous answer), and hysteresis (going from off to on at a high count (270) and from on to off at a lower count (170)).
The program may need tuning to work with a given set of capacitive buttons.  The tuning variables used here (such as ButtonIsOn = 270, ButtonIsOff = 170, usSettle=60, usPreWait=5, and nsamp = 40) work ok with my nine-button setup where each capacitive button is attached to an input pin (like 4,5,...12) and to a 619K resistor (a size I have a number of).  The other end of each of those resistors attaches to Uno pin 13.  By changing ButtonIsOn and ButtonIsOff, one should be able to accomodate resistor sizes from a megohm on up to perhaps 4 or 5 megohms.
Note, to install Streaming.h (which doesn't increase code size) unzip Streaming5.zip from arduiniana.org in your sketchbook/libraries directory.
/* Via serial port, tell the current time when capacitive readings on
  various digital pins show a button has been "pressed" or "released".
  This version reads buttons using 13 as a drive pin, and two groups
  of pins as capacitive switches: group D = pins 4,5,6,7, group B =
  8,9,10,11,12.  Each of those pins should be connected to the drive
  pin via (eg) a 1M ohm resistor.   JW - April 2016

 See eg refs at http://playground.arduino.cc/Code/CapacitiveSensor and
 http://www.arduino.cc/en/Reference/PortManipulation and
 http://garretlab.web.fc2.com/en/arduino/inside/arduino/Arduino.h/digitalPinToPort.html
 */
#include <Streaming.h>       // provides nicer syntax for printing
enum { pinsMax = 9 };        // upper size on pins count per sample;
enum { nPortReads = 40 };    // # bit samples saved per reading;
enum { bundleSize = 16 };    // 2^j samples carried in running average
enum { drivePin = 13 };      // # of pin to drive capacitors
enum { ButtonIsOn = 270 };   // button-on level, with hysteresis
enum { ButtonIsOff= 170 };   // button-off level "    "
enum { usSettle = 60 };      // Hold sense pins low this long.
enum { usPreWait = 5 };      // Ignore probably crosstalk this long.
enum { nKeys=9 };        // # of keys in PinSet. Cannot be > pinsMax
#define PinSet "4,5,6,7,8,9,10,11,12"
unsigned int AvCount[nKeys]={0};
unsigned long int nSamples; // # of samples taken
//-----------------------------------------------------------
// Use delta=0 for startup, vs delta=1 for exponential averaging
void makeSample(int delta) {  // Take a sample, add it to AvCount
  byte counts[nKeys], j, nc;
  unsigned int bundle;
  nc = countPins7(drivePin, PinSet, counts);
  for (j=0; j<nc; ++j) {
    bundle = AvCount[j] * (bundleSize-delta);
    AvCount[j] = bundle/bundleSize + counts[j];
  }
  ++nSamples;
}
//-----------------------------------------------------------
void setup() {
  Serial.begin(115200);     // initialize serial port
  nSamples = 0;
  // Initialize AvCount[] with a bundle of samplecounts
  for (byte j=0; j<bundleSize; ++j)
    makeSample(0);      // Add sample directly to total
}
//-----------------------------------------------------------
// portSampler7(): countPins7() calls this routine, which holds
// drivePin and involved pins on current port low for usSettle
// us, then makes them inputs and turns on drivePin.  It waits
// usPreWait us (to weed out crosstalk), then reads the port
// nPortReads times as the pins recharge.
// The set of nPortReads port readings is returned in portReadings.
//
// Inputs:  drivePin, portCode, pinsMask.  Constant nPortReads.
// Output:  array of nPortReads portReadings.
//
// This version takes 8 cycles per reading.  Inputs switch
// on after about one RC time constant.  On a 16MHz Arduino an
// m-count result (that is, a zero bit in m of the nPortReads reads)
// suggests RC is about m/2 us + usPreWait us.

void portSampler7(byte drivePin, byte portCode,
          byte pinsMask, byte *portReadings) {
  volatile byte *pin, *port, *ddr;
  // pin, port, and ddr are pointers to registers with volatile
  // contents: input port, output port, direction register.
  pinMode(drivePin, OUTPUT);
  digitalWrite(drivePin,LOW);
  pin =  portInputRegister (portCode); // eg points to PIND
  port = portOutputRegister(portCode); // eg points to PORTD
  ddr =  portModeRegister  (portCode); // eg points to DDRD
  *port &= ~pinsMask;        // Turn off our pins
  *ddr  |= pinsMask;         // Make our pins be outputs, briefly
  delayMicroseconds(usSettle); // Delay to let pins settle low
  *ddr &= ~pinsMask;         // Make our pins be high-impedance inputs
  digitalWrite(drivePin,HIGH); // Turn on driver pin
  delayMicroseconds(usPreWait);
  for (byte i=0; i<nPortReads; ++i) // Take and store nPortReads readings
    portReadings[i] = *pin;
}
//-----------------------------------------------------------
/* Decode a pins-list into one list per involved port.
   Use portSampler7() to get rise-time counts for each port.

   If pins are spread across k ports, countPins7()  will make
   k calls to portSampler7().  Results are in counts array.
   Note, make pinsMax larger if pinsMax < #(pins in list).

   pinsList can look like "2,3,4,5,6" or "2,4,5,12,9,23,17,7"
   etc.  A list may contain digits and commas only.  Pins may be
   listed in any desired order.  Elements of counts[] will be in
   list-order.  Eg, in the "2,3,4,5,6" example, counts[0] is the
   count for pin 2, counts[1] is the count for pin 3, etc.  A
   larger count implies longer rise time and larger capacitance.
 */
byte countPins7(byte drivePin, char *pinsList, byte *counts) {
  byte pnum, pomask, pocode, potem, i, j, mul;
  byte sampl[nPortReads], pim[pinsMax], pat[pinsMax], bout=0, nat=0, pcon;
  char *c, cc;
  int usedPorts=0;  // To track which ports are done
  for (c=pinsList, counts[0]=pcon=0; *c; ++c) // Zero the counts array
    if (*c < '0' || *c > '9') counts[++pcon] = 0;
  // In each pass, group bit numbers by port and sample the port
  while (nat<pcon) { // Each loop pass sets one bit in usedPorts
    pnum = pocode = pomask = bout = pcon = 0;
    c = pinsList;
    while ((cc=*c++)) {  // Loop until c is at end of string
      if ('0' <= cc && '9' >= cc) {
        pnum = 10*pnum + cc - '0';
        if ( *c < '0' || *c > '9') { // See if pin # is complete
          potem = digitalPinToPort(pnum);  // Get port #, in range 1 to 12
          if (!(usedPorts & (1<<potem))) { // Is potem's port already done?
            if (!pocode)           // If pocode not set, set it
              pocode = digitalPinToPort(pnum);
            if (pocode == potem) {  // Process pin if it's in current port
              pomask |= (pim[bout] = digitalPinToBitMask(pnum));
              pat[bout++] = pcon; // Save location of pin's bit in results
            }
          }
          pnum = 0; // Clear # accumulator
          ++pcon;   // Count pin numbers
        }
      }
    }
    // Now pomask is a mask for all bits to be read from port pocode
    // and we are ready to sample current port.

    // Get nPortReads port readings into sampl array.
    portSampler7(drivePin, pocode, pomask, sampl);
    usedPorts |= 1<<pocode;       // Mark the port finished
    // Count up # of zeroes (ie rise times) in sampled bits
    for (j=0; j<bout; ++j) {
      int count;
      byte m=pim[j];
      for (count=i=0; i<nPortReads; ++i)
        count += sampl[i] & m;
      counts[pat[j]] += nPortReads - count/m; // Return the number of Zeroes
    }
    nat += bout;        // Count number of pins done so far
  }
  return pcon;          // Return # of pins processed
}
//-----------------------------------------------------------
// Measure rise times at designated pins and report
// current running averages of rise times, once per second
void secondlyReport() {
  unsigned int seconds=0, now;
  while (1) {
    now = millis()/1000;
    makeSample(1);      // Add a sample to running average
    if (now > seconds) {    // See if next second started
      Serial << "Counts: ";
      for (byte j=0; j<nKeys; ++j) // Show output
        //for (byte j=1; j<nKeys; j+=2) // Show output
        Serial << AvCount[j] << " ";
      Serial << " t=" << now << " sec." << endl;
    }
    seconds = now;
  }
}
//-----------------------------------------------------------
// Frequently sample rise times on designated pins, to
// find and report capacitive key press times & levels.
void keypressReport() {
  // Old-state and holdoff-count vars
  byte ostate[nKeys] = {0}, holdo[nKeys] = {0}, j, k;
  while (1) {
    makeSample(1);      // Add a sample to running average
    for (k=0; k<nKeys; ++k) {
      if (holdo[k]) {       // Ignore an on button during holdoff
      --holdo[k];
      } else {
    if (AvCount[k] > ButtonIsOn ||
       (AvCount[k] > ButtonIsOff && ostate[k])) {
      if (!ostate[k]) { // Were we off?
            ostate[k] = 1;  // New button press
            holdo[k] = 40; // Start a holdoff period
            Serial << "At t=" << millis() << " button " << k;
            Serial << " on at level " << AvCount[k] << "  ";
            for (j=0; j<nKeys; ++j)
              Serial << (ostate[j]? 'x' : 'o');
            Serial << "  nr= " << nSamples << endl;
          }
          ostate[k] = 1;     // We detected button is on
        } else {
          ostate[k] = 0;     // We detected button is off
        }
      }
    }
  }
}
//-----------------------------------------------------------
void loop() {
  if (0) secondlyReport();
  keypressReport();
}

authors: ชีวิตไม่สิ้น. ก้อดิ้นกันไป


text:
Assembled redboard PTH kit, when I turn it on the led flashes increasingly fast and stops
I assembled the following sparkfun redboard: https://www.sparkfun.com/products/retired/10776
When I plug the board in it start to blink but increasingly fast until the LED stops.
I'm very new to this and not sure what could be the issue or what to look. Any tips on how to debut this?
Here are images of the assembled board:

Adding a Picture of your board that you put together would be useful for others to see if there is a problem. Also compare yours to the sparkfuns one.

Just added images of the assembled board

The board seems to be working. After I plugged in an ftdi connector (adafruit FTDI friend) and uploaded blink to it, it started blinking every second instead of really fast.
The documentation was a bit confusing as it implied that blink was pre-loaded on the device but instead it would just blink extremely fast until it went all the way on and then turn off the green led.


text:
Why is my pushbutton always reading LOW?
I know this is ridiculously simple task but I spent the last two hours trying to get this to work and it is not working.  I don't have an Arduino but I have an ESP8266 Huzzah Feather which is programmable via the Arduino IDE.  So, I don't think I can provide a Fritz diagram but in any case, I'm just trying to hook up a pushbutton and be able to read a HIGH or LOW (via my Serial monitor).  Currently, everything is 0.
As best I can describe it is:
5V from Feather into resistor into one terminal of the pushbutton.  Out the other terminal of the pushbutton is a wire connecting to pin 12 of the Feather, and also a wire leading to ground.  Feather is also grounded.
My code is:
void setup()
{
  Serial.begin(9600);
  pinMode(12, INPUT);
}

void loop()
{
  int button_val = digitalRead(12);
  Serial.println(button_val);
}

It shouldn't be this hard for me.  Whenever I open and run the serial monitor, it reads 0s.  What am I missing?
Oh, an issue that I faced is determining which 2 out of the 4 terminals of the pushbutton to use.  Some resources I find say that it is the same side as the terminal the voltage is flowing into; other resources say it is the terminal opposite to the side the voltage is flowing into.  I currently have it opposite.

If you have a multimeter you can measure how to connect your switch up, measure the resistance between the pins. Two sets of pins will measure 0 Ohms, you want to use a pair which doesn't measure 0 Ohms

If you don't have a multimeter, you can connect an LED (with current limiting resistor) between your Arduino and button. It should go on when the button is pressed.

And before doing everything else read @Majenko's answer, because reading what you wrote you wired the button in the wrong way (this is the correct way)

Out the other terminal of the pushbutton is a wire connecting to pin 12 of the Feather, and also a wire leading to ground.

That sounds to me like you have connected the IO pin direct to ground.
The IO pin should connect to the same pin as the resistor that connects to +5v. The other side of the button should connect to ground only.
For instance using @HansNeve's button picture you could connect pin A to the IO pin and via a resistor to +5V, and pin B to ground.

Oh, my.  This worked wonderfully for me.  Thank you!  Both answers were helpful but I had to pick this one because it told me that my IO pin was connected incorrectly as well as which terminals of the button to use.  Now, a follow-up question: my button reads 1 without a press and 0 with a press.  Is that right or should it be the other way around?  I tried swapping terminals but that didn't seem to correct the issue.

That is completely correct. It is known as "active low" because it gives a "low" signal when you activate it.  To make it "active high" you reverse the entire circuit by connecting the wire that is connected to ground to 5V instead, and the resistor that is connected to 5V to ground instead.

@noblerare be aware, though, that the active low configuration is the most common, because you can exploit the internal pull-up (no need for resistor, just enable the pullup)

@frarugi87 thanks, I kept it as active low and modified my code accordingly.

The pins on each side of the button are shorted, the "button" is between the sides of the button. Else your code looks alright.
Edit: Here's an image which shows how a push button is connected internally, make sure you're using the correct pins.


text:
Connecting ethernet shield to computer
What configuration settings do I need to change on my computer to use the ethernet shield mounted on my Arduino UNO as I don't want to connect the ethernet shield to the router?

That depends entirely on the settings you have on the Arduino. Also note a special cross-over cable may be required.

What ethernet library do you use one the Arduino? And what is your network configuration? And what is the type of your Ethernet Shield?

Why wouldn't you want to connect it to the router? It's not directly accessible from the internet by doing so.

And what operating system are you using? (Windows/Linux/MacOS)

First off you need a basic understanding of TCP/IP networking. One you have that you need to:

Allocate yourself a new subnet - one that's not your normal local network (say 192.168.1.0/24)
Assign an IP in that subnet to your Arduino (say 192.168.1.1)
Assign a different IP in that subnet to your PC (say 192.168.1.2)
Configure your Arduino's sketch with it's IP address and netmask
Configure the PC's Ethernet interface with it's IP address and netmask
Connect the two together with a suitable cable.  If the PC's Ethernet port doesn't have auto-direction sensing you will require a special cross-over cable where TX+/TX- and RX+/RX- are swapped over.

You can try the easy way
This always works for me :D

Connect the shield to the Arduino and plug in the cables to the
PC(RJ45/Ethernet).
Go to network communication center.
Go to change adapter settings.
Select Ethernet(Arduino) and wireless(Wifi) /(internet source) and
right click.
Click bridge connections.
Wait for a few seconds.
Enjoy.


text:
Wire Library send/receive
I'm doing a project that includes an Arduino Uno and custom hardware made by me. Everything is working perfectly independently, and I'm trying to implement a way for them (the Arduino and my hardware) to work together. In order to achieve that, I am using the Wire protocol (Arduino side) and I2C (custom hardware side). From now I can send data from my hardware to my Arduino in a master-slave relation, and I have no problem with that. Please take a look at my Arduino code for better understanding:
void setup(void) {
  Wire.begin(7);
  Wire.onReceive(receiveEvent);
}

void receiveEvent(int howMany) {
  int x = Wire.read(); // receive byte as an integer
  Serial.print(x);
  if (x==0)
    state = 0;
}

So far so good. Now I want to send data from the Arduino to my custom hardware full duple, and for that I am adding this code:
void frame(void){
  Wire.write('x');
  Wire.write('\r');
}

void loop() {
  if (state == 0){
    frame();
    state = 1;
  }
}

In order to receive the 'x' char in my custom hardware I have switched the I2C protocol bit from Write to Read using I2C_FORMAT_7_BIT_ADDRESS(SlaveAddress, _address, I2C_WRITE); to I2C_FORMAT_7_BIT_ADDRESS(SlaveAddress, _address, I2C_READ); in my custom hardware code.
I don't know why, I am not receiving the data from the Arduino. Am I missing any configuration on the Arduino side?

Do I need any address in my custom hardware (I2C protocol) to receive data from the arduino side?

Who exactly is the master here? Who generates the clock? Full duplex means both devices can transmit simultaneously; this isnt possible with the I2C protocol. The Wire library is an Arduino implementation of the I2C protocol.

The master is my custom hardware (pic32mx) and the slave is the Arduino. So the master gives the clock which is 5khz for this case. I know they can not simultaneously but i AM trying to find a way for them to work in a question-answer way.

I've not done events on an Arduino so this could be a bum steer, but shouldn't the state variable be volatile and protected with a semaphore?
You are accessing it in the main program and in your event/ISR.
Secondly, no offence intended, could you replace your hardware with a bit of tried and trusted hardware to eliminate the remote possibility that your hardware is at fault.

No, you don't need to have a variable defined as volatile and protected to access it in the main program and in any other event/method.
Let's not consider any possible problem with the hardware (which is a thing I don't believe because it's already a established product). What I really want to understand if it is possible to send and receive characters through Wire protocol as long as we have the Arduino defined as slave. I am receiving data with Wire.read and after that I am sending a chunk of chars using Wire.write but I am not getting that info in my hardware.

@scuba - in actuality, Matt's concern is probably correct.  The Arduino documentation is notoriously incomplete, but http://arduino.stackexchange.com/questions/4477/what-is-the-execution-context-of-the-function-registered-via-the-wire-onreceive suggests that the event methods are called in interrupt context, which means that the state variables they share with the main thread of execution do need to be volatile.  This is in contrast to something like SerialEvent() which occurs in the main thread of execution only between calls to loop().

However it looks as if your more primary issue may be that your code would respond to the write address by sending data, when what it needs to be doing is sending data in response to the read address that triggers the request event.

You use the onReceive() and onRequest() methods of the Wire library to implement an Arduino slave. In your case, something like this:
void setup(void){
  Wire.begin(18);
  Wire.onReceive(receiveEvent);  # register receive handler
  Wire.onRequest(requestEvent);  #register request handler
  Serial.begin(9600);
}

void receiveEvent(int howMany){
  int x = Wire.read();    // receive byte as an integer
  Serial.print(x);
  if (x == 0)
    state = 0;
}

void requestEvent(){
  Wire.write("x\r");
  state = 1;
}

See Slave Receiver and Slave Sender examples for more details.

How is the requestEvent is being called in this case? I already use the wire.write to send data to my hardware but I am not using the requestEvent at all. Is it really necessary?

requestEvent is called automatically whenever the master requests data from the slave. The Arduino is not in charge of the I2C bus; it must wait till the master begins driving the clock line and specifically asks for data. Only then should you use Wire.write() else nothing happens.

So from my Pic side which function should I use to request data from the arduino?

The same function you would use to read data from any I2C slave; from the PIC32, you simply send the address of the Arduino slave (7, in this case) followed by a 1 to indicate a READ operation and you wait till this is sent. At this point, the Arduino receives this byte and interprets it as a READ, calls onRequest() and begins to place data on the bus. Your PIC32 reads the data byte by byte until it is satisfied and then sends the STOP condition. I assume you've worked with I2C on the PIC32 before?

That's exactly what I am doing in the PIC32 side but it seems the READ operation is not taking effect in the arduino side and it's not calling the onRequest() arduino function automatically.

@scuba update your post with the pic32 i2c read function. Or provide a link.

The code is kinda big, how can I show you without putting all the code here?

Let us continue this discussion in chat.

In case anyone's interested, I think the problem had to do with the slave I2C address. 0x7 is a reserved address so I've edited the answer to use an allowed address.


text:
MCP4725 not working
I tried using a MCP4725 DAC with an Arduino (M0 Pro, Duemilanove and Diecimila) and it is not outputing any voltage (just random noise).
I've been using the 2 tutorial codes fount here : https://learn.adafruit.com/mcp4725-12-bit-dac-tutorial/using-with-arduino which are supposed to generate a sinus wave and a triangle wave.
I am pretty sure it doesn't come from the Arduino because basic examples have been working so far.
Anybody had the same issue or can help on this ?
#include <Wire.h>
#include <Adafruit_MCP4725.h>

Adafruit_MCP4725 dac;

void setup(void) {
  Serial.begin(9600);
  Serial.println("Hello!");

// For Adafruit MCP4725A1 the address is 0x62 (default) or 0x63 (ADDR pin tied to VCC)
  // For MCP4725A0 the address is 0x60 or 0x61
  // For MCP4725A2 the address is 0x64 or 0x65
  dac.begin(0x62);

  Serial.println("Generating a triangle wave");
}

void loop(void) {
    uint32_t counter;
    // Run through the full 12-bit scale for a triangle wave
    for (counter = 0; counter < 4095; counter++)
    {
      dac.setVoltage(counter, false);
    }
    for (counter = 4095; counter > 0; counter--)
    {
      dac.setVoltage(counter, false);
    }
}

How do you know its not outputting what you expect?  Have you tried outputting a constant voltage and measuring that?  What does the second parameter do?

I have an electrometer on the output.
Yes.
2nd parameter is a storeflag that indicates to the DAC whether it should store the value in EEPROM so that next time it starts, it'll have that same value output. You shouldn't set the flag to true unless you require it as it will take longer to do, and you could wear out the EEPROM if you write it over 20,000 times.

The output you are generating is a triangle wave, as it states in the program. To see that you need an oscilloscope. I haven't seen an Electrometer since the 18th century.

So if i just do dac.setVoltage(1000,false); I should get a constant voltage on the electrometer right ?

Maybe on a voltmeter you might, yes. Please call it what it is, not what it was known as 200 years ago. Unless you really have got your hands on a modern electrometer, in which case you must have huge amounts of spare cash lying around.

It's written electrometer on it.

I finally got this example to work.
Details:
My A0 line was tied to ground using the solder jumper (through a 10k SMD resistor on the board it appears).
I used . . .
define MCP4725_ADDR 0x62
. . . as the base address of the chip.
My CMD to update the DAC was . . .
Wire.write(64);
. . . (64 in decimal i.e. 0b01000000)
This YouTube video helped out a lot:
https://www.youtube.com/watch?v=ngvqgIeaS9M
All the best
KenLaszlo


text:
Cheapest Arduino wireless solution for home automation
I am from programming background and newbie to this field.
Couple of days ago I brought Arduino Uno (5V). I want to control light bulb and fan from my Android. So I thought, I will buy relays and ESP8266 module and its done.
But now read somewhere that ESP8266 works with 3.3v and my Arduino supplies 5v.
Should I go for different Arduino board (like Arduino pro or Arduino mini) or is there any reliable & cheap solution that will work my Arduino Uno (5V) ?

Millions (well, hundreds or thousands) of people use the ESP8266 with the Arduino. There are trillions (well hundreds) of tutorials. Wiring it up requires two resistors. Is discovering that through google beyond your capabilities?

There are in fact around 300,000 hits on "ESP8266 Arduino" Google search. The top ones describe how to interface with a Uno, as this is a common problem. Did you check any of those before posting your question?

@Majenko I know there are 'There are trillions (well hundreds) of tutorials' and every article has something which contradict to the content of other. They left me more confuse thats why come to this forum, so if you don't want to help me its fine but keep your arrogant comment to yourself.

If you want to go for cheap just use a ESP8266 no arduino needed.

To elaborate this answer: Actually, you can download your own code to an ESP8266 module, as it comes with (a really powerful) microcontroller. Actually you can program it from Arduino IDE directly via an USB-serial cable. See https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-guide/installing-the-esp8266-arduino-addon and http://makezine.com/2015/04/01/installing-building-arduino-sketch-5-microcontroller/ as a full example.


text:
Which GSM-shield is most efficient for GPRS communication?
I tried Google, I tried a bunch of forums and I searched here. This question needs a final answer:
Which GSM-shield is most efficient for GPRS communication?
Since Arduino is the amateurs best friend for home automation and IoT, an "efficient" shield has a very low power consumption.
I am currently developing a system that collects some data from different sensors at a place far, far away, with limited access to power (e.g. it has a very small solar panel and a battery). It is also in pocket-size which makes a car battery a bad option.
Anyway, this specific device reads these sensors every 20 minutes, and if there's a deviation since the previous reading it starts the GSM module to send the new data to my API.
SMS and call features are of absolutely no interest at all.
Since these GSM-power-absorbing-current-eating-devils really like power I must think outside the box and compare different alternatives. So besides the primary question in this post, is there any way you can limit the power consumed, for example by limit the connection speed or anything like that? I'm using a M590 module at the moment, and that beast can eat around 2A if it's hungry.
Thanks in advance :)

Three main things come to mind here...
Overall hardware power consumption: if you can make the arduino sleep for those 19ish minutes and are willing to do some of the things below/linked. Adding a RTC module using the alarms to trigger a GPIO to wake the arduino might be something depending on your hardware options as well.
Software / clock speed / timing: having the perfect code will make all the difference here as well. if your test code takes say 30 seconds to wake up, read the sensors, arrange the data, wake up gprs and transmit then fall asleep again. that might be pretty good. But say for example FONA shields have a 7second wake up.. This time can be used to sample sensors and arrange the data. Then transmit straight away when it wakes up.. could save a few seconds. also switch it off asap before any other code n so on.
GPS/GPRS Reception: If you can establish a connection quickly, you will be able to put it all back to sleep quicker and draw less power. Also possibly pre-select your providers baud rate to stop it trying and waiting.
As for point 1 above,
If you are powering it via the DC jack, then it is simply using a regulator (at least on the arduino side) that is not efficient (7805)...
So one suggestion is to get a 5v switching power supply and power it via the header pins or cut/splice a usb cable. this could gain you about 20% give or take.
Finding power hacks and running mini arduino's and alternatives can get you down even lower on power consumption.
I'm not going to give references from these listings, there just a quick few results. but basically from memory and glance its a case of removing resistors/regulators/redirecting/modifying/all that stuff and then also some software hacks along with changing the clock rate as well.
https://playground.arduino.cc/Learning/ArduinoSleepCode
http://www.home-automation-community.com/arduino-low-power-how-to-run-atmega328p-for-a-year-on-coin-cell-battery/
https://learn.sparkfun.com/tutorials/reducing-arduino-power-consumption
https://github.com/petervojtek/diy/wiki/Arduino-with-Very-Low-Power-Consumption
https://www.hackster.io/techduino/reducing-arduino-power-consumption-9bcaf1
Atmega328 with minimal circuit schematics

I didn't know this thread was still alive. This was a very good and
thorough answer. I actually made a lot of tweaks since I wrote it, and switching power supply is one of them. Thanks for a great answer, and I hope someone else will also find it useful. Cheers!

GSM, by its very nature, is power hungry.  Even the most "efficient" one will blow your power budget many times over.  Since everything on GSM goes down the same digital transmission channel there would be no real difference between one with call and SMS and one without. It's all just data at the end of the day.
That said, the most efficient GSM module is one that consumes absolutely now power. And that is, at least for most of the time, perfectly possible.  By making the Arduino control the power supply to the GSM modem it can be literally turned off until an update is needed to be sent. Worst case that is on for maybe a minute (give it time to register on the network and what have you) and then off for 19 minutes. That's only on for 5% of the time - less if there isn't a change since the last time, of course.

So with that information in mind, the shield of choice is nothing that actually needs deeper consideration? The key is therefore to shut it down when it's not in use - which I already do. I did have some hope that there's tweaks I just hadn't heard of yet :)


text:
LCD readout is odd
I want it to display the current temperature in the middle of the screen, fade out for two seconds, display new temperature, rinse repeat.  This is current (see images)]2
/*
 * File:    readTemperature.ino
 * Author:  Andy Gelme (@geekscape) & Angus Gratton (angus at freetronics. com)
 * License: GPLv3
 *
 * For more information see www.freetronics.com/irtemp
 *THIS NOW WORKS!!! Except for reading to LCD.
 */

#include "IRTemp.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 9, 8, 7, 6);

static const byte PIN_DATA    = 2; // Choose any pins you like for these
static const byte PIN_CLOCK   = 3;
static const byte PIN_ACQUIRE = 4;

static const TempUnit SCALE=CELSIUS;  // Options are CELSIUS, FAHRENHEIT

IRTemp irTemp(PIN_ACQUIRE, PIN_CLOCK, PIN_DATA);

void setup(void) {
 // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // initialize the serial communications:
  Serial.begin(9600);
}

void loop(void) {
  float irTemperature = irTemp.getIRTemperature(SCALE);
  printTemperature("",irTemperature);
 delay(1000);
   // when characters arrive over the serial port...
  if (Serial.available()) {
    // wait a bit for the entire message to arrive
    delay(100);
    // clear the screen
    lcd.clear();
    // read all the available characters
    while (Serial.available() > 0) {
      // display each character to the LCD
      lcd.write(Serial.read());

  // delay at the end of the full loop:
  delay(1000);

}
  }
}

void printTemperature(
  char  *type,
  float  temperature) {

  lcd.print(type);
  lcd.print(" temp: ");

  if (isnan(temperature)) {
    lcd.println("Failed");
  }
  else {
    lcd.print(temperature);

  }
}

Try setting the LCD's cursor to the right place...

Before you write the first character of your temperature text, set the cursor to where you want that first character to display.
For example, use lcd.setCursor(col, row); to set the cursor at a specified column in a specified row.  Row and column numbering starts from zero.
You can also use lcd.home(); to set the cursor at (0,0).
The output cursor advances a column each time you write a character.

So how do I change the code to reflect that?

I have set the cursor but it still prints all over the place in the correct order.

Can you edit your question to show this change where you "set the cursor" please?

/*
 * File:    readTemperature.ino
 * Author:  Andy Gelme (@geekscape) & Angus Gratton (angus at freetronics. com)
 * License: GPLv3
 *
 * For more information see www.freetronics.com/irtemp
 *THIS NOW WORKS!!! Except for reading to LCD.
 */

#include "IRTemp.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 9, 8, 7, 6);

static const byte PIN_DATA    = 2; // Choose any pins you like for these
static const byte PIN_CLOCK   = 3;
static const byte PIN_ACQUIRE = 4;

static const TempUnit SCALE=CELSIUS;  // Options are CELSIUS, FAHRENHEIT

IRTemp irTemp(PIN_ACQUIRE, PIN_CLOCK, PIN_DATA);

void setup(void) {
 // set up the LCD's number of columns and rows:
  lcd.begin(16, 1);
  // initialize the serial communications:
  Serial.begin(9600);
}

void loop(void) {
  float irTemperature = irTemp.getIRTemperature(SCALE);
  printTemperature("",irTemperature);
 delay(1000);

  }

void printTemperature(
  char  *type,
  float  temperature) {

  lcd.print(type);
  lcd.setCursor(1,1);
  lcd.print(temperature);
  lcd.setCursor(7,1);
  lcd.print("celcius");

}

/*
 * File:    readTemperature.ino
 * Author:  Andy Gelme (@geekscape) & Angus Gratton (angus at freetronics. com)
 * License: GPLv3
 *
 * For more information see www.freetronics.com/irtemp
 *After much playing around this is the finaL result.
 */

#include "IRTemp.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 9, 8, 7, 6);

static const byte PIN_DATA    = 2; // Choose any pins you like for these
static const byte PIN_CLOCK   = 3;
static const byte PIN_ACQUIRE = 4;

static const TempUnit SCALE=CELSIUS;  // Options are CELSIUS, FAHRENHEIT

IRTemp irTemp(PIN_ACQUIRE, PIN_CLOCK, PIN_DATA);

void setup(void) {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 1);
  // initialize the serial communications:
  Serial.begin(9600);
}

void loop(void) {
  float irTemperature = irTemp.getIRTemperature(SCALE);
  printTemperature("",irTemperature);
 delay(1000);

  }

void printTemperature(
  char  *type,
  float  temperature) {

  lcd.print(type);
  lcd.setCursor(1,1);
  lcd.print(temperature);
  lcd.setCursor(7,1);
  lcd.print("celcius");

}


text:
IR remote unstable button numbers
Question
Is there a reason for unstable button numbers of an IR remote?
Desciption
I wrote a remote class where I identify the pressed number of the remote to set states. But however I get never the same number of the pressed key.
For example I press the number '1' and on the serial interface shows this:
3588650484
2740290906
3148594742
689746115
2396927248
2934053595
4294967295
3876827360

And it should look like this:
16724175 // Button 1
4294967295
16724175 // Button 1
16724175 // Button 1
16724175 // Button 1
16724175 // Button 1

Hardware
I am using an arduino UNO board and the standart remote of the starter kit. There is no name just 'SPECIAL FOR MP3'.
Some more infos
Ok, in my first project I used the code from Noreddine Kessa(Example Project) which works fine. Next I copied some code in my new class 'IRControl.cpp' ( you can see below). Then I created an object IRControl in the main.cpp and run the menu() in the loop.
h-File:
/*
 * IRControl.h
 *
 *  Created on: 04.04.2016
 *      Author: David
 */

#ifndef IRCONTROL_H_
#define IRCONTROL_H_

//Remote Defines
#define buttonON 16753245
#define buttonMode 16736925
#define buttonSoundOff 16769565
#define buttonPlayStop 16743045
#define buttonTrackBack 16712445
#define buttonTrackForward 16761405
#define buttonEQ 16769055
#define buttonMinus 16754775
#define buttonPlus 16748655
#define button0 16738455
#define buttonRepeat 16750695
#define buttonJSD 16756815
#define button1 16724175
#define button2 16718055
#define button3 16743045
#define button4 16716015
#define button5 16726215
#define button6 16734885
#define button7 16728765
#define button8 16730805

#include "IRremote.h"
#include "wiring_private.h"

enum zustaende{Motor1, Motor2, Motor3, Sleep};
extern int zustand;

class IRControl {
private:
    IRrecv *irrecv;
    decode_results remoteValue;
public:
    IRControl(int RECV_PIN);
    virtual ~IRControl();
    void menu();
};

#endif /* IRCONTROL_H_ */

cpp-File:
* IRControl.cpp
 *
 *  Created on: 04.04.2016
 *      Author: David
 */

#include "IRControl.h"

IRControl::IRControl(int RECV_PIN) {
    // TODO Auto-generated constructor stub
    irrecv = new IRrecv(RECV_PIN);
    pinMode(RECV_PIN , INPUT);
    irrecv->enableIRIn();
}

IRControl::~IRControl() {
    // TODO Auto-generated destructor stub
    delete irrecv;
}

void IRControl::menu() {
    if (irrecv->decode(&remoteValue)) {
        //lReceived = remoteValue.value ;
        Serial.println(remoteValue.value);
        /*
        switch(remoteValue.value)
                {
                case button1:
                    zustand = Motor1;
                    //digitalWrite (LED1, HIGH); // for control
                    break;

                case button2:
                    zustand = Motor2;
                    //digitalWrite (LED2, HIGH);
                    break;
                case button3:
                    zustand = Motor3;
                    //digitalWrite (LED3, HIGH);
                    break;

                case button0:
                    zustand = Sleep;
                    break;

                default: break;
                }
                */
        irrecv->resume(); // Receive the next value
      }
}

Where the problem could be
I think there could be a problem with the IRrecv *irrecv;. But i'm not sure.
Thanks for your help

I'd say you're just "receiving" random numbers. That most likely means your hardware setup is not what it should be. Unfortunately your answer only mentions software so nothing to comment about until you explain your hardware setup. And instead of immediately complicating things with complex code, I usually just start with the library's example code and check that my hardware setup is OK. Only then I continue with the software.

there are a number of ir protocols, you need to understand which one you are using, and use the right software/hardware and/or settings.  you cant just randomly throw ir at some random tool and expect it to work.

it not giving consistent results indicates that you have not matched up the receiver (protocol, frequency, etc) to the transmitter (the remote).

Thanks for your answers. However I used the same hardware setup for both projects. The problem appeared as I exported the code to my new class.

So I guess the general setting should be fine and there is an issue in the code.

Please post the code where you call the library. In particular where do you make an instance of IRControl?
I am guessing you are doing it at global scope which means you are probably running into the C++ static initialization order fiasco.
What it is: http://www.parashift.com/c++-faq/static-init-order.html
How to prevent it: http://www.parashift.com/c++-faq/static-init-order-on-first-use.html
To prevent this, you should not be doing this in the class constructor:
irrecv = new IRrecv(RECV_PIN);
pinMode(RECV_PIN , INPUT);
irrecv->enableIRIn();

Instead, make a begin function (like most Arduino classes do) and call that from setup.

btw. is http://www.parashift.com/c++-faq/static-init-order.html down?

Ok it works. I i create the objects in the main.cpp and changed my code in the IRControl. I think your answer was a good help. Should i update my question and add my solution?

btw. is parashift.com/c++-faq/static-init-order.html down? looks like it. It's the top Google hit for C++ static initialization order fiasco though.

Should i update my question and add my solution? - not really, because the question part is for the question. If you want to amplify on my answer with example code, etc. then make your own answer and explain what you had to change and why. It doesn't make a lot of sense if a question answers itself.

What you can do, if my answer was largely correct, but you want to add more detail, is to edit my answer and add in the detail. The edit will be added to an edit queue, but it will no doubt be accepted. That way the answer is fleshed out. If you think that your code is substantially different to what I posted, then post it as a separate answer.

Don't just post all your code though. Post the relevant parts, that solved the problem. This will help others in the future.


text:
Connecting Pulse Sensor to RFDuino Simblee
I am trying to make a heart rate sensor watch. I am trying to do this using a Simblee (www.simblee.com) and a Pulse Sensor (www.pulsesensor.com) however they will not work! The original code from pulsesensor uses Timer2, which I commented out in favor of delay(2) (i'm new to Arduino and it seemed to work). I am getting readings over serial they just seem to be in a wave instead of a pulse. I need to get this working as I am out of time and money ;) Would anyone have any ideas on how I could get them working?
ALL CODE ON GITHUB (https://github.com/shadow85926/SimbleeArduinoCode)
Thank you.
Wave pattern:
https://i.stack.imgur.com/zw7tP.jpg


text:
What would be the architecturally-right place to put custom -D defines?
What I am trying to accomplish is to include information about the state of my environment at build time in my code. For example, I may want the setup() code to print the git sha it was built against, and the time of build.
There are two related issues here:

How to include that information in the code
How to specify to the build environment what to generate in the first place.

The first can be addressed in a number of ways:

-D options can be generated at build time, and the corresponding defined macros expanded in the code. For example, the compiler could be invoked as g++ -DGIT_SHA=$(git rev-parse HEAD) -DDATE=$(date '+%Y%m%d-%H:%M:%S'), and my code could have something like #define strfy(_x) #_x followed by Serial.println(strfy(GIT_SHA));. Or the build tool could generate a header file that would define these as external string variables, which the main sketch could then include and print. Or any other number of tricks.

The question I am really asking is: how should I specify this sort of stuff for arduino-builder?
Ideally, it would be a custom recipe in platform.txt, but if there is a way to invoke shell commands in recipes and use the results to modify other variables (such as preproc.macro.flags), I haven't been able to find it (if there is documentation, it's really well hidden). Ideally I would want to be able to say preproc.macros.flags=-w -x c++ -E -CC -DGIT_SHA=$(git rev-parse HEAD) and have the shell command be executed at the point.
So, before I set out to hack arduino-builder, do people have any opinion on this? My main criterion is something that would be of general value and has a chance of being incorporated in the code, rather than a kludge that only works for me and which I have to patch every time I upgrade. Please do not suggest workarounds. I can think of several myself!
I did try to search, and this sort of issue has come up before, but I didn't see any satisfactory answers from people who knew what they were talking about.
Thanks!
/ji

That is a tough one...  Because arduino-builder is basically a custom go script you don't get the facilities you get in a Makefile, like shell execution.
I would be inclined to do this kind of thing outside that environment - use some external program or tool to generate a config.h file (maybe use something like GNU Autotools) that contains your custom defines. That can then be #included in your sketch.

For the date and time of compilation there are predefined preprocessor symbols: __DATE__ and __TIME__.

Unfortunately these are at compile time and not at link time.

Seems appropriate; the OP used compiler command-string examples.

I'm not stating it is inappropriate. I'm adding that this solution has a drawback.
From experience I learned that a IDE that only builds changed files (like the newest versions of the arduino IDE) will end up with outdated dates and time on the Arduino.


text:
How do I connect a vibration motor to Arduino?
I'm trying to figure out how to connect a vibration motor to my Arduino.  I've come across this resource and it seems pretty straightforward though for a while my eye glazed over at how complicated the circuit was (do I really need all of that to run my vibration motor?).
My real question is that I have a vibration motor similar to the picture in the link and I'm trying to figure out how to actually connect it to my breadboard.  Do I have to solder wires onto those flimsy ends or is that a better way to get this to work?
Thanks!

What application do you need it for? I've seen vibration motors employed as regular motors to drive a tiny worm drive.

Lets break down the circuit and have a look why everything in that circuit is there and what it does.
First we have the 33R resistor before the motor which limits the current to the motor. This particular motor is rated at 75mA and has a starting of 85mA. The 33R resistor limits the current to 130mA maximum through the motor. If the risk of the motor pulling too much current is an issue then stick a fuse in-line
Then there's the motor, not much to say here really. It's whatever motor you're using.
We then have both a diode and a capacitor across the motor. I find this a bit strange, I've seen the use of flyback diodes, I've seen the use of snubbers, but both? The purpose of the diode is to allow a return path for any spikes caused by switching off power to the inductive load (the motor) which stops them from damaging the transistor. For the capacitor, just remove it, it's not got any use here really.
Then comes the transistor, it might be easier to think of a transistor as a switch (especially in this example). When you put a little bit of current on the base, the transistor 'opens' allowing the motor to connect to ground. The reason we have to use a transistor is because the outputs of an arduino are only able to supply a maximum of 40mA, we need more than that to run our motor. Fortunately, the transistor is not going to need any more than 5mA on it's base which is why we use it to 'switch in' components that require more voltage/current. The 1K resistor on the base is to limit the current coming from the arduino and preventing it from killing our poor transistor.
tl;dr - You need everything except the capacitor

There are actually a number of things wrong with that circuit.
First the motor runs from 2.5 to 3.8V, yet they show it running off the 5V supply pin.
Secondly they include a 33Ω resistor to "limit the current". It doesn't! It drops a voltage depending on the current flowing through it, and the current flowing through it depends on the speed and load of the motor at the time.  So the motor itself will be getting a fairly random voltage applied to it, which at times will be below the specifications.
E.g.:

The start current is 85mA.  V=RI, 33*0.085 = 2.805V. 5 - 2.805 = 2.195V: way below the 2.5V required minimum.
The run current of 75mA calculates as: 33*0.075 = 2.475. 5 - 2.475 = 2.525V: only just enough for it to run.

So it should be powered from a 3.3V supply that has enough current capacity to drive it (85mA) and the 33Ω resistor should be removed entirely.

I'm really grateful for your answer. I've been doing nothing but LEDs for so long I'd fallen into a trap and completely forgotten something so basic. Thanks for waking me back up

I've never used a vibration motor, but I think you do need all of the circuit.  Its says in the text, but the transistor is needed because the Arduino 'doesn't supply enough current through the output port' and the diode and cap are required to prevent spikes.
As to the flimsy wires you could solder them onto a bit of strip board and then solder "proper" wires of connectors onto the board too.

You could make a simpler circuit by removing the diode, capacitor.  BUT this comes at the cost of having a circuit that could kill your arduino.
Stick with it and build the entire thing.  This isn't a shortcut worth taking.

I wouldn't even give the suggestion of removing the diode. It's general practice to always put a diode across an inductive load. Unless you like dead transistors

I didn't say it was a good idea.  Only that it was possible.


text:
Arduino Uno + Jaguar Speed Controller + CIM Motor (12V DC)
I have connected a CIM motor to a Jaguar speed controller, powered by a 12V battery. The Jaguar is connected to an Arduino Uno via the signal and ground. Also, I have two switches connected to the Arduino, for forward and reverse of the motor.
In the code, for speed of the motor, I have set 90 as the mid point and 100 for forward and 80 for reverse. When I push the reverse button, the motor runs smoothly in the reverse direction at the set speed. However, the problem is, when I press the forward button, the motor runs seemingly slower in the forward direction than the set speed.
My logic here was, if I have set speeds in forward and reverse at +/- 10 from the mid-point, the motor should run at the same speed in the forward and reverse direction, but this is not happening.
I am pasting my code below. Any help would be much appreciated. Thank you!
#include <Servo.h>

int forwardPin = 2;
int reversePin = 4;
int motorPin = 10;
int fwdReading = 0;
int revReading = 0;

Servo myservo;

void setup() {
  TCCR1B = TCCR1B & 0b11111000 | 0x04; // PWM Freq. at 122Hz
  pinMode (forwardPin, INPUT);
  pinMode (reversePin, INPUT);
  myservo.attach(motorPin);
  myservo.write(90);  // set servo to mid-point
}

void loop() {
  fwdReading = digitalRead(forwardPin);
  revReading = digitalRead(reversePin);
  if (fwdReading == HIGH) {
    myservo.write(100); // forward
  } else if (revReading == HIGH) {
    myservo.write(80); // reverse
  } else
    myservo.write(90); // neutral
}

When I read Jaguar speed controller I imagined you were mounting this on a Jaguar XD anyway how do you detect that the motor is slower? How much slower? Did you get quantitative measures (e.g. with an encoder)?

@frarugi87 Haha...
Btw, no I haven't measured it, but by eyeballing one can tell that it is slower than the other direction.

Is there anything attached to it? And.. It would be better to test it using an encoder. And, in the end, remember that the controller board does not control speed directly, but just the voltage (and so the speed will not be controlled very well). I don't know if that controller board supports a speed feedback, but if you require a precise speed then you'd better switch to a closed loop design (either integrated - but I don't know them) or build one yourself

I searched for the library you're using and the arduino website mentions :

0 being full-speed in one direction, 180 being full speed in the other, and a value near 90 being no movement

From this we can take that the value 90 is not perfectly in the middle of the speed range therefore 10 points under 90 won't necessarily be equivalent to 10 points above 90.
My only advice is to try and find the equivalence point yourself by trail and error.
Even though 90 seems to cause no movement, try 89 or 91 see if they also have the result and so on.
Or simply try different values to get same speeds in different directions, it's ok if you use different values (away from 90) for the two different directions :P.
Gd Luck


text:
Arduino Due Serial garbage
I have made a custom board based on the Arduino Due but have some problems with the Serial communication with the 16u2 chip.
i have usb connection with the 16u2 chip and was able to load the arduino-due usb serial hex over the usb port. the usb now shows up as arduino com port. now when i try to load a sketch it says No device found on COM12. the SAM chip is erased but it can't load the new sketch.
now when i load a sketch with a simple serial print at 115200 over the native port. the SAM chip is programmed correctly. when i open the serial monitor i receive data but it is garbage! the garbage is always different. the sketch is at 115200 and the monitor also at 115200.
this would explain why it can't upload a sketch with the 16u2.
the same sketch on a original arduino due works fine.
the transmit an receive led are blinking.
What would cause this garbage in the connection where do i start looking?

SAM chip not running at the speed you expect it to run at?

Tip: Output a constant stream of "U" through the serial port. Measure the resultant frequency on the TX pin (before it gets to the 16U2). Double the frequency. That is the actual baud rate it's transmitting at. Compare that to what you expect it to be (115200). Any difference can indicate a difference in source clock speed.

You mean the serial speed or the actual chip speed?

The actual chip speed determines the serial speed. If that is wrong the serial will be wrong. By analysing the serial speed you can back-track that to the chip clock speed.

Alright thank you for the tip! will try to messure the frequency of the TX.

What could cause the chip to run at a wrong speed?
and is there a way to test te speed at what speed a chip is running?

Incorrect crystal or incorrect fuse settings. Testing the TX is a good way of measuring the clock speed. You get a ratio of what you want and what you measure, then apply that ratio to the clock speed you want - the result is the actual clock speed.

was not able to get a frequency test but did a speed test sketch on a original Due and 2 of my own builds.
The Due runs at 6745 Millis
and my own at 6281 Millis so it seems to be running slower then the original Due.
the crystal used is:
link.
i don't have any knowledge of fuse settings so will have to read into this.
if i have a different crystal would this need different fuse settings than a original Due?

Umm, well according to the schematics the Due has a 12MHz crystal. Yours is 16MHz. And you numbers suggest it's running faster than the original not slower, which would make sense. So yes, you will need to change the fuse settings to get the correct speed from a 16MHz crystal. At the moment you are most likely overclocking it.

sorry that was the 16U2 crystal it is a 12MHz crystal:
link
Yes you are correct its the other way it is running faster.

Have you adjusted the crystal's capacitors to suit the crystal you have chosen?

I have checked and it seems that they are 12pF and the datasheet for the crystal says it needs a 8pF.
Could this be the solution so my problem?

The crystal has a load capacitance of 8pf - that means it needs around 16pf load capacitors.

Oke so replace them with 16pF or is the 12pF close enough?


text:
Bluetooth and another sketch
I uploaded a bluetooth sketch from IDE (File->Examples->Firmata->Standard Firmata) to Arduino Duo.
Now if I have a sensor attached to this Arduino, I can use bluetooth from another device (Raspberry pi or mobilephone) to read the sensor.
But what if I want to do something in the arduino itself? I see only one option
which is to edit the standardfirmata to read the sensor and do something. So multiple sketches running in one sketch.
Am I correct?

If you programmed the Arduino to read the sensor and the do something else, what would you do if a second request to read the sensor came in before you had stopped doing something else?
I don't know anything about Firmata.  Could you add two sensor's, so the Pi could select to read from sensor 1 or sensor 2?  If you could do that then you alter the 'readSensor2()' function so it did 'Something else'.  This way you are exploiting any control/synchronisation logic within Firmata.  If you need 'readSensor1()' to automatically 'do something else' ever time it was called then couldn't you just tag it onto the end of 'readSensor1()'.