text:
Transistor Switching
I'm hoping that someone will be able to help me. I'm looking to produce a power interrupt for testing. I'm looking to have 28V DC input flowing to an output which I can hook up to a load and then switch on and off using an Arduino. I'm thinking of using an NPN high current transistor, I have built the box and code which runs fine. The issue I am having is the pin output on pin 13 doesn't have enough current to switch the transistor, can anyone recommend a transistor that would be able to take the high current and be switched by the Arduino? If you would like a schematic to help you understand it I can provide one!
Thanks for reading,
Lewis

Define "high current" - also how is the transistor wired?

Around 4A, see photo above for wiring of transistor

For high side switch I would use PNP not NPN, and switch it using an NPN. To be more specific I would use a P-channel MOSFET and switch it using an N-channel MOSFET or NPN transistor. Google "MOSFET High Side Switch" and you will find many circuits.

Here is one example: http://electronics.stackexchange.com/questions/42030/p-channel-mosfet-high-side-switch

Your current circuit will only apply around 4.3v to the load (assuming a 5v Arduino PSU). Can you switch the ground side rather than the 28v side? Circuitry will be far simpler.

If you did manage to switch the transistor on, It would only output 4.3V, the rest would be dissipated in the transistor. If you managed to switch 4A this would dissipate 96W - and the transistor would melt.
A MOSFET would be a better option and could be easily switched by the Arduino. (I regularly switch 10A using a MOSFET and Arduino.)
This assumes you can put the MOSFET in the negative lead. If not you should use a P-Channel MOSFET, but you need a more complex circuit to drive it.
Have you considered using a relay module?

Thanks for the answer! So I'd be able to use the MOSFET in this configuration and get the Arduino to switch it. I did look at using a relay but I didn't think that the Arduino would be able to switch it, this would be a simpler solution though, any relays that you could recommend ?

Could I use this relay ?  http://uk.rs-online.com/web/p/solid-state-relays/6996632/

Or this transistor? http://uk.rs-online.com/web/p/mosfet-transistors/5411720/

@Lewis, that SSR is rated at 4 A max.  Look for an 8 to 10 A rated SSR or electromechanical relay to handle your 4 A load.   The P mosfet is ok except its V_GS is limited to ±20 V, hence the gate must be above 8 V if the source or drain is at 28 V.  Anyhow, to definitely turn the P mosfet off, you need to have the gate above 26 V, and to  definitely turn it on, below 24 V (assuming V+ = 28 V).   The Arduino's pin 13 is  (Vcc+0.5 V) max, too low to drive the P mosfet's gate without using an intermediate N-fet or NPN or some diode network.

Thanks for all your help guys, my knowledge is still getting there, thanks for being patient. So this relay would be able to be controlled by the Arduino due to its low control voltage? @jwpat7

http://uk.rs-online.com/web/p/solid-state-relays/2448987/

@Lewis, yes, that would work.   But so would some less-expensive RS items, as long as switching type is DC or AC/DC, and Minimum Control Voltage is somewhere under 5 V.  Also on ebay you might be able to buy a batch of 5 or 10 ea. 25A SSRs for a lower cost than that one RS 6A SSR.


text:
Why is my arduino acting like a radio? And is there a way to abuse this?
I am playing around with an arduino and a cheap SDR dongle and I just noticed something strange!
When I play a tune on pin 13 with just a random piece of wire connected to the pin (Using the Melody example from the arduino page: http://www.arduino.cc/en/Tutorial/Melody)
I can pick it up as AM sound on my SDR on exactly 64Mhz even as far as 15meters away through walls with a little gain!!!
What magic is going on here and secondly and maybe most importantly would there be a relatively easy way to pick up the signal using just an arduino and cheapo components?
(Just for educational purposes of course, I know that there is better options depending on what I need to send)

I would like any qualified guess as to what is going on, I am genuinely puzzled...

https://www.youtube.com/watch?v=HV6YQ4WKtYY

That gives a good explanation for the signal. Thanks, still don't understand how the internal RF-clock can affect pin output, interresting that it can be hacked into transmitting FM signals too!

My guess is you are seeing harmonics of your pin's output. Fast toggling digital signals, like your PWM, carry heavy harmonic content. I would expect many more peaks, but your setup may be by pure luck (stray inductances and capacitances) well tuned for that particular band.

@EdgarBonet the display isn't wide enough to see the other harmonics

I did something like that a while ago. Hardware:

Code:
const byte ANTENNA = 9;

void setup()
  {
  // set up Timer 1
  TCCR1A = bit (COM1A0);  // toggle OC1A on Compare Match
  TCCR1B = bit (WGM12) | bit (CS10);   // CTC, no prescaler
  OCR1A =  9;       // compare A register value to 10 (zero relative)
  }  // end of setup

void loop()
  {
  pinMode (ANTENNA, OUTPUT);
  delay (500);
  pinMode (ANTENNA, INPUT);
  delay (300);
  }  // end of loop

The 16 MHz clock is divided by 10 (that is, 1.6 MHz) and that is used to toggle pin 9 at that rate, giving a frequency of 800 KHz, since one toggle turns the output on, and second toggle turns it off.
If you hold the Arduino near an AM radio tuned to around 800 KHz you should hear a hissing toggling on and off (like Morse code) as the carrier is turned on and off for 0.5 / 0.3 second intervals.

would there be a relatively easy way to pick up the signal using just an arduino and cheapo components?

I think you might find making a receiver a bit harder than a transmitter.

I just tried to modify the Melody example, replacing the digitalWrite calls with pinMode and I can basicly now play tunes on the AM band, is that even legal :D ?

I doubt it. I also doubt it would have enough power to get much further than the walls of your room.

Bottom line: The OP has built an 800 kHz AM radio transmitter. All it transmits is an 800mHZ carrier signal.  If you modulated the amplitude of that carrier, you could transmit sounds. However, an Arduino doesn't have the processing power to do that. You'd be better off building an analog 800 kHz AM transmitter.

I dont think Nick Gammon's answer actually explains clearly enough what is going on - he just made an example of how to do it. Since no-one else on this site has had a go at explaning it-I will-though Im no expert in arduino radio communications.
"What magic is going on here"
Its not magic -you are observing the principle of "electromagnetic induction" and the principle of "resonance".
Its not unique to arduino- basically an Antenna transmits information by making on and off power changes in the electrical current in the wire-as you are doing playing the melody. By the famous Maxwell equations this energy in the wire creates a corresponding invisible waves in the air. A well known circuit in electrical engineering (tank circuit or oscillator circuit) says that there is also a corresponding receiver circuit (which can be a radio) that will change the waves back into sound (by using the principle of electrical resonance).

I think the “magic” the OP is talking about is not the propagation of electromagnetic waves, but rather the emission being at 64 MHz, way above anything the Arduino does.

@Edgar Bonet. I can only at best guess what the OP is thinking (from what they wrote in the question) and I think a new reader would appreciate to know what going on in terms of electromagnetic waves-and how how an antenna works-especially if they really didnt know any physics or how transmitters and receivers work

source: Stack Exchange

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

sort: votes


text:
How do I change the I2C address on the LCD backpack?
The 20 x 4 LCD comes with a I2C backpack.  I know it has A0, A1, A2 to set the address, as shown at the bottom here:  https://tronixlabs.com.au/news/tutorial-serial-i2c-backpack-for-hd44780compatible-lcd-modules-with-arduino/
It points to here:  http://www.nxp.com/products/interface-and-connectivity/interface-and-system-management/i2c-bus-portfolio/i2c-general-purpose-i-o/remote-8-bit-i-o-expander-for-icbus-with-interrupt:PCF8574_74A
My unit shows up as 0x3F.
And even with all this information I can't tell how to change it.
I need to have a second display on the same I2C bus.
Question:  How do I change the address of the second one?

As mentioned in the page you linked, jumper together one of the address jumpers. For example, above A0 are two pads. Solder a wire across them (vertically - between the two pads above A0). I am guessing the address is pulled high by a resistor, so that will probably make the new address 0x3E, but you could run the I2C scanner to check that.

I tried it and it works.  Simply jumpering A0 together gave me the address of 0x3E, just like you said..  Thanks again for your help,

I would add that the method I used that worked was to first use my soldering iron to build up a bead of solder on both contact points, then take a small solid wire and scrape it and tin it thoroughly, bend it to fit, then solder both points at the same time.  Then snip off the excess.  These points are small but it sure can be done.  Thank you again, @Gammon, for the encouragement.

I fleshed out this process here:  https://arduino.stackexchange.com/questions/12181/how-do-i-use-two-i2c-lcds-with-4-pins/32188#32188 and couldn't have done it without your help, @Gammon.  Thank you again.

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


text:
How might the SD library be reading phantom files?
I have the Sparkfun CAN Bus shield with integrated SD card writer attached to an Arduino Mega 2560. I can delete a logged file from the SD card using Windows, log more data using the SD library, then look at the logged data in, say, Excel. The new log file will include the logged data from the old, deleted file.
The card is formatted in Windows in FAT32 and the logged file has the same name as the original. It seems like the SD card reader/SD library is able to 'recover' the deleted file by name, open it for writing having read its uncorrupted contents, and continue logging to it, despite it having been 'deleted' in Windows. I know a deleted file doesn't get rid of the data unless it is overwritten, but there seems to be some bug/oversight in how the SD library in card reader or how it interrogates the SD card or FAT32 volume for the existence of the file.
Has anyone come across this before? Is it a bug or am I doing something wrong?

Do you remove and reinsert the card from/into the arduino with the power still on?

I have implemented a switch to initialise writing (file.open();) and stop writing (file.flush(); file.close();). This was done with the intent of ensuring the system need not be powered off to remove the card. You make an interesting point if the library maintains some kind of awareness of past files.

It could be caching at the block level, not just the file level. Not sure if there is a way to flush that cache...

The SdVolume class seems to have a cacheClear() function which flushes the block-level cache and invalidates all the cache entries. You don't normally have access to the volume entry of the SDClass, so you would have to break it down into card/volume/root in your sketch instead so you can access all the individual parts (or modify the SDClass to allow access).

Personally though I never use SD.h because it's horrendously slow and badly written. I use (various implementations of) FatFS.

How do you connect sdCard on CAN-BUS shield with Arduino Mega2560? Can I see the code and interface?
Thankyou

How large is the file when it is deleted in Windows? I can imagine what you describe happening if there's a bug in the Arduino File System (see below) - but that requires relatively small files (less than 4K or so).
I assume that the SD card has zero or more "static" files, that don't change; and then the log file, that grows. That is, when the log file is deleted, the newly-freed blocks get re-used again for the new log file?
I also assume that you're using Windows' "Safe Removal" mechanism - giving it a chance to tidy up the SD Card before you yank it out.

To delete a file in FAT, the file system needs to do two steps:

Unlink the used blocks from the File Allocation Table (the eponymous F.A.T.).
These should be set back to zero - making it hard to accidentally re-use them again unless they're the same blocks again (which, for SD Cards, is unlikely due to wear levelling!)
Mark the directory entry as available again.
This is done by merely overwriting the first character of the directory entry with 0xE5. When FAT needs a new directory entry, it will use entries with either 0x00 or 0xE5. If the deleted file is being "resurrected", then a bug could be that it re-uses the directory entry but doesn't zero the existing contents, allowing the existing block number and length to be appended to.

Rather than deleting the file in Windows, try renaming it to something else entirely. That way the Arduino will create a new file, and you shouldn't have the problem. If you still do (worse: if the renamed file gets corrupted) then it's a caching problem. If you don't, then it's a bug in the file system.

The files have been of varying sizes from 1 to 100 kB. At present this is the only file on the card, though hopefully that won't be a limitation going forward. Yep, using 'Safe Removal' in Windows, there seem to be plenty enough corruption issues with SD cards to make that procedure mandatory. Have to admit, I don't know how file allocation tables work, especially on SD cards. When you say unlinking the blocks, is a link to a set of blocks literally just the start and end block? What does the directory entry look like and are you referring to the character array of its name to overwrite?

Without going into the whole FAT mechanism: 1) In the FAT a file is defined as a series of blocks that are indexed as a "chain" of clusters: the directory entry defines the first cluster, and each entry in the F.A. Table defines the next cluster in the chain - with -1 to end it. 2) The directory entry contains six entries: the name; the attributes (read only, directory, etc); the create and modified times; the start cluster; and the size of the file. And yes, when deleting the file the first character of the name array is modified.


text:
Interfacing Digital clock with Uno
I want to take input from a clock for a specific time and respond to it.
I am taking alarm as input because it will send some signal to a buzzer and I want to decode it through Arduino.
I am using Arduino Uno.
The program I used is as follows:
int b = 0;

void setup() {
    pinMode(8, INPUT);
    Serial.begin(9600);
}

void loop() {
    b=digitalRead(8);
    Serial.println(b);
    if(digitalRead(8) != 0)
    {
        Serial.println("input in 8");
    }
    else
        Serial.println("not");

    delay(500);
}

I have removed the buzzer from the clock and connected the terminals to Arduino pin 8 and GND.
But the output is always random (i.e. 0 & 1), no matter if my alarm is on or off.
I cannot find if my program has a flaw or if my approach is just wrong.

It is likely that the alarm clock does not provide any voltage level (I mean GND) to the  buzzer when it does not have to ring, the circuit is just left "open" then; it will provide a voltage level (depending on your clock power supply) only when the alarm has to ring.
On the other side, your Arduino pin 8 must have a voltage level that can be mapped to a 0 (anything between GND and 5V/3) or a 1 (anything between 2x5V/3 and 5V).
However, in the absence of alarm, the input is left "dangling" (no voltage level at all). In CMOS technology, leaving an input pin dangling will make it randomly take 0 and 1 levels as you described.
Fortunately, the solution to this problem should be easy: you just have to force a 0 level to pin 8, by connecting it to GND through a resistor. I generally use 10K or 15K for that resistor. This is called a "pulldown" resistor:

when the alarm does not provide any voltage, the input pin level will be "pulled down" to GND, ie 0.
when the alarm provides a 5V (see important remark below) to the input pin, then it will be seen as 1.

IMPORTANT: you have to make sure that your alarm clock, when ringing, provides a voltage that is not higher than 5V (it would grill your UNO, or more precisely the ATmega328 of your UNO) and is at least ~3V to be "recognized" as 1.
NOTE: it is likely that solving this first issue will not be enough to make your complete program work, because your alarm clock probably does not send a continuous voltage to your buzzer but and alternate one to make it ring, hence you will get successive 1 and 0 at high speed (between 100Hz and 100Hz I would say) in your program. If that is the case please open another question as the solution for that specific issue is disconnected from the current one (random 1 and 0).

A 10k pull-down resistor should also help to stabilize the signal.

A capacitor could help smooth the 100 Hz (or whatever) signal when the alarm is on.

If you have access to an oscilloscope, it would be beneficial to take a reading of what output the clock makes when the alarm is on. (ie whether it is AC or DC and what voltage it is).


text:
Program hangs at am2315.begin() - ideas?
In working with the AM2315 temperature/humidity sensor, my program hangs at the am2315.begin(); line.
The only output I get is "Serial on"
Here is the code:
#include "cactus_io_AM2315.h"
AM2315 am2315;

void setup() {
     Wire.begin(0X20);
     Serial.begin(9600);
     Serial.println("Serial on");
     Serial.println(am2315.begin());
     Serial.println("- - - - Weather station - - - - - - - -");
     Serial.println(" ");
     Serial.print("RH\t\tTemp (C)\tTemp(F)");
     Serial.println(" ");
}  // end setup

I have tried it both with and without the 10K pull-up resisters and get the same result.  I'm not comfortable including them in any case because I will eventually use I2C&Power to link the I2C bus to many other devices and am not sure what that might do..
Right now none of that is hooked up.  It is just the sensor and the Arduino and the laptop.
Voltages have been measured so I know the device is getting 5V power.
My connections and software are based on this article:  http://cactus.io/hookups/sensors/temperature-humidity/am2315/hookup-arduino-to-am2315-temp-humidity-sensor

UPDATE:  New information:  When I am using I2C&Power, I provide power from only one of the dual-port units.  But I discovered that leaving the SDA and SCL unterminated there it breaks the I2C that is trying to pass through it.  By putting in 4.7K pull-up resistors there it restored the connection.

I added a DS3231 RTC module to the breadboard I2C bus and removed the 10K resisters, and now they both work.
Apparently this sensor does not play well alone.  But with the both of them it is fine.
No need at all for the 10K resisters.  (I am using a Nano)
If I disconnect the RTC and reset, it again hangs at the am2315.begin statement, resistors or not.
So this problem is solved now.

10K might have been to high a value. Test it with a lower value resistor (e.g. 1K).

The Adafruit page mentions ~10k, but 4.7k is more typical for I2C pull-up resistors. Your RTC looks like it has 10k resistors built in, so that would have helped. Are you sure your resistors are 10k? Perhaps check with a multimeter.

All good ideas.  I will try them out.  Thank you.

New information:  When I am using I2C&Power, I provide power from only one of the dual-port units.  But I discovered that leaving the SDA and SCL unterminated there it breaks the I2C that is trying to pass through it.  By putting in 4.7K pull-up resistors there it restored the connection.

I've seen some devices saying that they need just a 1.5K resistor, but like you the best solution I have found is to always have a DS3231 on the I2C bus, seems to make everything work.


text:
avrdude.conf: programmer type must be written as "id_type"?
I'm trying to compile & run using ino.
At the ino upload step I get the following error:
avrdude: error at /usr/share/arduino/hardware/tools/avrdude.conf:332: programmer type must be written as "id_type"
Relevant section of avrdude.conf:

programmer
  id    = "wiring";
  desc  = "Wiring";
  type  = wiring;   # line 332
;

I've seen various posts around the internet that suggest I just delete the config & refresh it, but I'd like to find the correct syntax and actually understand & fix the issue.

Which version of the IDE are you using? Did you download it from the Arduino site, or install using apt-get?

I'm not using an IDE, just ino: http://inotool.org/

After looking at the source repo it looks like quotes are now required:

  type  = "wiring";


text:
Why is my switch not working?
I'm trying to have a common light switch turn a LED on and off.
When I connect the light switch directly to a LED, it works like it should - the LED turns on and off with the switch.
When I connect the light switch back to the board, changing the switch does nothing - I get the exact same signals regardless of whether the switch is on or off.
Why?
How do I make the board recognize whether the switch is on or off?

The diagram I followed:

const int  buttonPin = 2;

const int ledUt = 13;
const int ledTest = 12;
int buttonPushCounter = 0;
int buttonState = 0;
int lastButtonState = 0;

int tilstand = 0;

int buttonStateForrigeForrige = 0;

boolean light = false;

void setup() {
  Serial.println("Hello World");
  Serial.begin(9600);
  pinMode(buttonPin, INPUT);
  pinMode(ledUt, OUTPUT);
  pinMode(ledTest, OUTPUT);

}

void loop() {

  digitalWrite(ledTest, HIGH);
  buttonState = digitalRead(buttonPin);
  Serial.println("Sjekk");

  tilstand = LOW;
  if ( buttonState == HIGH ) {
    Serial.println("buttonState HIGH");
    if ( lastButtonState == HIGH ) {
      Serial.println("lastButtonState HIGH");
      tilstand = HIGH;
    } else {
      Serial.println("lastButtonState LOW");
    }
  } else {
    Serial.println("buttonState LOW");
  }

  if (buttonState != lastButtonState) {

    if (buttonState == HIGH) {
      buttonPushCounter++;
      Serial.println("on");
      Serial.println(buttonPushCounter);
    } else {
      Serial.println("off");
    }
  }
  buttonStateForrigeForrige = lastButtonState;
  lastButtonState = buttonState;

  if (tilstand == HIGH) {
    digitalWrite(ledUt, HIGH);
  } else {
    digitalWrite(ledUt, LOW);
  }
  }

Is this switch connected to positive voltage or negative voltage?

At present this is not clearly stated enough to be answerable.  Your code appears to look for input on pin 2, but your second diagram, perhaps from Nick rather than your actual circuit, provides it on pin 8.  Your original diagram does not provide any useful information to indicate if you have a workable circuit or not.

You can draw a schematic in pen and scan it if you have to. Do you have a resistor in series with the LED?

See my page about switches. Judging by your very-hard-to-read diagram, you have just connected the switch to an input pin like this:

That will not give a positive reading either way because it is "floating". You should connect a pull-up or pull-down resistor, like this:

Now if the switch is open, it is pulled-up to 5V by the resistor and the input will read HIGH. When the switch is closed the switch conducts and "overpowers" the resistor, and it would read LOW.

An alternative is to use a pull-down resistor like this:

That reverses the sense of the switch. When open it will read LOW and when closed it will read HIGH.

I hope you have a resistor in series with the LED.

Sorry, I have no experience in making electronics diagrams.
Your diagram shows just what I did, with a 12k resistor.

You can also use pinMode(buttonPin, INPUT_PULLUP); instead of pinMode(buttonPin, INPUT); in that case the arduino "activates" an internal pull-up resistor.

authors: ภาณุพันธ์ ชินะวนิชกิจ


text:
Problems building an Arduino Micro with through-hole components
So I'm trying to build an Arduino Micro using a bread-board and through-hole components. I'm leaving out the voltage regulator and voltage selector (see schematic at the bottom for reference). I'm powering off of USB, so the +5V line is connected to VUSB.
I checked over the circuit many times, so I think it's okay. Below is a picture of me trying to use an Arduino Micro to load the bootloader on to the Atmega32U4:

I looked here and here as references for trying to load the bootloader, but every time I try it gives me an error. It seems like the MCU is not being recognized. Has anyone tried this before, and successfully done it? I'd like some pointers as to how to achieve this.
EDIT: I've moved the crystal (and 22 pF cap's) closer to pins 16 and 17. The steps I take are:

Upload "ArduinoISP" sketch to Arduino Micro (the "programmer").
Select "Arduino Micro" as the board to be programmed.
Select "Arduino as ISP (Atmega32U4)" as the programmer.
Burn bootloader.

Here is the verbose output (compilation and upload):
Arduino: 1.6.12 (Windows 7), Board: "Arduino/Genuino Micro"

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega32u4 -carduino -PCOM5 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xcb:m -Uhfuse:w:0xd8:m -Ulfuse:w:0xff:m

avrdude: Version 6.3, compiled on Sep 12 2016 at 17:24:16
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM5
         Using Programmer              : arduino
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega32U4
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  9000  9000 0x00 0x00
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0xffffff (probably .reduced_core_tiny) (retrying)

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0xffffff (probably .reduced_core_tiny) (retrying)

Error while burning bootloader.
Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0xffffff (probably .reduced_core_tiny)
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

avrdude done.  Thank you.

Are you sure you aren't trying to build a radio receiver?

My page about uploading bootloaders may help you.

Where is "here and here" ?  2. Edit question and show what commands or sequence you used for bootloader transfer.   3. What do you get when you try to read the fuses?

@IgnacioVazquez-Abrams Well played sir!

@NickGammon
I'll have to check that out. It looks quite promising!

@jwpat7
Good catch! I edited the post. It should have the links now.
The sequence is the same as in the second link.
Let me try and load it again. I'll post the errors I get.

Loading the "ArduinoISP" program on to the programmer (the Arduino Micro on the left side of my picture) works without errors.
I then unplug it from my computer and hook it up as shown in the second link.
I select "Arduino/Genuino Micro" as the Board.
I select the port that the programmer (Arduino Micro) is connected to.
I select "ArduinoISP" as the programmer.
I press "Burn Bootloader".
I get the following:
avrdude: Error: Could not find USBtiny device (0x2341/0x49)
Error while burning bootaloader.

Regardless if related to your present problem or not, you should put the crystal and its capacitors right at the relevant pins.  The same goes for anything intended as a bypass capacitor.

I did some research online, and found that other people have had trouble programming with the "Arduino as ISP". So I decided to go with a dedicated AVR Programmer (I chose the USBtinyISP). [In the Arduino IDE] I was able to write, but AVRdude reported errors during reading. One thing I noticed from using the USBtinyISP is that the "target" (board being programmed) must be separately powered. So my initial problems were caused by either failing to separately power the target board, using a "finicky" programmer, or both!

I select "ArduinoISP" as the programmer. I press "Burn Bootloader". I get the following: avrdude: Error: Could not find USBtiny device (0x2341/0x49) Error while burning bootaloader.

You need to select Arduino as ISP from the Tools > Programmer menu. ArduinoISP is a dedicated in system programmer made by Arduino, confusing because the name of the sketch used with Arduino as ISP is ArduinoISP.
If you're using Windows you'll also likely encounter the issue that ATmega32U4 based boards can't be used for Arduino as ISP. The cause of this is explained at https://petervanhoyweghen.wordpress.com/2012/09/16/arduinoisp-on-the-leonardo as well as a solution. Unfortunately the solution described in that blog post no longer works as-is with recent versions of the Arduino IDE. I have updated the solution to work with recent Arduino IDE versions and added support for installation via Boards Manager here:
https://github.com/per1234/ATmega32U4asISP

I got the following message when trying the steps on the github page:
Arduino: 1.6.12 (Windows 7), Board: "Arduino/Genuino Micro"
avrdude: Yikes!  Invalid device signature.
Double check connections and try again, or use -F to override
this check.
Error while burning bootloader.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

@MaxJacob, I'm imagining the Arduino Micro auto-resets when you start a download to it.  If that is the case you need to disable the auto-reset after you download ArduinoISP to the Micro.  The Micro should remain connected to your host computer (that runs Arduino IDE) when you click Tools, Burn Bootloader to copy the bootloader to your target system.  The IDE will send the Bootloader to the Micro, and the Micro will send it on to your target system.   Note, if you have other working Arduinos, use one to practice download/bootload process, in case your target system is just not working.

@jwpat7
I disabled auto-reset (placed 120 Ohm resistor between 5V and Reset) after uploading the Sketch, but I still get the same error when try to burn the bootloader. Sadly, I do not have any extra Arduinos around.

I want to zone in on why I'm having these issues. What is the simplest circuit necessary to burn the bootloader to the ATmega32U4 using an Arduino Micro (using "Arduino as ISP") as the programmer?

If you have the correct board selected then usually the "invalid device signature" error indicates a wiring problem. If you have verbose output during upload enabled in File > Preferences you can see the actual signature that was read. What was it? It's probably helpful if you would edit your question to add the steps you used to do the Burn Bootloader and full verbose output from the console to your question so that all the information is located in one place instead of spread out over multiple comment threads. I agree with Chris Stratton about the crystal being too far away.

@per1234
Good suggestion. I've edited the original post with more details.


text:
NeoPixel setPixelColor works only in for loop
I am working with a NeoPixel RGB led and have gone through various tutorials but I have a question regarding the setPixelColor().
If I do not have my setPixelColor() and show() inside of a for loop it will not work.
This works:
void holoLight(uint32_t c){
  for(uint16_t i = 0; i<2; i++){
    holo_pxl.setPixelColor(i, c);
    holo_pxl.show();
    delay(2500);
  }
}

This does not:
void holoLight(uint32_t c){
    holo_pxl.setPixelColor(1, c);
    holo_pxl.show();
    delay(2500);
}

I am sure it is something specific to the language or execution but would love some clarifications, thanks =)

Please edit question and say what happens -- ie what colors appear, which lights turn on or off -- rather than ambiguous "works" and "not work" descriptions.  Also, to do the same thing in the second version as the first (except for delays) add holo_pxl.setPixelColor(0, c); and report results.

Please show the part of the code that initializes holo_pxl and describes your neopixel device better (is it a matrix? how many LEDs does it have?)

Out of curiosity, have you tried holo_pxl.setPixelColor(0, c);instead of holo_pxl.setPixelColor(1, c); in the second example?

@jfpoilpret you were spot on, I can't believe I skipped something so simple.  Thanks for the help =)

I am not sure I fully understand your exact problem but you have to be aware that holo_pxl.setPixelColor(1, c); set the color of the second LED in a NeoPixel chain, NOT the first one.
For the first LED, you have to use holo_pxl.setPixelColor(0, c); instead.

#facepalm...it would be something so simple. I switched out an 8 led neopixel stick for a single rgb neopixel...and didnt think about it being zero-based index. As embarrassing as this post is I will leave up for anyone else that overlooks the obvious coding late into the night o.O


text:
What options do I have to wirelessly connect my computer to an arduino?
For my project I have an arduino Uno connected to my robot. I need to control it wirelessly. I have thought of using a bluetooth module , but I need a larger range. Then I thought of using an RF-module like the Xbees and the 2.4 Ghz nRF24L01. However I can't use the Xbees due to budget issues. As for the nRF24L01- I understand that using the trasmitter and receiver modules I can transmit information between 2 arduinos- however I need to transmit from my computer to my remote arduino. I want to achieve this without using a second arduino at the transmitting (computer) end. Is there a way to achieve this?

How about using wifi?
The esp8266 costs as low as 3$ and has good range.
here's a quick tutorial
What you'll need to do is send a command to the esp8266 and in turn it'll communicate with the arduino via Serial (or Software Serial) and tell it what to do.

It is also not very cheap, but you can easy use wifi shield. The one I sent you is from arduino, but there are chinese analogs which are cheaper. You can use them either to connect your arduino to computer or to connect it to the other devices. Have fun!


text:
How to connect an RF module directly to a PC without using an arduino?
I know that in xbees i can connect the xbee module directly to my pc using the USB explorer. But I'm using the nRF24L01 RF modules. I want to transmit from my pc, via the RF transmitter to my RF receiver, which is connected to my arduino. How do I connect this RF module directly to my PC?

There's a version of the nrf24 chip with a USB interface, often sold assembled as a data link for quadcopters, but its not cheap and there would be new things to learn.  A simple  MCU board, Arduino or otherwise, that you are already familiar with may be best.

The nRF24L01+ uses SPI. PCs don't (usually) have an SPI interface. So you will need some piece of hardware to provide the PC with an SPI interface.
That could be an Arduino, or it could be a dedicated SPI dongle, such as one based around the FT2232 chip.
Of course, you then would need to write software to use that SPI interface and work with the nRF24L01+ connected to it, including using the same message format / packet system, which won't be a simple task. So you may be better off just using a small Arduino to do the communication and present you with a simple serial interface for sending / receiving messages. That way you can then use the same nRF24L01+ software that you are using elsewhere in your setup.


text:
How to animate a LED Strip via wifi?
I'm remotely connecting my phone to an arduino MKR1000 via wifi, and sending data via HTTP GET (so to switch on the debug LED, I just need to navigate to http://192.168.1.1/debug/H, for example). Now, I want to be able to remotely send animations to an RGBW led strip.
Ideally, I would have a simple keyframe based protocol such as:
    http://192.168.1.1/anim/(keytime in ms):R,G,B,W+(keytimeinms) etc...
So for example, to animate from white to red in 500ms, I would navigate to:
    http://192.168.1.1/anim/0:255,255,255,255+500:255,0,0,0
Is this the best way to remotely send animations to my arduino? How should I implement this on the arduino side in the most ressource-efficient way possible? I don't even know where to start :/
For the moment, on the arduino side, I've got a keyframe class and an array of those keyframes representing the animation.

Start with something. Worry about making it efficient after you've figured out how to make it at all.

I'm actually working on such a thing (https://github.com/Paul-Ver/OpenLedstrip). Though it's far from finished and may focus on other points of such a LED driver, but you can check out the HTTP message handling.

I'm also using "HUE" instead of "RGB", which makes it easier for a user to select a color (with a slider, going through all hue's). I believe that will make animating a fade much easier. You simply increase/decrease the hue with set steps over time, until you reach the set hue. And same can be done for the brightness.

Ignacio's comment, “Start with something. Worry about making it efficient after you've figured out how to make it at all”, is good advice.
Note, to make the transition from one keyframe to another more efficient, use a variant of the Bresenham algorithm.  This allows use of fast integer arithmetic and is intrinsically accurate.  Instead of error accumulating and getting steadily worse (as will happen if you add constant increments), the Bresenham algorithm tracks error and minimizes it.  See, for example, “Simplified Bresenham's line algorithm: What does it exactly do?”.

This edit addresses Paul's question about accumulating error:

I've added a note to my answer, in which I try to battle the accumulation of error, could you check if my assumption (that the last implementation doesn't accumulate the error) is right?

There can be several sources of error, including accumulation of round-off error; arithmetic overflow errors; time-base errors; and silly errors [it's always easier to poke holes in other people's code!].
To illustrate those error sources and a possible solution, consider the following code snippet:
 0   unsigned long int startTime = millis();
 1.  unsigned int totalTime = 3000, nSteps = 100;
 2.  int msPerStep = round(totalTime/nSteps);
 3.  byte startRed = 100, startGreen = 28, startBlue= 50;
 4.  int deltaRed   = endRed   - startRed;
 5.  int deltaGreen = endGreen - startGreen;
 6.  int deltaBlue  = endBlue  - startBlue;
 7.  byte nowRed=startRed, nowGreen=startGreen, nowBlue=startBlue;
 8.  for(int step= 0; step < nSteps; step++){
 9.     analogWrite(RPin, nowRed   += deltaRed/step);
10.     analogWrite(GPin, nowGreen += deltaGreen/nSteps);
11.     nowBlue = startBlue + (deltaBlue/amountOfSteps)*step;
12.     analogWrite(BPin, nowBlue);
13.     long int elapsed = millis()-startTime;
14.     analogWrite(RPin, startRed + (deltaRed*elapsed)/totalTime);
15.     delay(msPerStep);
16.  }

First, consider currentRed += deltaRed/step expression in line 9.  In the first loop pass it adds an undefined quantity, deltaRed/0, to nowRed; in the next, it adds deltaRed/1 to nowRed; then deltaRed/2; and so forth.
Line 10 corrects the silly error of dividing by step instead of nSteps.  But there can be significant accumulation of round-off error.  For example, if deltaGreen is 199 and nSteps is 100, it repeatedly adds 1 instead of 1.99, and ends up with the Green level 99 counts short of being correct.
Line 11 attempts to compensate for that problem by adding a step-proportional amount of deltaBlue to startBlue at each step.  However, due to the parenthesized order of arithmetic it has exactly the same round-off error problem as line 10 – it adds exactly one unit per step for my example numbers.  To try to avoid this problem, one might write (deltaBlue*step)/amountOfSteps in place of (deltaBlue/amountOfSteps)*step.  This will do accurate arithmetic except can easily overflow an int so should perhaps be written instead as (deltaBlue*(long int)step)/amountOfSteps.
Even if line 11 is rewritten to avoid truncation, round-off, and overflow errors, it still is subject to time-base errors.  Like the color numbers, the delay() parameter msPerStep is subject to accumulation of round-off errors.  During the for loop, several hundred milliseconds of error could accumulate, leading to mismatched or jittery color levels.  To avoid that error, instead measure elapsed time (as in line 13) and make color levels proportional to elapsed time (as in line 14).  In addition, one probably should change the for loop to a do { ... } while (elapsed < totalTime) loop, ie, let the loop run until the right time has passed, rather than some arbitrary number of passes.

Nice note on the "Bresenham algorithm", I also encountered thought of that when writing my answer. But I think that for LED lighting, it wouldn't really be that visible. (Unless it just rolls over 255 and becomes 0.1, then it's about off instead of fully on ;D)

I've added a note to my answer, in which I try to battle the accumulation of error, could you check if my assumption (that the last implementation doesn't accumulate the error) is right? EDIT: I'm not even sure if it battles the problem (and is probably inefficient) but it seems logical.

@Paul, as I couldn't fit a reply into a comment, I've edited my answer with comments on that question.  Let me know if you see any errors in the comments.  Thanks!

Very good explanation, indeed, if I do the multiplication after the dividing, it will still accumulate the error, missed that one. But nice fix you have there ;) but it indeed is rather easy to overflow, should be tested and specced well, or add some checks.

And I indeed missed the thing on delay, of it's 49ms instead of 50ms and you only have 100 frames, it has an error of 100 on 5000, which may seem not too much of a deal, but I agree that code should be robuust/portable. If you get 1ms on 2ms, with a 1000 steps, you're at 50% error (a whole second).

@Paul, for this particular color animation, an error of 100 in 5000 might not matter.  But more generally, for sound or picture sequences, a tenth of a second is glaringly obvious.  Even a hundredth of a second gap is pretty obvious and makes a click in a sound sequence.

I'm not sure what you have working or what you haven't.
I'm also not sure what you've tried and which problems occured.
However, I'd like to give you atleast a basic answer before I vote for: "Too broad".
It's actually quite simple (but you can make it difficult).
Step 1
Imagine the effect, what are you actually trying to achieve? Fade out the current color and fade in a new one? Or are you trying to shift the color from one to another?
Step 2
Find resources online.
You're likely not the first person to have tried this ;D
https://www.arduino.cc/en/Tutorial/ColorCrossfader
Step 3
Iteratively and rationally develop your project.
Know what you have and what you need.
You've got these parameters:

Current R/G/B values.
R/G/B values you wish to shift/fade to.
Duration of the fading effect (total time of the animation, total amount of frames for the animation)

Your goal:
Is making an "animation". Changing the colors over time, as an fading effect.
We will simplyfy it by starting with only the R (red) channel, we can add the rest later.
Let's say we want to fade from 100 to 255 in 3 seconds.
We're going to have 155 different levels of brightness over 3 seconds.
Which is roughly 20ms per step.
for(currentRed; currentRed < setRed; currentRed++){
   analogWrite(redPin,currentRed);
   delay(msPerStep);
}

But that won't really work for multiple channels...
Just add another channel and find your way out that challenge.
(I added blue, but you could add up to x amount with this code I believe)
unsigned char currentRed = 100;
unsigned char currentBlue = 50;
unsigned char setRed  = 255;
unsigned char setBlue = 255;
int differenceRed  = setRed  - currentRed;
int differenceBlue = setBlue - currentBlue;
unsigned int totalTime = 3000; //3sec (in ms)
unsigned int amountOfSteps = 100;
int msPerStep = round(totalTime/amountOfSteps);

for(unsigned int step= 0; step < amountOfSteps; step++){
   analogWrite(redPin, currentRed  += differenceRed/step);//We could optionally calculate the difference per step beforehand, to avoid having doing dividing in a loop (may be a tad inefficient this way).
   analogWrite(bluePin,currentBlue += differenceBlue/step);//But well, in the delay you're also just wasting CPU, so who cares? :)
   delay(msPerStep);
}
currentRed = setRed;//Compensate for rounding step values
currentBlue=setBlue;//You may want update the analog pins, though I presume it would be barely visible to a person.

You could get rid of the blocking delay, but well, that's beyond the scope of this answer.
I haven't tested the code, nor the algorithm extensively.
You may check what happens if the setpoint is lower as the current value.
So now you can test the algorithm, finetune/adapt it to your liking and make a function out of it :)

As noted by jwpat7, combining floating point math and integers on Arduino will have quite an error in it. And if you keep applying the same error each step, it will accumulate.
I'm not sure how significant it will be for LED applications, you usually can't see the difference between a few "levels" of brightness.
I've made my own implementation of which I think may battle this problem:
unsigned char previousRed = 100;
unsigned char previousBlue= 50;
unsigned char currentRed = previousRed;
unsigned char currentBlue = previousBlue;
unsigned char setRed  = 255;
unsigned char setBlue = 255;
unsigned int totalTime = 3000; //3sec (in ms)
unsigned int amountOfSteps = 100;
int msPerStep = round(totalTime/amountOfSteps);

for(unsigned int step= 0; step < amountOfSteps; step++){
    currentRed = previousRed + ((setRed-previousRed)/amountOfSteps)*step;
    currentBlue = previousBlue + ((setBlue-previousBlue)/amountOfSteps)*step;
    analogWrite(redPin, currentRed);
    analogWrite(bluePin,currentBlue);
    delay(msPerStep);//If the algorithm is inefficient, you COULD compensate for it by lowering the msPerStep.
}
currentRed=setRed;
currentBlue=setBlue;

I believe that, by completely recalculating it every step, the error won't accumulate.
This, however, may be a lot more inefficient than what jwpat7 describes. But atleast it's easy to understand.
Since you're throwing most of the cycles away by waiting for the next frame and can barely see the difference between "100 and 102" intensity from PWM, I think it's a viabale option.


text:
Can the EWRF 3022 module be directly connected to the pc totransmit data from the pc wirelessly?
In my project I want to connect my pc to an RF transmitter. The receiver will be connected to an arduino on my robot. However most of the RF modules I looked up couldn't be directly connected to my computer- in all of them I needed to use an arduino on the transmitter end too. Then I came across this:

 EWRF 3022

Can this be directly connected to my computer? If so, how is it done?

How many modules are you going to ask the same question for? You can find out for yourself: Look to see if the module has a PC interface - that is (generally) a USB or RS-232 interface. If it has then yes you can. If it hasn't then no you can't.

If you use a USB to TTL UART adapter, such as an FT232 dongle, then yes you can communicate to it from a PC.
It will not directly connect to a PC though without you getting that extra hardware.

Thanks. Also, what are some other similar, more popular, modules having a PC interface? I mean, is there one which is more commonly used for this purpose?

The only common wireless systems that have a direct PC are WiFi and Bluetooth. Anything else people design a dongle.

What about xbees? They have a USB explorer board, by which they can be directly connected to a pc.  The only problem with them is the cost.

That is really no different to using an nRF24L01 with an Arduino, or whatever that is you linked to above with a TTL to UART adapter. I don't see what you have against using extra hardware, especially when you yourself then suggest using extra hardware.

In another answer, you said that using a TTL to UART adapter will require writing more software, right? If I remember what I read correctly, the xbees involve significantly less coding right? How so?

I don't know, I have never used an XBee. I think there is some kind of configuration program that sets them up. However, you will still need to write some software to do the communicating.

Ok. I see. Could you also elaborate on what software I have to write to make it work?

No, I can't. What software you need to write depends on what you are doing and what you are doing it with.


text:
Binary message formatter
I am currently developing an IoT device with arduino and i want to minimise the data payload. First i used json which is not very efficent in fixed messages (the format will always be the same). Then i found something like messagepack which also sounds nice but i think you could do even better with just binary. I hope to find something like that:
I have a message for example:
#BOOL#INT#INT#FLOAT#BOOL#STRING#

The position of this variables never change so i could represent the message in binary and i could save a lot of bytes. Is there any library which can de/encode such formats and generate messages from given values?
If not i think it would be very useful in further IoT devices!

Passing messages across computers and/or microcontrollers with different architectures can be a real pain (endianness...). So do not fall into NIH / reinventing the wheel traps but keep standing on the shoulders of giants! Several message serialization protocols exist.

BSON
MessagePack
Protocol Buffers
CBOR (Concise Binary Object Representation)
...

Several implementations of such protocols exist (even for Arduino).
I suggest to have a look in a search engine for such protocols and add Arduino.
I've found:

BSON

ardubson

MessagePack

msgpack-mcu
arduino_msgpack
MsgPacketizer
msgpack-arduino
ArduinoJSON serializeMsgPack / deserializeMsgPack

Protocol Buffers

nanopb

CBOR

Arduino-Cbor

...

PS: You might read https://scottlocklin.wordpress.com/2017/04/02/please-stop-writing-new-serialization-protocols/
and have a look at https://xkcd.com/927/
Just choose a giant compatible with your requirements ;-)
https://en.wikipedia.org/wiki/Comparison_of_data_serialization_formats may help

Brilliant. Maybe add something about how bad sending structs between avr, arm and x86 works?

No such library is needed, since basic C++ can handle this on its own. Create a packed struct with the fields, fill the fields with assignment or memory copying, and cast to a char* in order to send. Reverse the order of operations in order to receive. Beware the string though, since they need to/should specify a length somewhere.

is it also possible to terminate the string instead of using a fixed length?

There is no difference between terminating a string and specifying the length other than the fact that the terminator cannot be used in the string.

A good choice to send sensor data is CayenneLPP. LPP stands for "Low Power Payload". It is a sensor type aware encoding that uses as few bytes as possible.
A key feature is that recipient must not be aware of content as it is encoded into message, so you can build a generic gateway using that.
You can read more about CayenneLPP here: https://developers.mydevices.com/cayenne/docs/lora/#lora-cayenne-low-power-payload
It is recommended for using it on TTN to minimize payload weigth.
There is an Arduino library for enconding and decoding. For decoding it outputs JSON object so it is ready to be used in platforms like NodeRed or any python or web based application.
Check it here: https://github.com/ElectronicCats/CayenneLPP

use a struct organize the data and when transmit the struct, use a char pointer pointing to it so everything is sent in binary format.
you will need to come up with a way to determine when the pointer ends.

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


text:
RFID Reader ID12-LA reads every card as ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
My new RFID reader ID12-LA by SparkFun can recognise an RFID tag, but it can't read its tag number - the Arduino IDE outputs the tag as ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
Any help on how to convert this into a proper ID would be much appreciated - btw I have tried other baud rates; no difference.
Thanks, Raihaan
Edit - the code I'm using is this:
#include <SoftwareSerial.h>

SoftwareSerial rSerial(4,5);

void setup() {
    rSerial.begin(9600);
}

void loop() {
    if (rSerial.available() > 0) {
        int b = rSerial.read();
        Serial.print(b);
        Serial.print(" ");
    }
}

This now returns 255 6 times... Any ideas?
Schematic:

Raihaan, please edit question and format the code as code.  To do so, highlight the code and press ctrl-K.  Add a blank line before and after the code.  Also, use cut and paste when you include the code -- there are some missing characters.  Also, where are you getting data from the reader?  Do you have one connection for the reader, and one for the IDE, with one or the other not shown in your question?  Fix the question.

There is a format selector (I can't quite read the image because of the wire). It should be grounded to select ASCII format.

ÿ is 0xFF (255 in decimal). That is, all 1-bits set. It is also what is returned from Serial.read() if there is no data (actually it returns -1 which is 0xFFFF in this case however that will look like 0xFF if you stuff it into one byte). Possibly there is a gross mismatch in baud rates. An occasional 0-bit will look like a start bit, and then if you get all 1-bits after that, you would get 0xFF returned.

If you have one of the regular Arduino models, the hardware UART is connected to pins 0 and 1, which are also used by the USB programmer and in your case obviously your serial monitor, on which you expect to see some output.
Configuring a SoftwareSerial on pins 0 and 1 is probably not going to work at all. If you need the USB programmer to stay connected and the serial monitor for debugging, you have to use different I/O pins and setup your SoftwareSerial accordingly.
I assume that you are aware that the ID12-LA chip only works on the 125 kHz band and is incompatible with common tags running on 13.56 MHz?

Ok, so I'e switched the SoftwareSerial pins to 4 and 5, but I'm still not getting an output - is it because I'm not using EM4001 ISO tags?

@Raihaan What kind of tags are you using?

No idea- only ones that advertised themselves as compatible with any RFID reader

Except the ID12 says that very specific ones are the only ones compatible - i.e. the EM-4001 ISO tags

RFID is an umbrella term for many similar, but otherwise incompatible transmission technologies. There simply are no tags 'compatible with any RFID reader'.

You created a SoftwareSerial connection to read from the module and then you're printing what you just read to the same module. You probably want to print to the serial monitor on your PC. You should add Serial.begin(9600); to your setup() and ensure that all print()s are to Serial and not rSerial().

Thanks, now it outputs strings, but still quite unusual - 255 13 times - I'm starting to believe the issue is not from the Serial connections but with the actual RFID hardware - either the reader or the tags.

@Raihaan Edit the code in your question. Also include your circuit.

Done - code has been updated, schematic has been included (from Sparkfun)

Like Nick Gammon has said, you need to connect the FORM pin to GND to select ASCII format. Also connect the RES pin to 5V.

How should I select ASCII format? Is this in the serial monitor?

What do you know... It worked! Cheers guys!


text:
Aptotec PN532 shield power consumption
I am currently planning a battery-powered project, where one of the tasks involves reading Desfire EV1 tags. Since the cheap RC522 based NFC shields are reported not to work with the Desfire EV1 tags, I wanted to make an attempt with a PN532 based shield. Due to offering the fastest shipping option, I ordered an Aptotec PN532 shield, although there are many other, and likely cheaper options out there as well. The Aptotec shield seems identical to the Seeed NFC Shield V2.0.
Communicating with the Desfire EV1 tags works as expected, but I am not understanding the shield's power consumption. If I understand the PN532 datasheet correctly, the chip itself should only draw 45µA when in standby mode, some 30mA when active, but not transmitting and additionally up to 150mA more during actual transmission.
After sending an 'InRelease all targets' command to the PN532, the shield however still draws about 50mA, although the PN532 should be in stand by mode. Using the RFConfiguration command to turn the RF field off completely still does not decrease the shield's power consumption. Activating the RF field e.g. by issuing an InListPassiveTarget command, the current draw increases to about 80mA, which matches with my assumption that the PN532 now draws 30mA more than when idle. There seems however to be something else on the shield causing a 'base line' 50mA current draw, which is not caused by powering the PN532 chip.
Does someone know where this power is lost, if it is possible to software-based turn off whatever is causing the power draw or if other PN532 shields show the same behaviour? Since my project must run on a battery, the 50mA unexplained current draw is not acceptable.

Please provide an exact reference of the shield you used, so that we may take a look at its specs (if any). Note that power consumption of an IC may be different for a shield or more complete circuit that integrates this IC. I have had this problem in the past with NRF24L01P modules, which consumed far more than the IC itself.

@jfpoilpret Sure. I've linked to Aptotec's web page, but there is not much documentation available from them. The board seems identical to the 'Seeed NFC Shield V2.0', where some more documentation is available, but no technical specifications explaining the power consumption.

After some trial and error, I think I can answer this one myself.
The circuit schematic from the Seeed module is actually broken and the Apotec model is built almost identically. The PN532 chip has an SVDD output pin to power an optional security access module for cryptography support. In the Seeed design, this pin is connected to the 3.3V input voltage from the voltage regulator, which is simply wrong and the pin sinks an essential amount of current.

Good catch about the SVDD being an output is connected to 3.3V! I too am facing the same problem. Have your tried to cut the trace on the PCB coming out of SVDD (pin 37), and connected this pin to ground (or left floating?). Do let me know if you have tried this. Thanks
Tilak.

Accept your own answer to close this question.

@user31092 Sorry that I missed your comment. No, I haven't tried to fix the module. If you cut the PCB trace to the SVDD pin, you have to let the output pin float and should not connect it to ground.

authors: โอ๊ด อภิชาติ


text:
What is a cheap way to interface a USB keyboard to an Arduino Uno?
What is the cheapest way to interface a USB 2.0 keyboard to an Arduino Uno?
The keyboard does not support PS/2 emulation (interfacing a PS/2 keyboard to Arduino is easy). So this means the Arduino will read the USB keyboard's keystrokes - whatever their speed of input is.
If it can be solved using an IC then DIP is preferred as it quicker to work  with for soldering and pluggin into breadboard.

Have you considered USB/UART bridges, like FTDI ones? I might be wrong but lots of them are used in UART communication and other stuff

Don't it's a bad idea.  Or if you must, use a teensy LC in place of the Uno.

@ChrisStratton I know it possible to do becuase thheres a one chip solution-its here http://www.hobbytronics.co.uk/usb-host-board-v2

but I cant figure out the circuit from that photo-maybe iots based around a max 3421e? teensy LC at its cheapest is a cost of a few arduino Unos-so I dont think its that cheap.

What to figure out? The description text says: "The USB Host Board is based around the Microchip 24FJ64GB002 microcontroller which contains a built-in full-speed USB host controller".

@yabbadabba not true. The Teensy LC costs less than an Arduino Uno even before adding the host shield the latter would require, which probably makes the Arduino solution cost three times as much.  If you go unbranded, the microcontrollers are about the same cost, but the Kinetis as used by the Teensy is vastly more capable than the ATmega used on an Uno, and not only in its ability to be a USB host.  Granted, if you go with an unbranded or original board you'll probably need to use something like mbed USB libraries rather than Arduino-type ones.

@ChrisStratton Im looking ad different ARM CPUs now-which as you imply are about the same cost or cheaper and can handle USB host. Im looking at the  MKL03Z16VFG4 which is about $2 as a solution-but it doesnt look like its in DIP form. So what I need to know now is how to get started using ARM MCU.

There's hardly any MCU that can handle USB in DIP form.  You'll need to learn new techniques or buy something already on a board.  Not sure the kl03 does USB but the kl25z and similar do.  If it sounds complicated, remember the first thing I said was that the project was a bad idea.

It is currently totally unclear what the OP's project is, what is the scale of the project, and why there is such a limitation as DIP packaging. So we can't say if this is a bad or good idea.

@Chris Stratton Here a potentially cheap solution-its USB host implemented in software on ATMEGA 32 -unfortunately they only have driver for mouse not keyboard https://courses.cit.cornell.edu/ee476/FinalProjects/s2007/blh36_cdl28_dct23/blh36_cdl28_dct23/

With V-USB https://www.obdev.at/vusb/ it is possible to bitbang USB 1.1 on Arduino. If ARM MCU in DIP is needed, NXP has some: LPC1114 (M0), LPC1768 (M3)

The cheapest way is to get a plain PS/2 (or PS/2-USB convertible) keyboard instead of USB1.1 (I hope you mean the standard LS keyboard, since USB2.0 HS keyboards hardly exist), and interface it to GPIOs in accord with known solutions.
The Arduino Uno is designed around Atmega8u2 and ATmega328P chips, which can act as USB device only, FS and LS. To interface it with a dedicated USB keyboard (which is a USB device), the you need to have the Arduino as a USB host. Probably it is possible to emulate some limited hardware host functionality for LS mode (1.5Mbps) over GPIOs, but it will be a remarkable effort.

For the senario I am interested in I cant switch over to PS/2 unfortunately-as I mentioned in question if it was PS/2 it would be easy to do. I have a guess it can be done with using a single chip that acts as USB host in conjunction with arduino uno.

You asked for a cheap way. Of course, you can use a dedicated USB host controller based on MAX3421E chip (to SPI), aka "Arduino USB Host Shield", but it will cost you $20-$30, instead of an old junk PS/2 keyboard from some trash.


text:
Arduino Uno and ESP8266 serial monitor issue
I plugged in the Arduino Uno and the ESP8266 following this schema:

When I enter "AT" in the serial monitor, I get an "OK". I can also connect to my wifi using typical ESP8266 commands.

What doesn't work is passing these commands using an Arduino Script. For example, if I use this script, I don't get an "OK" from the ESP8266.
void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
}

 void loop() {
  // put your main code here, to run repeatedly:
 Serial.println("AT");
 delay(10000);
   if(Serial.find("OK")){
    Serial.println("OK");
     }
     else{
     Serial.println("NOT OK");
  }
}

I tried a bunch of different codes,and nothing works. What am I doing wrong?

With the code above, how can you say that you don't receive "OK" from ESP8266? Your code contains no read from Serial, so if "OK" is sent, you cannot know it.

Ok so my question was stupid i guess. What do I need to add so that I display the "OK"?

For that you'll need to check Serial.available() and then use Serial.readString() or other Serial methods. Then you will have to decide how you "debug" your sketch, that could be lighting a LED (quite limited) or printing to another serial port (for that you will need to use SoftwareSerial. I think you can easily find simple examples that just do that.

I updated the code above using serial.find(). It still displays "NOT OK". What I don't understand is when I type in the command "AT" everything works fine. When I try to pass it programatically, then it stops working.

What you are doing wrong is:
If sending AT commands from PC to ESP and receiving OK ,as you said, works - that means you connected TX output from USB --> RS232 IC on the board to both RX pin of the ATmega328 and RX pin of the ESP8266 - not as in your picture. Similarly, you connected RX input of the USB --> RS232 IC on the board to both ATmega328 TX and ESP8266 TX pin of the ESP8266. If communication between PC and ESP works, then you connected TX Arduino pin with TX ESP pin and RX Arduino pin with RX ESP pin and not as shown in the picture.
When you send AT command from PC both ATmega328 and ESP8266 are getting the signal from USB --> RS232 IC in their RX pins. As your firmware in the first 10 seconds doesn't read the RS232 data, ATmega328 just ignores the packets sent by PC but ESP8266 receives the packets and responds with OK.
Since you shorted RX on ATmega328 and RX on ESP8266 and you shorted TX on ATmega328 and RX on ESP8266, ATmega328 can not send the data to ESP and vice versa so there is no OK.
In the other case, if you connected ATmega328 TX with ESP8266 RX and ATmega328 RX with ESP8266 TX (as shown in the picture) then you would have shorted USB --> RS232 IC's TX with ESP's TX and you would have shorted USB --> RS232 IC's RX with ESP's RX.
In that case ATmega328 might be able to send AT command to both ESP and PC at the same time and ESP would respond but now ESP's TX would be connected to ATmega's RX which is now shorted with USB --> RS232 IC's TX so PC can't receive that packet. However, when ATmega328 responds with OK, the signal now goes from ATmega328 TX to USB --> RS232 IC's RX (as always) and you might see the response in serial terminal.
So, you can't get the ESP to respond directly to PC and to ATmega328 without interchanging the TX/RX wires. Furthermore, as you may know RS232 is designed for communication between two devices, not three - and this is the case where three devices (USB --> RS232 IC, ATmega328 and ESP8266) are connected to the same TX/RX pins at the same time in a rather unusual way. Because, devices are usually connected TX to RX and RX to TX. However, when using the Arduino's onboard USB --> RS232 converter (by removing the microcontroller or holding it under reset) then you have to connect TX to TX and RX to RX. That is because there is one more TX/RX pair in between PC and the RX/TX pins on the board. The output of the USB --> RS232 converter (TX) sends the data to RX pin on ATmega328 (and RX pin on the board) but if you want to send the signal further (to some other device), then the pin marked with RX is going to act as TX.
To summarize:

The schematics does not correspond to what you have written. Such a connection would not allow to send the AT commands from the PC to ESP and to receive response, meaning you connected the TX/RX the other way round.
You can not have both at the same time. You have to decide whether you want to send AT commands from the PC or from microcontroller and then connect the wires accordingly.


text:
very lightweight low power microcontroller with memory?
I have build a couple of projects using arduino.  For a new project I want to log skin surface temperature vs. time (just perhaps a few times per day) and possibly other easy to obtain info such as voltage.
I need to make everything as small and lightweight as possible (since it would be measuring skin temperature on a small mammal), i.e. below 5g, lighter if possible, ideally 3g, including the battery, so that it doesn't upset the 50-100g animal too much.
I read it might be possible to change the arduino pro mini to use less current by getting rid of the voltage regulator? but perhaps it is more sensible to change completely and learn to program another type of microcontroller which someone could recommend? It would need to be possible to operate it directly from a lightweight coin cell or similar lightweight battery. (I'm also not sure how to find a lightweight 3.3V battery for the arduino pro mini, I guess they exist but I can only find 3V batteries so far). If it has onboard memory to save temperature every few hours which could be downloaded later that would be ideal (I would also be interested if anyone has recommendations for memory). I know it's possible to buy an "Ibutton" but if I have time I would like to make my own so that I can add other sensors and obtain more information.

...sorry, my actual question is: Could someone recommend a suitable low powered lightweight microcontroller, or do you think I should continue with arduino and try to adapt it?  Any help is really appreciated!

You could use an ATmega328 at 8MHz, powered with two 1.5V batteries in series. You could then continue using Arduino libraries and IDE.

@jfpoilpret, 2AA would be too heavy I think. A 2032 3V coin cell could be better.

Depending on how you program it, an ATmega328 or an ATtiny84 or 85 might have very light current consumption and work with a lithium CR2032 cell for quite some time. However, reducing power consumption of a circuit (ATmel or any other) can become rather tricky.

I made up a small torch locator which used an ATtiny85 powered from a button-cell (CR2032). It looks like this:

Other side:

That currently weighs 5.9g. The battery-holder weighs 1.6g so you could save that by making a more light-weight holder (perhaps a bit of plastic for insulation, and soldering directly to the battery). The chip socket weighs at least 0.5g, so you could save that as well by soldering to the processor pins. So we are down to 3.8g.
The ATtiny85 has 512 bytes of EEPROM which you could use to log readings to. I'm not sure about a clock if you are trying to save weight, but if you start it at a known time, you could have a reasonable estimate of the time by using the millis() function to find miliiseconds since startup.
I made another one a while ago which flashes an LED every couple of seconds:

That is similar. The processor is there (upside down under the chip socket) and the battery is underneath. That weighs 6g. The battery has lasted a couple of years, and that is flashing an LED every couple of seconds!
Instead of the LED you could have a thermistor to read the temperature.
You could program it to take a reading every few hours and save it to EEPROM. Then when instructed (eg. by joining a couple of pins) it could output the readings to another pin (via serial).
You could save more weight by using SMD (surface mounted) devices, and perhaps using a tiny circuit board you could get made up.

Code
The code for my torch locator is below. Of interest is the fact that it sleeps most of the time. Also it sleeps during the ADC sampling. Although in my case I am measuring a LDR (light dependent resistor) the code for measuring a thermistor would be similar. You just need to do some calculations at the end to turn the reading into a temperature.
// ATtiny85 torch detector
// Author: Nick Gammon
// Date: 25 February 2015

// ATMEL ATTINY 25/45/85 / ARDUINO
// Pin 1 is /RESET
//
//                  +-\/-+
// Ain0 (D 5) PB5  1|    |8  Vcc
// Ain3 (D 3) PB3  2|    |7  PB2 (D 2) Ain1
// Ain2 (D 4) PB4  3|    |6  PB1 (D 1) pwm1
//            GND  4|    |5  PB0 (D 0) pwm0
//                  +----+

/*

  Pin 2 (PB3) <-- LDR (GL5539) --> Pin 7 (PB2) <----> 56 k <----> Gnd

  Pin 5 (PB0) <---- LED ---> 100 R <-----> Gnd

*/

#include <avr/sleep.h>    // Sleep Modes
#include <avr/power.h>    // Power management
#include <avr/wdt.h>      // Watchdog timer

const byte LED = 0;          // pin 5
const byte LDR_ENABLE = 3;   // pin 2
const byte LDR_READ = 1;     // Ain1 (PB2) pin 7
const int LIGHT_THRESHOLD = 200;  // Flash LED when darker than this

 // when ADC completed, take an interrupt
EMPTY_INTERRUPT (ADC_vect);

// Take an ADC reading in sleep mode (ADC)
float getReading (byte port)
  {
  power_adc_enable() ;
  ADCSRA = bit (ADEN) | bit (ADIF);  // enable ADC, turn off any pending interrupt

  // set a2d prescale factor to 128
  // 8 MHz / 128 = 62.5 KHz, inside the desired 50-200 KHz range.

  ADCSRA |= bit (ADPS0) | bit (ADPS1) | bit (ADPS2);

  if (port >= A0)
    port -= A0;

#if defined(__AVR_ATtiny85__)
  ADMUX = (port & 0x07);  // AVcc
#else
  ADMUX = bit (REFS0) | (port & 0x07);  // AVcc
#endif

  noInterrupts ();
  set_sleep_mode (SLEEP_MODE_ADC);    // sleep during sample
  sleep_enable();

  // start the conversion
  ADCSRA |= bit (ADSC) | bit (ADIE);
  interrupts ();
  sleep_cpu ();
  sleep_disable ();

  // reading should be done, but better make sure
  // maybe the timer interrupt fired

  // ADSC is cleared when the conversion finishes
  while (bit_is_set (ADCSRA, ADSC))
    { }

  byte low  = ADCL;
  byte high = ADCH;

  ADCSRA = 0;  // disable ADC
  power_adc_disable();

  return (high << 8) | low;

  }  // end of getReading

// watchdog interrupt
ISR (WDT_vect)
{
   wdt_disable();  // disable watchdog
}  // end of WDT_vect

#if defined(__AVR_ATtiny85__)
  #define watchdogRegister WDTCR
#else
  #define watchdogRegister WDTCSR
#endif

void setup ()
  {
  wdt_reset();
  pinMode (LED, OUTPUT);
  pinMode (LDR_ENABLE, OUTPUT);
  ADCSRA = 0;            // turn off ADC
  power_all_disable ();  // power off ADC, Timer 0 and 1, serial interface
  }  // end of setup

void loop ()
  {
  // power up the LDR, take a reading
  digitalWrite (LDR_ENABLE, HIGH);
  int value = getReading (LDR_READ);
  // power off the LDR
  digitalWrite (LDR_ENABLE, LOW);

  // if it's dark, flash the LED for 2 mS
  if (value < LIGHT_THRESHOLD)
    {
    power_timer0_enable ();
    delay (1);  // let timer reach a known point
    digitalWrite (LED, HIGH);
    delay (2);
    digitalWrite (LED, LOW);
    power_timer0_disable ();
    }

  goToSleep ();
  }  // end of loop

void goToSleep ()
  {
  set_sleep_mode (SLEEP_MODE_PWR_DOWN);
  noInterrupts ();       // timed sequence coming up

  // pat the dog
  wdt_reset();

  // clear various "reset" flags
  MCUSR = 0;
  // allow changes, disable reset, clear existing interrupt
  watchdogRegister = bit (WDCE) | bit (WDE) | bit (WDIF);
  // set interrupt mode and an interval (WDE must be changed from 1 to 0 here)
  watchdogRegister = bit (WDIE) | bit (WDP2) | bit (WDP1) | bit (WDP0);    // set WDIE, and 2 seconds delay

  sleep_enable ();       // ready to sleep
  interrupts ();         // interrupts are required now
  sleep_cpu ();          // sleep
  sleep_disable ();      // precaution
  }  // end of goToSleep

for your flashing led "thing", wouldn't it be better to use a 555 timer chip? I find using an ATtiny somewhat of a waste.

I was going for low power consumption. The processor sleeps most of the time, and then flashes the LED for a millisecond or so.

thanks! looks possible to use this, will have a go at learning how to set up and program it.

Re “Instead of the LED you could have a thermistor to read the temperature”, one could instead read ADC channel 15, the on-board temperature sensor.  [However it isn't highly sensitive or accurate.]

Your torch finder is a wonderful piece of design and the power consumption estimation you did is very much in the spirit of the "engineer as much as you need to" spirit of Ardunio. The whole thing warmed the cockles of my heart (wherever those are).

Thanks! That's very kind of you. :) It's still working by the way. I look at it in the evenings wondering when it will fail.

I would personnaly suggest an ATtiny 45/85. It is pretty much a small AVR with 5 GPIOs. You can program it with the Arduino IDE and use the Arduino as ISP. If you can design you own custom PCB, a SMD version of the ATtiny is small, low and compact. The total circuit to make the ATtiny function is also minimal.

Also, at a low clock speed (0-4MHz), you can power the ATtiny at a voltage as low as 1.8V. You could probably even run it at 1.5V, but this is not totally recommended. If you want to be safe, a 3V coin cell will be small, flat, and it can last probably many years. It is also a little safer compared to lipos which have many risk, especially if you mount it on an animal that you can't really control.

I would also recommend SMD components if possible. It lets all the component be lower and it doesn't hurt or sratch the skin of the person/animal you are monitoring.

Looks like we both had the same idea!

thanks!! this looks great,  really appreciate the help!  I will try to learn the basics of how to set up the microcontroller etc. from the first circuit and once I get it working will probably change to SMD components as you suggested.  I think realistically I will need to do that to make it small enough.


text:
Using an Arduino as a crystal oscillator
I want to overclock my Game Boy Advance SP. It has a built-in 4 MHz crystal, and I was able to temporarily replace it with an 8 MHz crystal to see if I was able to overclock it, which I was :).
However I'm wondering if it's possible to emulate/simulate a crystal using an Arduino? Like instead of a crystal soldered to the Game Boy, two output pins from the Arduino? If not, is there a such thing as a variable oscillator? Like a crystal with a potentiometer to change the frequency when the potentiometer is adjusted?

Why would you waste a 10$+ Arduino/ATmega328 to replace a 0.25$ crystal?

Its temporary. I want to add a female port(s) to the side of the Gameboy where I can attach the Arduino to control the clockspeed.

The Arduino Uno (and most other Arduinos) doesn't really have a crystal oscillator (the on-board one is for the USB-to-serial chip, not the main processor).

You want to use the Uno? You can set up a timer to output varying frequencies and output them on a pin. I have a page about timers which might help. The fastest you can get with a 16 MHz processor is 8 MHz output however you can get other frequencies by changing the timer parameters.
The ATtiny85 can output higher frequencies if you use the PLL clock option, I think you can then adjust the resulting frequency.

If not, is there a such thing as a variable oscillator?

Adafruit make a Clock Generator Breakout Board - 8KHz to 160MHz. You connect that via I2C to your Arduino and then program assorted frequencies as a clock output. That uses the Si5351A clock generator chip.

Example code to output 8 MHz on a Uno or Mega2560:
#ifdef __AVR_ATmega2560__
  const byte CLOCKOUT = 11;  // Mega 2560
#else
  const byte CLOCKOUT = 9;   // Uno, Duemilanove, etc.
#endif

void setup ()
  {
  // set up 8 MHz timer on CLOCKOUT (OC1A)
  pinMode (CLOCKOUT, OUTPUT);
  // set up Timer 1
  TCCR1A = bit (COM1A0);  // toggle OC1A on Compare Match
  TCCR1B = bit (WGM12) | bit (CS10);   // CTC, no prescaling
  OCR1A =  0;       // output every cycle
  }  // end of setup

void loop ()
  {
  // whatever
  }  // end of loop

To output 4 MHz change OCR1A to 1 rather than 0.

Thanks for the reply! So I understand my UNO can output 8mhz. Now this might sound like a stupid question, but since it outputs on only 1 pin, how would I connect it to a device that would normally use a 2-Pin crystal oscillator? Would I connect that one pin to both sockets of where the crystal would be, or would I connect the one output pin to one side and GND to another?

Ok, so I found this code which outputs 8MHz on an Arduino Micro (which I own). I'm trying to figure out how to output 4MHz instead, while keeping the code similar.   http://pastebin.com/JFP7pUiF

Would I connect that one pin to both sockets of where the crystal would be, or would I connect the one output pin to one side and GND to another? Yes, but the Gameboy might not be designed for that. A circuit that expects a crystal should probably be given a crystal. You could get different value crystals from eBay for a couple of dollars.

Hmm. that's what I was thinking but then I saw this: https://youtu.be/nwJQxD8LLNY. He said he used a frequency generator, which to my knowledge, outputs a set frequency, so I thought he result would be the same with an Arduino. Can you show me how I'd go about changing this code (http://pastebin.com/JFP7pUiF) to output 4MHz, and show me how you did it? I checked out your page, and I'm normally pretty good with Arduinos, but I am COMPLETELY lost with this timer thing.

Since you tagged your question with "Uno" I've amended my answer to show how to do it on a Uno. The register OCR1A is what you count up to. If it contains 0 then it toggles the pin every clock cycle. If you count to 1 it toggles the pin every other clock cycle.

Ugh, just joined SE. Couldnt figure out the stanky tag thang! Thank you so much for the help! You are a GOD!

A crystal oscillator connection to a microcontroller typically consists of two pins - an output "driving" pin, and an input "amplifying" pin. The crystal sits between the two pins (basically between the input and the output of the amplifier) and the amplifier oscillates at the frequency of the crystal.
In general you can bypass the crystal itself and just provide a clock signal on the input pin (often labelled OSC1 or OSCI) and ignore the output pin since it isn't needed to drive a crystal.
Some microcontrollers provide a special "EC" mode (External Clock) which disables the amplifier and just expects a clock signal.

Thanks so much for the clarification! This clears it up alot!

Using the Arduino platform as a signal generator (oscillator) results in too high a granularity factor.  Software that has been suggested can only change between 8 and 4 MHz but not output anything between those two frequencies.
It would be better to use some sort of DDS or Frequency Synthesizer circuit
that can be adjusted incrementally with a granularity of 1 Hz or better.
My suggestion would be to use the Arduino to control a modern synthesis IC
like the S15351a.  This combination can output any frequency from 3KHz to
160 MHz in 1 Hz steps.  The device is inexpensive and has 3 outputs which
can be adjusted independently.  Google "Si5351a Arduino" to find some
circuit suggestions.
https://www.qrp-labs.com/progrock.html

On many Arduinos, including Arduino Uno, the main microcontroller uses a poor ceramic oscillator with a 0.5% tolerance (the crystal is only used for the USB side)


text:
Coding problem (gesture sensor)
Hi I am using an Arduino Mega 2560 with two sparkfun zx gesture sensors, two servos, 4 rgb leds strips and 4 light switches.
With the sensor, the code relies on interrupts, which interfere with the bahaviour of the servo and leds.
My knowledge of coding is limited so I am unsure of how to work around this, I think I have to introduce some new code.
interrupts leds and servos
However, I am unsure of how to introduce it.
Any help would be appreciated.

Driving servos and LEDs from a hardware PWM may help. They will maintain a steady state even if there are interrupts. They may be a little less responsive to changes if there are interrupts.
Are you doing too much when the sensor interrupts? Typically a sensor makes multiple measurements and may be filters the results. When it is ready it interrupts. In the interrupt it should do as little as possible. Typically sending a message via global to a polling function that is not running in an interrupt. For example it may set a flag and the poling function reads the result. Reading the result in the interrupt would be bad.

With the sensor, the code relies on interrupts, which interfere with the bahaviour of the servo and leds.

The best solution for this problem would be to use objects and the millis() function.
Here is a great tutorial about objects and why do we use them with the millis() function. I wont explain it because it it too long and this tutorial is simply better.
I would also suggest to see the blinkWithOutDelay example code from the Arduino IDE. It is probably the first step you have to take to learn how to use the millis() function.

canadiancyborg, that might not be relevant – the question appears to be about conflicting use of interrupts.