text:
Can I use the setup() function inside the loop() function
In the normal case the setup() function will be run once automatically and and then the loop() function will run many times.
I want to initialize several modules in the setup() function and then in the loop() I want to read values from them periodically. But if the period between usage is long I want to power off the modules. After defined time the modules will be powered on again and need to be initialized. Can I use the already existing setup() function inside the loop() to initialize the modules or I have to write another similar function? Is there any other better way to power off/on sensors and modules during the execution of code.

Sorry if I have not defined the question the right way, maybe somebody can help me edit it so that it can be properly formed

It could be possible, since it is going simply to call the same function BUT it is really a very bad design*.
Usually the main purpose for a microcontroller is just sitting there and run a procedure or main function repeatedly until the end of the world. And during one loop just to check if some conditions are met.
You should never stop or influence your loop() function and never mess up the default design of the arduino.
In you case (but it depends on your code and your application), you just want to run the loop() once all sensors have been already started (in the setup() function).
In your run, you check periodically the sensor and start a timer (better if interrupted). If an amount of time has expired and the sensor should be turned off, then the timer will call another function, which has the only target to switch sensors off.
The loop() runs again and again and if the original condition is met, then you can start your sensors again.
To save up time and code typing, I suggest you write only ONE function for switching on the sensors and call this function in setup() and in your loop(), something like this:
void startSensors();
void stopSensors();

void setup() {
  startSensors();  // I start all sensors here
}

void loop() {
  if( condition?!?! )
     {
       ...
       stopSensors();
       ...
     } else {
       ...
       startSensors();  // I call the same function here
       ...
     }
}

*: for istance you define in your setup() the connection through serial port. This means that your object "serial port" is going to be recreated each time you call setup() whit undefeined behavior in case it is outputting datas or has same data in the FIFO Buffer. Simply...setup() has that name because needs to setup things once. Everything that must be done more than once, then must be called from run() too.

Thank you very much for all people that corrected my English. English is not my native language and it is really difficult (impossible) to get better without correction.

What you recommend is a good habit for beginners. But for calling it a "very bad design" you should have some stronger arguments. I agree, it is not a good design.

I updated my answer

I agree, given the very good example, it is very bad design :)

I don't disagree with your conclusion, but starting serial a second time will not cause that undefined behavior. The serial ports are global objects defined in HardwareSerial.h, the user code on arduino never creates new instances.


text:
Compilation error when trying to give pointer to a function to another function
I'm trying to write a library for Arduino using the Wire library.
Here's my code:
PiCom.h:
#ifndef PiCom_h
#define PiCom_h

#include "Arduino.h"
#include <Wire.h>
class PiCom
{
public:
    PiCom(int address, int* integers[], double* doubles[]);
    static void onReceiveCallback(int numbytes);
    static void onRequestCallback();
private:
    //Actually arrays of pointers to the data to be sent, has to be declared that way cause the size of the array isn't known at compile time
    int** _integers;
    double** _doubles;

    void onReceive(int numbytes);
    void onRequest();

    static PiCom instance;
};

#endif

PiCom.cpp:
#include "Arduino.h"
#include "PiCom.h"

static void onReceiveCallback(int numbytes)
{

}

PiCom::PiCom(int address, int* integers[], double* doubles[])
{
    _integers = integers;
    _doubles = doubles;

    Wire.begin(address);
    void (*receiveFunction) (int);
    receiveFunction = &PiCom::onReceiveCallback;
    Wire.onReceive(receiveFunction);//Here i get an error
}

I want the  constructor to be created when a new instance is created. A mehtod in this object should be called when data is requested or received. When trying to pass onRequest(int) directly to Wire.onRequest(void (*) (int)) an error is thrown. Same happend when saving it to receiveFunction.
This problem was solved by using a static function (onReceiveCallback(int). I wanted this static function to call onRequest(int) in the object saved into PiCom::instance.
But now i'm getting another error:
PiCom\PiCom.cpp.o: In function `PiCom':
C:\Program Files\Arduino\libraries\PiCom/PiCom.cpp:26: undefined reference to `PiCom::onReceiveCallback(int)'
C:\Program Files\Arduino\libraries\PiCom/PiCom.cpp:26: undefined reference to `PiCom::onReceiveCallback(int)'

Pointer to a member function is a painful corner of C++ until C++11. This is why when you try to pass an instance method pointer to Wire.onReceive (without the static keyword), you will get an error similar to:
error: ISO C++ forbids taking the address of a bound member function to form a pointer to member function.  Say '&PiCom::onReceiveCallback'

Well, you can't argue with the C++ ISO standard... changing the function to a static one (with external linkage, as they say) is indeed a workaround, as you have found out.
For this workaround to compile properly you just need to omit the static keyword from your definition (where it is implemented), and leave your declaration (in the header file) as is:
PiCom.h:
...
static void onReceiveCallback(int numbytes);
...

PiCom.cpp:
void PiCom::onReceiveCallback(int numbytes)
{
    ...
}

By doing this you can pass it to Wire.onReceive without any problem, from the PiCom constructor, as follows:
PiCom::PiCom(int address, int* integers[], double* doubles[])
{
    ...
    Wire.onReceive(&PiCom::onReceiveCallback);
    ...
}

Works as it should. I already noticed that i forgot the "PiCom::" and also figured out that i have to use static only in thüe declaration. But anyways, thank you for the detailed answer.

source: Stack Exchange

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

sort: votes


text:
Memsic Accelerometer not returning T value
I hooked up a Memsic2125 accelerometer to a Arduino Uno.  X and Y values are returning fine, but the T value is returning -4000 every time.
// these constants won't change:
const int xPin = 2;     // X output of the accelerometer
const int yPin = 3;     // Y output of the accelerometer
const int tPin = 4;     // Y output of the accelerometer

void setup() {
  // initialize serial communications:
  Serial.begin(9600);
  // initialize the pins connected to the accelerometer
  // as inputs:
  pinMode(xPin, INPUT);
  pinMode(yPin, INPUT);
  pinMode(tPin, INPUT);
}

void loop() {
  // variables to read the pulse widths:
  int pulseX, pulseY, pulseT;
  // variables to contain the resulting accelerations
  int accelerationX, accelerationY, accelerationT;

  // read pulse from x- and y-axes:
  pulseX = pulseIn(xPin,HIGH);
  pulseY = pulseIn(yPin,HIGH);
  pulseT = pulseIn(tPin,HIGH);
  // convert the pulse width into acceleration
  // accelerationX and accelerationY are in milli-g's:
  // earth's gravity is 1000 milli-g's, or 1g.
  accelerationX = ((pulseX / 10) - 500) * 8;
  accelerationY = ((pulseY / 10) - 500) * 8;
  accelerationT = ((pulseT / 10) - 500) * 8;

  // print the acceleration
  Serial.print(accelerationX);
  // print a tab character:
  Serial.print("\t");
  Serial.print(accelerationY);
  // print a tab character:
  Serial.print("\t");
  Serial.print(accelerationT);
  Serial.println();

  delay(100);
}

The output looks like this...
-104    -24 -4000
-96 -24 -4000
-96 -24 -4000
-104    -24 -4000
-96 -24 -4000
-104    -24 -4000
40  -216    -4000
120 -184    -4000
72  -200    -4000
-80 -376    -4000
456 672 -4000
-8  -40 -4000
-112    0   -4000
-112    0   -4000
Any ideas on how to get the -4000 fixed?

Maybe I 'm wrong but it seems that only two accelerations (X, Y) are digital. What is T standing for?

According to the datasheet, T is the chip temperature and is an analog value, not a digital pulse like X and Y accelerations, hence you cannot read it and compute it the same way as X and Y!

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


text:
Data Report Which Technology
I want to create a small position reporter for cars. I found some good GPS Modules with which i could collect data. But i'm unsure with what technology i should send the data.
A possibility would be to setup a service in the www which is feeded by the arduinos.
I want to track the data live. so i think GPRS should be the right choice ?
Or more better are there any shields which make this GPRS LOG and SEND as a package ?
Which GPRS hardware would you use ?
Would you use something else?
Any hints are very welcome

You can actually find all the information for what you want to do on the formal Arduino.cc website. They suggest a GSM shield:

But of course you can find many other GSM shields for purchase. Most of them works the same. Arduino.cc also offer a nice GSM Library, with which you can perform HTTP GET/POST queries to a remote webserver (visible over the web).
You can select whatever web server technology you prefer for receiving the data. Using NodeJS, PHP, MVC.NET or any other, you could expose a REST API to perform the update from the Arduino+GSM Shield side using HTTP.
The web server then could analyze the incoming data and display it in any way you like.

I would add that feeding datas in www through an internet access is going to put some undefined time delay in recording and forwarding datas online. And this is what he wants to achieve.

I think that the average GSM latency can be considered to be 'live', as much as any other online service/game you used on your smartphone

yes. With live i mean "where has it been in the last minute or so"


text:
Arduino motor shield will only work in one direction
I have this Arduino motor shield which is hooked up with two DC motors. The board is the same as this one from Sparkfun.
A PWM output controls the speed of the motor, and a digital out controls the direction. The problem is that it only works in one direction, namely if the direction pin is high.
With the direction pin HIGH and 255 is written to the PWM pin, Vout on the terminals is similar to Vin. If I reverse the direction by setting the direction pin LOW I would expect Vout to be -Vin, ie. the polarity reversed. But not so. I get a little more than zero volt across the terminals.
It's the same for both channels.
Edit: The setup is powered from a 9V power adaptor through the barrel jack on Arduino.

Is the board defective, or am I misunderstanding something?
SOLUTION: Thanks to the edited post (especially #3) in the accepted answer, I not only looked at the schematic (again), I actually understood it. I had already noticed the jumper called V-LOGIC which on the picture from Sparkfun was set to 5V where it on my shield was not set. I really didn't know what it was used for, but I set it to 5V so it was the same. But by looking at the schematic and the inverters, I realized that the inverter was fed from V-LOGIC which was connected to 5V. And bingo: I had not connected the 5V pin on the shield, only vIN which I assumed would be sufficient. The thing is, I am awaiting a set of stackable headers instead of the ones supplied, so I only connected the minimum numbers of pins because I will need to desolder them when I get the new headers.

How have you hooked up the motor?

Sounds like something is hooked up wrong. Please add a photo or a diagram of your wiring. Also, what happens with the LEDs on the shield?

The motor is connected between 1 & 2 on the terminal. Or 3 & 4 for motor B. The LEDs light up for the direction that works (with the DIR pin high). For the other direction there is no light in the LEDs. Will add some photos tomorrow as it's late now. But thanks so far.

Added an image of the setup. Here the motor is connected to terminal A, but it's the same with B. Only works in one direction; the same applies to the LED.

Have you verified that the motor rotates in both directions independent of the board?

I think the problem is with your motor. What is the blue wire that's not connected to anything? I think this is not a 'simple' DC motor. It's not a brushless though, or it wouldn't run at all. I would try a different motor in this situation.

@Jasmine: If you look at the motor itself it only has 2 leads. The blue wire is likely an unused conductor in a 3-conductor cable.

I considered that, but then I also considered we only see one side of it in the photo. And, that it really should work, it's wired up fine, so something must be wrong with the motor, or the shield is broken and that's less likely.

The blue wire it not used. There are three wires in the cable and I just used the two of them. The motor spins fine in both direction if I reverse the wires, so it's definetely not the motor. Besides, I have 4 motors and it's the same for all of them! Also, as noted, I have measured the voltage across the terminal and I only get a reading for one direction (DIR pin is high). For the other, there is 0 V across the terminal. My best guess is that the shield is broken, it's just very unlike that BOTH channels would be broken, but of course not impossible.

Also, there is only light in the LEDs for one direction.

OK that sounds all good. Where is the power source for the motors? I don't see the 12V source for the motors in the picture? I can see that you're powering it from the USB, which is only 5V, and might not be enough voltage.

That the LED's won't light for reverse on either channel suggests you are doing something wrong - for example, you could be swapping direction and enable.  You might try looking up the L298 pinout and probing the input signals there - be careful though as it is easily shorted so you might want to do that using a current limited 5v supply rather than a high current 9v one.

I think you may be having an issue with how you are powering the shield.  Are you trying to do it with just your USB connection?
In your photo, I do not see a connection to your Arduino's barrel jack or to the Vin connector of the shield itself.  According to the SparkFun site:

The Ardumoto Shield should be powered through one of two power supply inputs. Pick one or the other:

The barrel jack input on the Arduino.
The Vin input on the shield

If you don’t want to use the Arduino’s barrel jack input, you can use the Vin input on the shield instead. This voltage input will supply both the shield and the Arduino. Like the motor outputs, this connection is broken out to both a 3.5mm screw terminal and a 0.1"-pitch header.
Do not supply power to both the Arduino barrel jack input and Vin on the shield!

I hope this helps!
EDIT BASED ON COMMENTS
Since you are properly powering the shield, I would recommend the following (see the shield's schematic for specifics):

Maintaining the connection shown above (with the addition of the 9V power supply connected to the barrel jack) ensure that you are able to properly set the DIRA input.  You can check this with a multimeter on pin 7 of the LN298 whenever you are trying to switch directions.
If you are getting the expected results on pin 7 (pin goes HI when your code wants the motor to go one direction and pin goes LOW for the other) - check pin 9... the value here should always be the opposite of what you are setting for DIRA on pin 7.  If that is all good, then you probably have an issue with the LN298.
If you are not getting the expected results at pin 9, but pin 7 looks good, then you are having a problem with the 74HC1G04 IC (although I would doubt this since you are having problems with both the A and B motor outputs).
If you are not getting the expected results at pin 7, then double check the code to make sure you have set and cleared the correct output pin.  I would also check the solder joints of the connectors on the shield - you can set a multimeter to do a resistance check from the shield's connector (pin 12) to the direction input on the LN298 (pin 7).  If the continuity is measuring close to 0 ohms then there is probably an issue with your code.
If your code looks good, I have also had issues with bad outputs on the Arduino - you can check to see if you are properly toggling the direction pin (pin 12) on the Arduino without the shield connected.  Then, if the pin is not toggling, there is probably an issue with your Arduino - try toggling a different (unused) pin and jumpering it.

I power the setup from a 9V power source via the barrel jack. Should have mentioned that, sorry. However, the shield works just the same powered from USB, only the motors spins somewhat slower.

"However, the shield works just the same powered from USB, only the motors spins somewhat slower" - and apparently in only one direction. The effect of lower voltage can be "doesn't work at all" it's not always just "weak"

Yes, but I do power it from a 9V external power source! I only say that it works the same powered from USB, because I tried that also :-)

@embedded_guy: Thanks for your thorough advice. Pin 7 goes HI and LO as expected, with the motor and LED on when hi. However, pin 9 stays LO all the time. And it's the same for driver B: Pin 13 goes HI and LO, but 15 stays LO. So two dead 74HC1G04 ICs?

Hooray! Problem solved. See my updated question.

@marlar Outstanding troubleshooting, I am glad that it is working for you now!


text:
Choosing right Sleep state
I'm planning on building an LED clock, but I want it to be lit only when I press the POWER button on my remote control. Using an IR receiver, which Arduino sleep mode should I use to reduce the current consumption but still be able to receive this interrupt?

Please be aware that, if you are using an Arduino board -ie you did not build your own- then you have a minimum consumption that you cannot reduce, e.g. due to voltage regulator current leakage, or (for UNO) ATmega16u2 is always running (for USB handling).

Also the IR-receiver uses something like a milli-amp. And then there is the power-on led.

@jfpoilpret Thank you I'm aware of that but at least I can consume a little bit less during the whole day.

You can drive the vcc directly by-passing the on board linear regulator. You can directly drive it with 2(2.8v), 3(4.5v) or 4(6v) for AA's. Note the ATMEGA328 is 6v and TSOP38238 is 2.5 to 5.5v

Related question has an answer by me with example code.

I recommend reading ArduinoSleepCode. Where it demonstrates placing the avr into a sleep state and using an interrupt to awake from the sleep state. In your case you can connect the output of your IR demodulator to the interrupt  pin, to simular awake.
Ken Shirriff's IR library allows you to use any pin as a receive input, so that you can use INT0 or 1 on D2 or D3. If you need to use a different pin, the Microtheron's github fork uses Pin Change interrupts. (I am not sure if stock sleep.h will awake from PCint, like int0 or 1 will, without tweek. Section 10.1 of data sheet says it will.)

You can only wake from INT0 and INT1, and only using the LOW trigger-mode; no PCINTs. The only problem is staying awake for a moment, while all the IR data is coming it, as the library you propose uses timer1 to sample the data coming in.

@Gerben I didn't think of that, while I'm pressing for the first time the POWER button the Arduino is still sleeping so it could miss some data, am I right?

Note the bootloader from any reset typically takes 5 seconds before executing the setup () followed by loop ().

Most ir protocols have a long initial pre-amble, before the data part to allow settle time for waking up. Where sherrif's already learned protocols require this in entirety. And as you noted it will be partial, at first. Where sherrif's ir library could be adjusted for this.

My thougt was to wake up from the intitial space (pre-amble) and start so that timer1 can resume. Alternatively one can tweak the lib to  either go back to sleep if no ir is present otherwise stay wake. This will only be awake for a moment every 50ms. This will extend life a long time (years). Many systems do such.

I still didn't get your answer because the commentaries here seems to me (Im very noob on this) that you cant use that library for this?

could anyone (sorry for asking) can write some dummy code to get the idea?


text:
Serial interrupts?
In a project, I’m using an EIA485 bus to send encrypted data packets. That works with Arduino’s buffered serial, but it is kind of awkward, and I’m using none of the more complex stuff in that class anyway.
If I do not use Serial anywhere in my Arduino sketch, is it safe to create my own interrupt handlers for USART_RXC etc. and to directly manipulate the USART registers?

Absolutely. The only interrupt that Arduino takes for itself unilaterally is the timer 0 overflow interrupt, used for timing purposes (delay(), milliseconds(), et alia).

Does it only define the ISR (like this one) once you've used the Serial object?

@Gerben: Using Serial causes it to link in two additional vectors on the '328P: USART, RX and USART, UDRE. I have not checked whether using Serial1 et alia is required for the further vectors on the '1280 or '2560. And to be fair I have not verified any of this on ARM.

Hmm 485. FYI if your interested in 9bit. I recently helped a friend and found it much quicker to tweak the existing core library. Rather than rewrite it. See https://gist.github.com/mpflaga/ebe6aadd20f81de8e970


text:
What's the smallest Arduino board with wifi capabilities?
The Photon from Spark IO looks super small. Are there smaller wifi enabled microcontrollers available that can be programmed with the Arduino IDE?

It's impossible to answer this kind of question and that the answer will stay relevant for a substantial amount of time. Today it's chip X, tomorrow chip Y...

For a tiny arduino with wifi look at tiny-circuits. Not the cheapest option or easiest for prototyping. But quick and easy to get up. https://tiny-circuits.com/tiny-shield-wifi.html

From your question it implies that the Spark IO use the Arduino IDE - it's not. It has two different IDE's, one is web based and the other is downloadable. In addition, it's not an Arduino per-se. It is based on the Wiring library, which is similar to the Arduino library but not exactly the same. And of course the MCU is not Atmel, but that is also the case with Intel's Galileo board.
As to the size question in hand - my believe is that the Arduino products are designed for prototyping, so the size of the product is less important. This is the case for several reasons:

Costs -  the different Arduino products are pretty expensive for mass production.
Peripherals - the Arduino boards come with different peripherals (such as the FTDI chip) which will probably be omitted in an end-user product, and which makes its size larger.
Pins - almost every (official?) Arduino product comes with pre-built male/female header pins, which are excellent for prototyping but not for production, because of the large vertical space they take.

There are many more reasons, but you get the point.
When moving to production with an Internet of Things product, it makes sense to fabricate your own PCB, and design it with a small Atmel chip you used for prototyping (such as ATtiny85) and small Wifi chip, such as the ESP8266. This is an example for such fabricated PCB, although the size is not the 'smallest' possible.
However, for beginners, or a one-time project, it would absolutely make sense to use a pre-fabricated Arduino product, in a small scale that could provide both easy coding capabilities, various libraries and a WiFi included. For that purpose, the Spark IO seems to be at the bleeding edge at the moment - but you never know what will be there tomorrow...

thanks for the detailed answer and the great example, very helpful!

Hi Omer thanks for this useful post - I am looking at making a prototype and it's useful to understand that the production hardware will be different - I was worried about the height of those vertical pins and if they were necessary. I would like to prototype something where the software made is not throw-away so I guess spark (now particle) looks like a good way to go


text:
Arduino serial communication broken. Possible due to short circuit
So I have a project I'm working on where I have about 6 arduino boards communicating with one another through cables. I've been testing them using a regulated DC PSU and at some point I caused a short and since then I can't upload any sketches onto the arduino. On some of them, the TX pin will light up while trying but RX won't and the IDE tends to freeze after around 90% of the upload process is complete.
Does anyone know how badly I screwed up? How do I avoid this next time? Is there an easy fix?
Thank you!

Can you give more details about the short circuit? Where did the current go?

Can you say us which Arduino board you have? Maybe you can switch the micro itself or maybe not

Try disconnecting the arduinos from each other, use a different power supply,plug pack or power via usb from pc and try programming and running them one by one. Try the simplest program possible and go from there(led flash of onboard led then change pins and use a led with resistor to check if you have blown any io pins).Which boards as if its older ones you may have just damaged the usb to serial chip. Or if a dip not smd board you maybe able to just replace the atmel chip. More details, circuit diagram and maybe a link to a picture would help us help you.


text:
Can the Sparkfun AVR pocket programmer bootload/program a 3.3 V ATmega328p
The product in question - https://www.sparkfun.com/products/9825 - operating at 5 V (and can also supply it to the device being programmed).
I need to program the bootloader onto a 3.3 V ATmega328p and don't have any level shifters immediately available. Thus the question. The "Hookup Guide" for the product (https://learn.sparkfun.com/tutorials/pocket-avr-programmer-hookup-guide) seems to suggest that it will work fine as long as the 3.3 V device being programmed isn't powered by the programmer. I wouldn't have thought it's the best idea in the world, but maybe I'm wrong.
So any practical experience?
Are the over voltage tolerances for input lines on Atmel devices good enough to handle the extra voltage?
I guess the output level from the device being programmed would be high enough to be buffered up to 5.0 V?

What is a "3.3V Mega328p"? Do you have a link to a product page?

"Mega328p" - can you please specify the exact kind of Arduino/break-out board you are working with? The ATmega328p max operating voltage is 5.5V

As a test run I would like to boot load an Arduino Pro Mini 328 - 3.3 V / 8 MHz - https://www.sparkfun.com/products/11114. (My actual intent is to bootload a custom board I've designed which also uses the same Atmel Mega 328p.)

Unless you copy the design of the board, the two experiences aren't directly comparable.

With that combination of programmer and Arduino you have two possible options:

Cut JP1 on the programmer and power the programmer from the Arduino. With this you will have to make sure that the Arduino is connected and powered up before you connect the programmer to USB.
Cut SJ1 on the Arduino and allow it to be powered by the programmer at 5V. The Arduino itself isn't required to be powered at 3.3V, that's simply what the on-board regulator provides, so we cut SJ1 in order to isolate the regulator from the MCU. Note that any devices connected to the Arduino will need to support 5V operation in order to this to be safe.

It is not safe to put 5V at the output of the regulator, so you must make sure that does not happen.

The SJ1 jumper controls the output of the MIC5205 regulator, no reason to remove it in order to feed the regulator with 5v

@Omer: You're feeding 5V to the output of the regulator. There is a parasitic diode in LDO regulators that can cause latchup if the output is allowed to go higher than the input, as may be the case if the Arduino is powered by a LiPo battery.

Not sure why you would want to feed the output and not the input (raw) side of the regulator? perhaps I'm missing something, but isn't the regulator "sits" between the breakboard's VCC and the ATmega328p's VCC?

@Omer: You feed the output because trying to use 5V programming signals on the MCU while supplying it 3.3V will fry it.

The Pocket AVR Programmer has a logic level shifting (74ACT125) on board, specifically for this situation. There is nothing wrong with powering the target with a separate power supply that the programmer. Why else would there be a "power target"/"No power" switch?
I don't see why other people would suggest cutting traces, when all you need to do is toggle a switch.

Although the schematic reads "ACT" directly at the device, the note just below it says "AC", as do the actual product shots. I agree that if it actually used an ACT/HCT device then it could be fine, but as it is the '125 may not be able to reliably detect the 3.3V signals coming back from the device.

Are you referring the the ACT version having a required supply voltage of 4.5v to 5.5v? I think all the IO voltages are well within the Minimum HIGH Level of both the buffer and the attiny?
If all this doesn't work, why would they bother putting in a buffer at all? I'd love to hear your thought, as I'm planning on building my own buffered programmer based on the usbASP. The 3.3v ones I have from ebay aren't really 3.3v while programming, I found out.

I'm talking about the high input levels. ACT/HCT has a high input voltage of 2.4V, which is within the high output voltage of 3.3V CMOS, but AC/HC has a high input voltage of 0.7Vcc, which with a 5V supply means 3.5V. If you're going to build your own then I recommend using a MAX3392E so that the target voltage is properly handled.

But the buffer is powered by the target's voltage. So if the target is 3.3v the minimal input HIGH would be 0.7*3.3 = 2.31V, right? By the way, I can't find the 0.7Vcc anywhere in the datasheet, or is that the wrong datasheet?

Okay, I've unpuzzled it. The '125 will be powered by the device if the jumper you mention is left disconnected. The AC has enough drive to push its output voltage high enough to reach the 0.6Vcc needed by the 5V '2313 when supplied with 3.3V. The datasheet gives explicit output voltages at various arbitrary values of Vcc instead of an equation, but if you do the math then you'll find that it's 0.7Vcc. Therefore your answer is correct, but I'd still prefer to err on the side of caution.

Thank you @IgnacioVazquez-Abrams . I think I got it now.

ATmega328p Operating Voltage is 1.8v-5.5v, as stated in the second page of the datasheet (PDF):

So there should be no problem feeding it with a regulated 5v VCC while programming it, and then supplying it with 3.3v on normal use. Just make sure you do not leave any 3.3v devices (which are not 5v tolerant) connected to the ATmega328p during the programming of the chip.
Regarding the Sparkfun's Pro Mini 328 3.3v/8Mhz, you can read in the comments section of the Pro Mini page that customers successfully managed to power it with 5v without any issue. You can see from the schematics that the voltage regulator in use (MIC5205) has a max input voltage of 20v, so 5v should not pose a problem to power it up.
EDIT: See Ignacio's answer. My answer apply for powering up the Pro Mini not for programming it with 5v signals and 3.3v VCC. The SJ1 jumper will need to be removed in order for the MIC5205 regulator to supply 5v instead of 3.3v.


text:
Help with parts identification from arduino starter kit from aliexpress
Ordered an arduino starter kit from aliexpress Link
The parts list they provide (as a jpg on the order page) is vague and not very descriptive, I've gone through most of the parts and am down to three they did not list.

Capacitor? -- Looks to be a capacitor, labeled HDX and nothing else, rattles when I shake it.

Black LED -- I think this is a flame sensor; if it is, what's the difference between this and an infrared receiver (like a 1838B) or photoresistor?

They also list something as 'a digital control' near the bottom of the list, not sure what that is? Every other part from the list is matched up and I don't see anything different in the first picture (not parts list picture) from what I have received in the order.

Rather than linking to OneDrive you can press the image button, browse to the image on your PC and it will automatically put it on imgur. Stack Exchange back those up so the image won't go missing in the future.

Thanks for the tip; didn't know that. I took the picture as I was typing my question and didn't want to go download them. I'll upload them here now.

The "black LED" is not a LED. I forget what exactly it is, but I have one sitting in my parts box. I'm pretty sure it is a photo-something. Light waves affect it. As for the capacitor-looking things that rattle, I got no idea.

Those are tilt sensors. The rattling is a metal ball that contacts two pins inside, closing the connection.
The 1838B is a full module that partially decodes the received IR so that a MCU can fully decode the rest easily. What you have there is a bare phototransistor with an IR window on the top. You would use it for proximity or presence sensing. Instead of varying its resistance, it varies the amount of current it will pass.
Probably the single-digit 7-segment display, as opposed to the 4-digit display they have listed as "4 digital tube".

Just did some tests with the parts and this answer is correct: #1 is a vibration sensor, it points up and cuts off current if it detects vibration. #2 is a phototransistor, works with flame but not light (unsure how this works in comparison to photoresistor, will have to do some research). For #3, I am leaning towards them meaning the single-digit 7-segment display, since there isn't anything else on the parts list that matches it, but unsure why they used 'control', I think maybe they just translated wrong or the vendor doesn't really understand what the component is.

@PGT: Flames give off much more IR than a light bulb.

Just a quick thanks. I ordered a set from a supplier called Sintron, also had some vague descriptions and the 2 listed above are the two I was also having difficulties with.  At first I thought caps, but...they shouldn't rattle... :D

I recently purchased the arduinotech module learning Kit and contains both components shown above. It does  mention an Infrared Photo Diode which it think is your "Black LED".
Thanks for the heads up on the HDX switches. Now I know what they are.:)

The HDX is a "Tilt Switch" Turns on/off depending on the angle.

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


text:
EFCom GPRS/GSM Shield
I have an EFCom GPRS/GSM Shield
http://www.elecfreaks.com/wiki/index.php?title=EFCom_GPRS/GSM_Shield
and I am using it with a mega 2560. The problem is that the code in the wiki page
//Serial Relay - Arduino will patch a
//serial link between the computer and the GPRS Shield
//at 19200 bps 8-N-1
//Computer is connected to Hardware UART
//GPRS Shield is connected to the Software UART

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);
void setup() {
  mySerial.begin(19200);               // the GPRS baud rate
  Serial.begin(19200);                 // the GPRS baud rate
}

void loop() {
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}

makes use of software serial but mega 2560 cannot use software serial on pin 2, as in the arduino reference, thus I changed the pins to 50 and 51 and used external female-male headers to connect s_tx to pin 50 "rx" , and s_rx to pin 51 "tx", still no response with the AT command...
code after update is :
#include <SoftwareSerial.h>
SoftwareSerial mySerial(50, 51);
void setup() {
  mySerial.begin(19200);               // the GPRS baud rate
  Serial.begin(19200);                 // the GPRS baud rate
}

void loop() {
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}

Note that I am using the Arduino IDE serial monitor.

Try to connect "Pin RX on Mega to Pin RX on Shield" an "Pin TX on Mega to Pin TX on Shield":

Pin 50 (Rx)  on Mega <==> Pin 2 GSM Rx on Shield
Pin 51 (Tx)  on Mega <==> Pin 3 GSM Tx on Shield

I use an Geeetech Shield with a Mega 2560 and connect RX to Rx and TX to TX. Works fine.
Another solution is to use Serial1 instead of using SoftwareSerial ...
First connect:

Pin 19 (Rx1)  on Mega <==> Pin 2 GSM Rx on Shield
Pin 18 (Tx1)  on
Mega <==> Pin 3 GSM Tx on Shield

    //Serial Relay
    unsigned char buffer[64];  // buffer array for data receive over serial port
    int count=0;               // counter for buffer array
void setup()
{
  Serial1.begin(19200);
  Serial.begin(19200);
}

void loop()
{
  if (Serial1.available())
  {
    while(Serial1.available())
    {
      buffer[count++]=Serial1.read();
      if(count == 64)break;
    }
    Serial.write(buffer,count);
    clearBufferArray();
    count = 0;
  }
  if (Serial.available())
    Serial1.write(Serial.read());
}

void clearBufferArray()
{
  for (int i=0; i<count;i++)
  {
    buffer[i]=NULL;
  }
}

You can use a Arduino IDE's Serial Monitor, Serial Terminals(sscom32) or Bray++ Terminal to send AT commands to the Shield, communicate with it.
I hope this information is helpful.


text:
Use website to communicate with Arduino WirelessProtoShield
I have a small office with wireless network, is it possible to make a wireless doorbell?
Practical example:
Arduino is connected to the main wireless network and has a static ip,
i have a website that connects through arduino using ftp to activate the "open door" function.
note: "open door" activates a motor to press the button, or i will hack the current doorbell to connect wires :D

Arduino wifi web server: http://arduino.cc/en/Tutorial/WiFiWebServer just modify the webserver to show a "open" button and to receive a post request and open the door.

Whilst you link may answer the question, it would be preferable to include the essential parts of the linked here, and provide the link for citation. Can you please edit your answer?


text:
DS1307 RTC conflicts with DS18B20
I'm working on a project to output the temperature from a DS18B20 to a 16x2 LCD while logging the temperature to a CSV file using the Adafruit Data Logging Shield. I keep getting this error when verifying the code:
RTClib-master/RTClib.cpp.o: In function `RTC_DS1307::now()':
/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:252: undefined reference to 'Wire'
/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:252: undefined reference to 'Wire'
/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:252: undefined reference to
'TwoWire::beginTransmission(int)'RTClib-master/RTClib.cpp.o: In function 'TwoWire::write(int)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Wire/Wire.h:72: undefined reference to 'TwoWire::write(unsigned char)'
RTClib-master/RTClib.cpp.o: In function 'RTC_DS1307::now()':
/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:254: undefined reference to 'TwoWire::endTransmission()'
/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:256: undefined reference to 'TwoWire::requestFrom(int, int)'
/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:257: undefined reference to 'TwoWire::read()'
/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:258: undefined reference to 'TwoWire::read()'
/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:259: undefined reference to 'TwoWire::read()'
/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:260: undefined reference to 'TwoWire::read()'
/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:261: undefined reference to 'TwoWire::read()' RTClib-master/RTClib.cpp.o:/Users/grafton/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:262: more undefined references to 'TwoWire::read()' follow

When I comment RTC_DS1307 RTC; in the code (below) these errors go away, but of course I get errors related to an undefined RTC. I'm a newbie cobbling together code from various sources, so any help is greatly appreciated. Code follows:
#include <LiquidCrystal.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2
#include <SD.h>
#include "RTClib.h"

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
const int chipSelect = 10;
File tempLog;
RTC_DS1307 RTC;

LiquidCrystal lcd(6, 7, 8, 9, 11, 12);

void setup() {
  Serial.begin(9600);
   while (!Serial) {
    ;
  lcd.begin(16, 2);
  //         ----------------
  lcd.print("Current temp (F)");
   sensors.begin();
   }

Serial.print("Initializing SD card...");
  pinMode(SS, OUTPUT);

  if (!SD.begin(chipSelect)) {
    Serial.println("Initialization failed!");
    while (1);
  }
  Serial.println("Initialization done.");

tempLog = SD.open("templog.txt", FILE_WRITE);
if (! tempLog) {
  Serial.println("Error opening templog.txt");
  while(1);
}
char filename[] = "LOGGER00.CSV";
  for (uint8_t i = 0; i < 100; i++) {
    filename[6] = i/10 + '0';
    filename[7] = i%10 + '0';
    if (! SD.exists(filename)) {
      // only open a new file if it doesn't exist
      tempLog = SD.open(filename, FILE_WRITE);
      break;  // leave the loop!
    }

  Serial.print("Writing to: ");
  Serial.println(filename);
  tempLog.println("Data Logging File");
  tempLog.println("Date,Temp(F)");
  }
}

void loop() {
  sensors.requestTemperatures();
  float temperature = sensors.getTempFByIndex(0);
  lcd.setCursor(6, 1);
  lcd.print(temperature);
  Serial.println(temperature);
  //-----------------------------------------------------------

String dataString = "";

//date time stuff-------------------------------------------

DateTime now = RTC.now();
  // log time
// tempLog.print(now.unixtime()); // seconds since 1/1/1970
//  tempLog.print(", ");
  tempLog.print('"');
  tempLog.print(now.year(), DEC);
  tempLog.print("/");
  tempLog.print(now.month(), DEC);
  tempLog.print("/");
  tempLog.print(now.day(), DEC);
  tempLog.print(" ");
  tempLog.print(now.hour(), DEC);
  tempLog.print(":");
  tempLog.print(now.minute(), DEC);
  tempLog.print(":");
  tempLog.print(now.second(), DEC);
  tempLog.print('"');

  tempLog.print(",");
  tempLog.print(temperature);
  tempLog.print(",");
  delay(500);

tempLog.println(dataString);
tempLog.flush();

}

The RTC library requires the Wire library. Just put #include <Wire.h> in front of the line #include "RTClib.h"

I have tried to simply #include <Wire.h> in RTClib.h, rather than putting #include <Wire.h> above #include "RTClib.h" in my sketch, but this does not work.  Do you know why?

That indeed doesn't work. I don't know the reason; sorry.


text:
Using an Arduino as an input device
I had an idea to create a control panel using an arduino and some buttons. How would I go about making the arduino emulate an input device so that when I press a button connected to the arduino, it would cause the same effect as when a keyboard key was pressed? (I'm using arduino UNO, if it helps.)
Thanks in advance.

Welcome to Arduino SE! This post was closed as a duplicate of this question: http://arduino.stackexchange.com/questions/991/can-the-2nd-mcu-on-the-uno-r3-be-used-for-keyboard-emulation. If you feel that this question is different, please feel free to edit your question. Thanks!

I don't agree that this is a duplicate. That question asks whether or not it can be done in a specific way, whereas this question asks in general, only mentions the Uno in passing (and not even the R3 specifically), and doesn't bring up the '16U2 at all.

The easy answer is to use a Leonardo, Micro, or Due instead. They already support USB HID functionality via Mouse and Keyboard.
If you insist on using an Uno R3 then you will need to reprogram the on-board ATmega16U2 to accept serial commands from the ATmega328P and generate the appropriate USB HID events.
If you're using an Uno or clone that doesn't have an ATmega16U2 as well then you're SOL and will have to write a program that runs on the computer that receives the commands via serial and translates them into HID events.

I have successfully reprogrammed the UNO's R3 8U2 to support keyboard emulation, as to just this. Making dedicated user inputs for kiosks to Computers. I recommend NicoHood's GitHub as it allows simultaneous Arduino Bootloader and Keyboard functionality, making it easy to reprogram the Arduino.
This along with using Capacitive Touch Sensor connected to Copper tap under clear acrylic protecting printed graphics of buttons is very quick and easy to make. Very little machining.
Example of such code is found at artemis-firmwares it was initially created with a different 8U2 method. Where next time we will use NicoHood's.
Note the stock keyboard send key command for the Arduino is limited. Where the above methods allows the code to send complete virtual keys supporting full emulation.


text:
I2C LCD Serial Interface Board not displaying text (wrong pins?)
I have a 1602 LCD screen that works fine on its own. However I wanted to free some pins by using an I2C / IIC LCD controller I purchased separately.
While the controller seems to be communicating with my Arduino UNO on the right address, I cannot get text to display. By default (no code) it seems the LCD will have 1 line of 16 solid "squares". When using address 27 in my code, the LCD will change to 2 lines of 16 squares (see photo below). The code also calls for the backlight to flash 3 times, which works. However I cannot get anything but 2 lines of squares. (Full code is at the bottom of this question).
I'm using the LiquidCrystal_I2C library by F Malpartida, which seems to be commonly used.
Is there a better library I should be using?
I'm wondering whether it's just the wrong pins being used in the code. All sketches I see online use the following pins:
//                    addr,en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
// Set the LCD I2C address

But all of the 1602 LCDs I see online have the same pins as mine, as you can see in my photo below:

These pins seem to be standard:

To further confuse me, the pins on the LCD board start with 1 on the left, yet the default code's pins seem to start with 0! So I tried changing the code's pins to the numbers on the LCD board. The LCD no longer changes to 2 lines of squares and no longer blinks the backlight. I then tried subtracting 1 from each pin (to start from 0), same result. I then tried used the default pins minus 1, same result. Thus the default pins are somehow more correct?! What am I doing wrong?
Has anyone else gotten one of these I2C controllers to work for them, and if so, how?
Full code:
/* YourDuino.com Example Software Sketch
 16 character 2 line I2C Display
 Backpack Interface labelled "YwRobot Arduino LCM1602 IIC V1"
 terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <Wire.h>  // Comes with Arduino IDE
// Get the LCD I2C Library here:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
#include <LiquidCrystal_I2C.h>

/*-----( Declare objects )-----*/
// set the LCD address to 0x27 for a 20 chars 2 line display
// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  Serial.begin(9600);  // Used to type in characters
  lcd.begin(16,2);   // initialize the lcd for 16 chars 2 lines, turn on backlight

// ------- Quick 3 blinks of backlight  -------------
  for(int i = 0; i< 3; i++) {
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  }
  lcd.backlight(); // finish with backlight on

//-------- Write characters on the display ------------------
// NOTE: Cursor Position: (CHAR, LINE) start at 0
  lcd.setCursor(0,0); //Start at character 4 on line 0
  lcd.print("Hello, world!");
  delay(1000);
  lcd.setCursor(0,1);
  lcd.print("HI!YourDuino.com");
  delay(8000);

// Wait and then tell user they can start the Serial Monitor and type in characters to
// Display. (Set Serial Monitor option to "No Line Ending")
  lcd.clear();
  lcd.setCursor(0,0); //Start at character 0 on line 0
  lcd.print("Use Serial Mon");
  lcd.setCursor(0,1);
  lcd.print("Type to display");

}/*--(end setup )---*/

void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  {
    // 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());
      }
    }
  }

}/* --(end main loop )-- */

Did you remember to add the pullups?

@Ignacio, Can you elaborate? I'm only using 4 pins total. A4 and A5 for SDA and SCL respectively. 5V+ and GND for the controller.

http://electronics.stackexchange.com/questions/102611/what-happens-if-i-omit-the-pullup-resistors-on-i2c-lines

As far as I know, the pull-up resistors should be integrated with the display. Did you try different addresses? I have a similar one, which works on address 0x3F. Maybe this helps.

Probably not the problem, but have you tried adjusting the contrast using the potentiometer? The numbers in the code refer to which pin on the PCF8574 chip is connected to which pin on the lcd board. P3 on the I2C board is evidently connected to the backlight pin on the LCD. But I think the other pins are wrong somehow. Try using a multimeter to see where the P0-P7 pins of the PCF8574 go to which pins on the lcd header.

The board was sold as "address 27", and 27 is the only address that responds at all. It's actually customizable by soldering the A1 A2 and A3 pins just above the trimming pot seen in the photo.

@IgnacioVazquez-Abrams, although the pullups should be built into the controller, I tried adding them manually to no avail.

@Gerben, I adjusted the trimmer already and it's either full blocks or nothing at all. There are two circular plastic blobs on the bottom of the LCD board. I cannot actually see any ICs. I don't think I have any way to see or measure the pins of the PCF8574 because there are only 8 contacts on the back of the board, but the PCF8574 has 16. I'm ready to blame the controller.

Although it may not be the issue, you should pay attention to the soldered pin headers on the LCD, from the picture they appear to not completely cover the copper around the hole; I would try to improve these solder points first.

The PCF8574 is the chip on the I2C interface board, not on the lcd board. Please re-read my comment, it see if it makes sense now. Otherwise, let me know.

@Gerben, derp. I tested the chip with a multimeter, however I am still completely confused. Pins 9-12 on the chip correspond to D4-D7 on the lCD. Pin 6=E, 5=RW, and 4=RS. I cannot figure out what pin 7 actually is. Using those values gives me no response from the LCD again. Also, am I supposed to subtract 1 from those pins? Because again, all the default codes out there have pin 0=RS. But that can't be, because the first pin on the chip is A0 (address). Basically, changing any single pin will either kill the backlight response or stop the 2nd row from showing the block characters.

The numbers 0-7 in the code refer to the P0-P7 pins on the PCF8574. If you look at the datasheet, P0 is on pin 4, P1 on 5, P2 on 6, P3 on 7, P4 on 9, P5 on 10, P6 on 11, P7 on 12.
So in your case, P0 goes to RS, P1 to RW, P2 to E P3 to backlight, P4-P7 to D4-D7. So your numbers in the code you've given were correct (i.e. LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);).
So that wasn't the problem. Try reseating the headers in the breadboard, as there could be an improper connection. Also resolder the header on the LCD, as they aren't great solder joint (to little solder).

I have the very same problem. I2C scanner found the display. I also traced the connections and got the same pin setup. I can turn on/off the display - it has a cursor but no text. No clue what's going on. Did you solve it eventually?

@tcurdt I've had no success with those particular components. I found that I can buy a 1602 LCD with an I2C controller already attached for nearly the same price, and that worked for me.

Just got into this. Backlight control works, no text output on display.

It's a good idea to check what library and code the seller told to use, most of them provide samples.

First of all, it looks like these wires aren't properly connected:

I haven't disassembled a female jumper before, so that might not be the issue. However, it seems likely that this could be a cause.
Also, you need to adjust the contrast by turning that trimmer (the blue thing that looks kinda like it has a screw in it). LCDs will either display nothing, a washed out version of the text, or blue boxes if the contrast is not set correctly. This is probably the cause.

The jumpers are like that only because I moved the board for the photo. Also I adjusted the trimmer already and it's either full blocks or nothing at all.

I bought the SainSmart 20x04 and I also had to change the address to 0x3F.  My backlight jumper was missing, that little header at the right of the I2C board provides the backlight power.  Some code I found included this:
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);

Change this code:
LiquidCrystal_I2C lcd(0x26, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

To this:
LiquidCrystal_I2C lcd(0x26, 2, 1, 0, 4, 5, 6, 7, 8, POSITIVE);

(The argument before "POSITIVE" is changed from a 3 to an 8)

Any explanation why? There is no P8 on the PCF8574.


text:
Arduino board to control microwave oven?
So I've taken apart an old microwave oven with a touch-sensitive LCD screen. I understand that I could die from playing around with this, so I've disconnected the high-voltage transformer and the magnetron. I'm also not going to remove any of the safety switches like the door switch. My question is, how is the microwave controlled? I'm thinking there is a computer chip somewhere in the circuit, and I'm looking to replace it with an Arduino board plus some extras, like AC relays and such. I'm curious as to how the microwave oven controls its functions, like power level, cooking time, and the beeping. Any advise as to how I could get started interfacing?
Is the power level controlled by PWM by any chance? Can you PWM alternating current?

It's pretty much all proprietary. It can be done, but you'd have to replace all the circuitry with the Arduino, interfacing with the existing magnetic and mechanical devices and doing everything in your own code.
Power level is controlled by PWM, but it's extremely low frequency PWM, on the order of 0.05Hz (20s period). That's why there are two different sounds that come from the microwave when it's not at full power; one when the magnetron is active, and one when it is off.

There is no power level in a microwave. It's just on or off. They lower the power by turning on the magnetron for a few seconds, and then off for a few second. You can actually hear this.
It's probably turned on by a relay, triac, or solid state relay. The magnetron is just requires a high voltage to work; nothing else.
The programmes, timing, and handling of the buttons is done by some microcontroller, similar to an arduino.

So the magnetron is just set at it's own "power level?" There's no variation of the output, it's just how long it is turned on? And I'm guessing if I set the power level on the LCD to full power, the magnetron would be on 100% of the time?

@user3211857: Correct.

Hmm, so if I wanted to control the operation with an Arduino, could I hook the Arduino up to an AC relay module, hook that up to the switch that turns on the magnetron, and program the Arduino when to digitalWrite(pin, HIGH)? Any ideas?

You wouldn't use a relay for pwm. Most relays can't switch fast enough .

You wouldn't use a relay for subsecond PWM. A microwave doesn't use subsecond PWM for its magnetron.

Just keep the door switches in series with the power going into the transformer. That way, the magnetron is disabled when the door is opened. Also use a relay that is rated for the amount of amps going through it. Note that there is also a motor, and probably a fan in parallel to this transformer, so the plate is spinning, and the fan is cooling the magnetron. Also keep the snubber circuit on the incoming AC line. Other than that, you got the basic idea of how to operate it correct.

Just hopping in here to point out that lots of newer microwaves do have multiple power levels for the magnetron. For older microwaves and some newer ones, the "on or off only" is still true, though. If the microwave in question is one of the new multiple power ones, there is no problem programming it as just on or off like an old fashioned one. And it's a lot safer than measuring and controlling the variable power settings.

If you want to learn more about AC power circuits start with relays (start with 5v or 12v dc as a lot safer , cheaper and easier) something like the spark fun power tail if you really do want to control 120V devices note its only on/off control, not different power levels. https://www.sparkfun.com/products/10747
You can generate AC from DC by using pwm at a lower voltage and driving a transformer
or a digital inverter. Can use an arduino to do it if you wanted to.
Use pwm function, then via optocouplers (to protect the arduino) to power mosfets or an h-bridge to drive a transformer. Can fairly easily produce 120V/240V output
Time to grab a good basic electronics book like Art of Electronics (should be able to find a pdf version)
3rd edition is finally getting published in 2015

Thanks for the tips. I've already messed around with AC voltage (luckily I'm still alive). I just used a relay module and hooked it up to my Arduino and the Wall outlet to control Christmas lights. But I haven't tried what you describe, generate AC to DC. Sounds pretty interesting.

other way around generate AC from DC. Thats how the static inverters for cars ,boats and aircraft can generate 120V/240V AC from 12 or 24V dc. First step is to get the arduino to output a sine wave (or close to a sine wave ). Learn more about pwm (also good for led brightness control)


text:
Which arduino should I start on to learn about it?
I'm pretty interested in arduino and the things I can learn from it. Being that I'm new into this I wanted to know which model I should get that would be easiest to learn on and why. What does this model come with, how much, and reputable place where one can purchase this.

How new are you? Do you know EE? C++?

Welcome to Arduino SE! This question is really broad since we don't know anything about your abilities and skills. For now, I've closed the question. You can edit your question to add more information (i.e. programming skill, needs/wants, budget, potential projects, etc.). Thanks!

I would simply say: buy a startkit like this one.At the end it is not important which Arduino board you'll start. They are (almost) the same*. At the very beginning you can start with Uno or Nano and even Leonardo could be very good. Those boards are very similar and you can program them in the same. Even the pins location and designation is not really different.
The most important thing about Arduino is to understand how to work and program and interface such a board with the sensors. In this sense I would choose a Uno board (or even 2009) which is less expensive and very easy to find overall. I don't really know how much experience you have, but it is likely, at the beginning, that you invert polarities of batteries, you drain too much power, or you invert some pins and damage the microcontroller. In that case doesn't make sense to buy the last powerful mega expensive board on the mark. If you get a Uno you can do almost everything and have for the next month a lot to learn.
To change from Uno or Nano to the other board it is not very difficult. Once you understand the basis you can switch to every board you want. If you need more power and memory you can buy a Mega. If you need much more power you can buy a Due/Tre/etc...you need just an upgrade not everything from scratch to learn.
If you are really new to Arduino the best way is to buy such a learn package as I showed you above. That have everything you need to understand basic of programming till to RC-Servo movement and motor drivers.
Happy new year.
*: stay away for the moment from the Arduino Due/Tre/Zero/Yuan/.. series. they are too expansive and require a lot of attention (3.3V, max drain current from the pins, pull up, pull down...etc..). Here is the risk to get your board damaged within few time very high. And you'll spend a lot of time thinking that the board has some problems.

Not to mention that most of those are ARM-based and so will require relearning the in-depth stuff if you go there.

Agree on the starter kit. Another option if you don't know much/any programming or electronics is start with a makeymakey board.  The main thing is to learn basic electronics and interfacing and to get comfortable breaking down things into small basic steps that are easy to program.

@IgnacioVazquez-Abrams you are right but seen from the side of the program doesn't too much from Due und Uno. There are new functions, of course, but the IDE and all the library stuff is the same. But in EE you are right, it needs a lot more caution and deep understanding how microcontroller works

It's best to buy an official starter kit: you support the community and you receive support if something doesn't work as expected http://store.arduino.cc/product/K000007


text:
Speeding up Girino gives strange readouts
I was reproducing the Girino (the Instructable by Caffeinomane) bundled with the Girinoscope (the Java GUI by Chatanga). The results worked well and I went on to see if the oscilloscope can go up to higher kS/s.
In short, originally only upto prescaler 8 works. I removed PWM pin and it works upto 4 but prescaler 2 strangely behaves. Here are the details:
I did a preliminary test on prescaler 32 (~38.5kHz). Settings as follows and the same in other tests.

The signal (the same hereafter) is generated by a 555 timer astable multivibrator running at 4.5V (3 AA batteries).
The circuitry was simply omitted. I just tied 3.3V of Arduino NANO / ATmega328 to digital pin 6 as the trigger level.
There is no +2.5V offset done by the original Girino. (The scale should be 0~5V and the signal is 0~4V)

So then I wanted to try if it can speed up more. The code optimization quoted by Chatanga allowed prescaler 8 and 16 (76.9kHz and 151.8 kHz).
In order to push it the poor Arduino to the limits, I disabled PWM pin in the original Girino which sets the trigger level with duty cycles (PWM from pin ~3 being fed into pin 6). It's because I simply used a fixed 3.3V trigger level.
Prescaler 4 is unlocked.

Ambitious I go on to test prescaler 2. The GUI did not provide this option so I simply set it in the Arduino code.

I thought it did not work. I noticed if the prescaler is exceeding the Arduino's capability, TXRX simply does not blink. But this time the TXRX is just blinking! To verify this, I shifted the wait duration.

In previous screenshots, the leftmost green line is dashed (probably because it's below fullscale deflection). But in the last two, be it offset or not, the line is solid.
The debug output is like this: (8bits 0~255 given by ADC)

many 0 then suddenly 255 thereafter. (matches the GUI output)

I suspect it's due to slow TXRX? How to solve this? Or anything I overlooked?
Hope that this overdetailed question does not sicken you.

Links: optimization code(https://github.com/Chatanga/Girinoscope/blob/master/doc/girino_optimization.md) and circuitry (http://i923.photobucket.com/albums/ad74/w_khs/g-001.png)

Just a thought. If you only care about low or high signals, why not use a digital read, instead of an analog read.

Yes that suffices for digital signals. But in fact I'm making an oscilloscope.

From the ATmega328P datasheet, section 29.8, "ADC Characteristics":

Clock Frequency — Min.: 50kHz, Max: 1000kHz

With a 16MHz system clock this means that a /16 prescaler is the most the ADC is considered reliable under for a reasonable 10 bit result (for a full 10 bit result the maximum frequency is 200kHz, which corresponds to a prescaler of /80).
As the frequency increases the sample-and-hold circuitry of the ADC gets less time to do the "sample" part before conversion begins. As such any correctness goes out the window, certainly at the lower bits. The fact that you got any sort of result that you did at /4 is luck.
TL;DR: The ADC is too slow.

Thanks for your quick answer! The original code sets a 8bit ADC. Does that explain why I can get a /4 result? Aside from this, how low should the resolution be if I badly need a, say, /2 prescaler?

At /2 you should not expect the ADC to work at all. What you need is a faster ADC.

So I shall buy a faster ADC IC.

Consider that you also need to get the results into the MCU fast enough as well though.


text:
Error Compiling on raspberry Pi - no error details provided in IDE
I've just cracked out my Franzis Arduino Tutorial Kit (Best Xmas Present EVER!) and I'm already stuck on my second program.
I successfully wrote and executed a basic 'blink' program, however when I wrote out the second program provided in the manual I get an 'Error Compiling' when trying to check the syntax or run the program.
I tried the obvious of unplugging the board and plugging it back in but this didn't work. When I search for help most forum posts refer to the error message, however I have no message, just the orange warning bar stating 'Error Compiling'
This is the code;
// Franzis Arduino
// My second Arduino program

int ledPin = 13; //LED is connected with digital pin 13

// The setup routine configures the digital port
// This routine is executed only once at program start!

void setup()
{
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  Serial.printIn("Our second Arduino program");
  Serial.printIn();
}

// The main program is an infinate loop
void loop()
{
  Serial.print("5 + 188 yields");
  Serial.print(5+188);
  while(true)
  {
    digitalWrite(ledPin, HIGH); // Turn on LED
    delay(2000);                 // Wait for a second
    digitalWrite(ledPin, LOW);   // Turn off LED
    delay(2000);                 // Wait for a second
    continue;
  }
}

And here's a screenshot of the error message (or lack of);

Turn on Verbose Compiling: File->Preferences->Show verbose output. Then, add the output to your question.

Both check boxes are already ticked, can you explain 'add the output to your question'?

It's not printIn, but println (as in "print line").

Thank you for the correction, however my original problem still exists

You mean, not getting any error message? Try re-installing the IDE.

Sorry, I did not apply your correction correctly, I used Ln not ln, this is now fixed and running. Thank you so much for your help!

Programming code is indeed case-sensitive. It's a lot more strict than a natural language. One missing ; and all hell breaks lose :-)


text:
How to convert this prototype to finished product?
My prototype contains below components:

Arduino Uno R3
Bluetooth LE nRF8001 Break-out (https://www.adafruit.com/products/1697)
MicroSD Break-out (https://www.adafruit.com/products/254)
ADXL335 triple-axis Accelerometer

I think It's OK on paper (and presumably on a breadboard too). I'm trying to wrap my head around on how to convert it to a finished product that sits inside a plastic box.
What are my options?
For instance, can I create a single PCB that contains all the components? If not, how can I connect these multiple break-out boards together? Is soldering some wires on both boards to connect them is a viable option?
Edit:
My ultimate goal is to create a product that is for sale. So I mean something that can be mass-produced and can meet regulatory requirements.
This is why I was thinking about a single PCB. Arduino (or should I say ATMegaXXX?) is fairly simple to place on a custom PCB. So I was thinking perhaps I could "re-create" my break-outs (see above) on this PCB thus creating a single piece including all components and the microcontroller. For some reason this makes sense to me but I don't know how hard it is or if it is even possible.

Chances are you can drop the ATmega and run it all on an nrf51822, so you only need the rf matching components, crystals, caps and ferrites, accelerometer, sd socket, and supply.

First, you should read this this question here.
The reasonable answer here varies a lot depending on how involved you want to get, and what volumes you want to sell at.
Fortunately, you're not using any breakouts with truly exotic parts. The nRF8001 is just a QFN part, which can be soldered by hand without too much trouble.
Speaking loosely, the process would look like this:

Design a PCB layout that contains everything.
(Optional) - Figure out if you want to put it in a enclosure of some sort.
(Optional) - Determine how you're going to have the enclosures produced or modified from an existing product. You can have a contract machine-shop do the work, but again, $$$$.
Send out to have PCB prototypes manufactured. I like OSHPark, but there are LOTS of options.
Assemble your boards.
Find out your prototype doesn't work.
Go back to step 1 (expect this to happen a few times)
Rent/Beg/Borrow some equipment to do EMC pre-qualification testing (for FCC).
Realize you have an EMC disaster.
Respin boards a few more times (e.g. go back to 1 again) to fix the pre-qualification EMC issues.
Feel like you have a decent layout, have it FCC tested.
Pay $10K+ for FCC testing.
If you're lucky, you passed, you now have a proper, FCC certified product.
Nope, go back to 1 again if you failed.
Do lot assembly, either manually (major time investment), or contract out (expensive!).
Sell your widget!

Note that you can contract out the prototype assembly, but doing so is expensive, even if you do it in china. The magic (or cursed, really) term here is "NRE", or non-reoccurring expenses/engineering. Colloquially, it's the "setup cost" of doing a production run. Sure, you may only pay $5-50 per-widget to have them assembled, but there will be a $1000+ base charge. This reflects the fact that the primary time-cost on the part of an assembly house to build your widget is setting up the production line, working up and debugging a pick-and-place routine, building test-setups, etc... Once everything is up and running, the actual per-unit cost is fairly marginal.
This is also why commercial electronic devices can be so cheap. They're made in truly enormous volumes, and that lets the companies amortize the NREs across the entire production run. NREs are basically the bane of any small electronics business. They're also basically the reason specialty widgets are so expensive. Places like spark-fun can get away with fairly cheap products because they have their own complete assembly line in-house, and even there, you're often paying 4X+ the cost of parts for just the IC on a PCB with a few cents worth of passives.
Since you seem to be new to PCB design, this is possibly not a great first project. It's doable, but expect it to cost 4X+ what you expect, and take 2X+ the time you planned. There are a LOT of facets to designing a proper product, and they each contain an entire field.
It'd probably be better off to start out with some simpler boards, maybe a through-hole-only arduino clone, or similar (though SOIC can be soldered without a hot-air station or anything).

Some assumptions I'm making:

If you're serious, you will have to lean SMT assembly practices. Through-hole only is not a viable stance anymore.
Expect to buy a lot of tools, and burn a lot of money in failed prototypes.
Expect 3 board revisions. At minimum, before you have something you can get tested. I could maybe do it in 2, if I got really, really lucky, but I doubt that would happen, and this sort of thing is my day-job.

Hardware is HARD, and worse, it's completely unforgiving. If you're coming from a software engineering background, you basically have to discard all your assumptions, as they will actively hurt you.
Imagine a software project where "compiling" can take 4 weeks. That's hardware development.

You'are right, I'm totally new to PCB design (I've never done it before) and I'm 99.9% a software engineer. I think your opinion on how hard Hardware is absolutely right. Fail and learn cycle can be extremely long compared to Software and all those "guides" and "tutorials" on the internet will take you nowhere but blinking LEDs all day like a crazy person. Also, since I'm currently located in Bahrain, multiply that 4 weeks with 2 or 3.

@frbry - I'm not trying to discourage you, hardware design can be tremendously rewarding and fascinating. However, it brings a whole suite of challenges with it, and you should make sure you know what you're getting into before spending a lot of money on prototypes, etc...

By "product", do you mean for sale? Giveaways to friends? One for yourself? How many do you expect to make? It isn't (monetarily) worth creating a board for one or five pieces unless you want to for reasons of aesthetics, reliability, demonstrating your skills to a potential employer, etc. OTOH, if you sell a product, it will to meet regulatory requirements in the jurisdiction(s) in which you intend to sell it. So the - admittedly unsatisfying - answer is: it depends. :)  (In other words, we need more information).
Chinese board houses advertise they can do small runs for quite reasonable prices, but expect to spin the board several times unless it's a pretty simple one. Not dissing their abilities or skills as I have no experience with any of them, but as a practical matter of communicating exactly what you want, the first time, to a business half a planet away, a business you might not be familar with yet, and someone with whom you might not share a native language. Even with those obstacles out of the way, boards can take several- to many spins to get to a first production revision.
For a small handful of boards (depending the size of a "handful"), hand-wiring on hobby PCBs or strip-boards can be effective and not too expensive.

Hi, thanks for your response! I've updated the question with some additional information.

Adafruit's breakouts are great at making available to experimenters, devices that would be too difficult for most of us to build with. If you're intending to hand-build your boards, soldering surface-mount devices might be a show stopper; if so, breakout boards would be key. But if the numbers warrant, you'd probably contract out the boards, with the bare devices on them. If you're going for regulatory approvals, that's almost a requirement, just to limit the number of things that could prevent your device from passing.

Could you please elaborate more on how I can contract out the boards and what the bare devices mean? :)

By bare devices, I meant using the ICs directly on your PCB, i.e., without a breakout board. It will be cheaper, smaller, and won't have a bunch of off-board wires to radiate garbage that will prevent your device passing certification. For board fabricators, LadyAda reviews a few of them; a quick search will turn up many, many more.

step1: Make the hardware

Refer the schematics of arduino you are using and make your own pcb
Approach any PCB manufactures and deliver them your GERBER files with correct Bill of Materials.
You can easily make a single PCB. consider PCB with components on both sides, and multi stackable PCB only if the dimension of required PCB matters.
Try not to place nRF antenna and crystal for the micro controller close to each other.

Step2: Firmware
This step is about getting .hex file from arduino code and givin this to the same pcb manufacturer, with proper fuse values

Go to file->preferences in arduino
Check show verbos
open the temp file (type %temp% on RUN)
Compile your arduino code. this will generate a build folder inside temp
folder Search for yourArduinoProjectName.hex inside that folder.

This is the code you need  to get fuse bits
#include <avr/boot.h>;
void setup() { Serial.begin(57600);

cli();
uint8_t lowBits      = boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS);
uint8_t highBits     = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);
uint8_t extendedBits = boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS);
uint8_t lockBits     = boot_lock_fuse_bits_get(GET_LOCK_BITS);
sei();

Serial.print("Low:  0x");
Serial.println(lowBits, HEX);
Serial.print("High: 0x");
Serial.println(highBits, HEX);
Serial.print("Ext:  0x");
Serial.println(extendedBits, HEX);
Serial.print("Lock: 0x");
Serial.println(lockBits, HEX);    }
void loop() { }

Or check the file

C:\Program Files (x86)\Arduino\hardware\arduino\avr\boards.txt

to find the fuses.

Single PCB is not viable, as some chips are near impossible to solder by hand. Also, you'd have to get your PCB checked for FCC compliance (because of the bluetooth), which you don't want.
You could design a PCB that contains the Arduino micro controller (ATMega328), and that all the other board plug into.
Wires could also be a solution, by you probably need to find a way to securely mount all the boards inside the enclosure (no rattling).
PS I'd suggest something like an Arduino Nano as it's smaller, and you can remove the header pins and solder wires directly to PCB.

Hi Gerben, why don't I want my PCB to be checked by FCC? Isn't it the standard procedure? Probably a newbie question, which I definitely am.

It would cost a huge amounts of money. Also, if something isn't okay, you'd have to have it rechecked, costing more money.

I don't see a single chip anywhere on those eval boards that's even that challenging to solder. Furthermore, if you're designing your own PCB, not just using a plain ATmega328P is just violently silly. Why pay all that money for the Arduino people to do a little soldering for you?

A $100 hot air station will save a lot of aggravation when playing with QFN. If that is considered a big ticket investment the project is implausible.


text:
Arduino vs Old Computers
How does an arduino microprocessor compare to some of the older computers in RAM, and computational speed? Like how does it compare to the Intel 400 or the original IBM PC. I'm interested in both the Atmega328 and the 2560. Just how much better/worse is the arduino compared to an old computer?

Compared to an 8088 IBM PC, faster CPU clock, 2-3 orders of magnitude less RAM, and half the ALU width.  Ultimately, you have to make such comparisons in terms of applications (especially, speed to accomplish what?) and they are targeted at quite different roles.

Comparing an MCU with a CPU seems like comparing apples and oranges... Comparing an Arduino to a computer is also plain wrong as it is NOT a computer.

Of course it is a computer!  It is just not one with much of a human interface.

@jfpoilpret According to the Merriam-Webster dictionary, a computer is "an electronic machine that can store and work with large amounts of information." An Arduino would fit this definition. You need to be more specific.

Please be more precise in terms of what features you want to compare. Think of RAM, memory architecture (Harvard vs. v. Neumann), instruction pipelines, caches etc. There literally are as many differences as transistors inside the CPUs, an exhausting answer is impossible and any other try won't meet what you want to read.

Similar capability in turns of processing power if you compare back 10 -20 years.
arduino is a micrcontroller not a microprocessor.
A good example is the pdp11 minicomputer and the ti msp430 micro controllers. They share the same instruction set (approx 90%) . Both can (or could) do realtime event handling but pdp11 was more for data processing. Though pdp11 didn't have integrated peripherals
see bottom of this page http://www.cpushack.com/CPU/cpu4.html

Good answer. However I thought that the Arduino(s) ran on an 8 bit design at the bottom of the article it said 16 bit registers on the MSP which would mean that they wouldn't be in the same class. I paged through the PDP manual once and didn't see anything about realtime event handling. Could you link to the source?

20 years ago - 1995 - was 32 bit pentiums at 100 Mhz with megabytes of RAM.  Try 30-35 years.

Yeah, I would say Arduino is on par with a VIC-20 except without the video output. That's going back 35 years to 1980. The Arduino clock speeds are 8-16X faster though.

@HSchmale arduino is an atmel mega 328 (assuming uno) as you most likely know http://www.atmel.com/devices/atmega328.aspx. For an older discussion on msp430 vs pdp11 see http://www.embeddedrelated.com/groups/msp430/show/20183.php  and a good comparison here http://web.archive.org/web/20070609012513/http://users.easystreet.com/jkirwan/new/msp430.html

pdp manuals here http://research.microsoft.com/en-us/um/people/gbell/Digital/DECMuseum.htm

@HSchmale msp430 isn't that different. larger but less registers (depending on which version and which chip) 16x 16 bit registers. Both are single cycle for most ops and are around the same processing power. The msp430's are a bit more powerful especially when using 16 bit . 16 bit comes in very handy when working with adc's and conversions. In my experience avr's (with gcc and aver studio)are a bit easier to work with. –  lxx 4 hours ago

The Arduino chip (usually Atmega328p-pu) is an AVR (Advanced Virtual RISC*)!!! It doesn't processor but a "full functional nano computer" a Microcontroller! The characteristics of Atmega328P-PU is an 8bit CPU with 2Kb RAM**, 1Kb ROM***  and 32Kb Flash. The CPU's max speed is 20 MIPS @ 20 ΜHz, double of Motorola 68020 (1988) and the half of ARM7 (1994) more fast than Intel i486DX (1991).
***electrically erasable Programmable ROM
**synchronous RAM or SRAM yes! is a type of RAM
*RISC=Reduced instruction set computer
https://www.microchip.com/wwwproducts/en/ATmega328P
https://en.wikipedia.org/wiki/Instructions_per_second

There is no ROM on the ATmega328P. Both the bootloader and the Arduino core are in flash.

The top of the flash is not a ROM, it's flash. The EEPROM is not a ROM, it's EEPROM. There is no “HEF” in this chip. Please, check the datasheet.

I Completely disagree the EEPROM, PROM, EPROM, UVEPROM, FLASH ROM, even the CD ROM or core rope memory is type of an READ ONLY MEMORY this is the meaning of ROM. READ ONLY MEMORY... If we must be so specific then don't say my computer just say my pcbs with couple of resistors ,capacitors,transistors ,inductors ,diodes..........etc...etc....where is programed with 23176173647812 lines o code thing... About the HEF i was confused from your comment and the table here

Despite its name, the EEPROM is not read-only memory. Calling it “EEPROM” is not as silly as you imply in your comment, and calling it “ROM” is very misleading, as in the context of old computers, “ROM” is where the built-in firmware is stored, whereas the ATmega328P cannot execute instructions from the EEPROM. Also, by your criteria, the Flash is also a ROM. In fact, it's closer to being read-only than the EEPROM: it's harder to write to from the running program. Thus you could just say “33 KB ROM”.

Yep... practically 33kb ROM but they doesn't on the same part of the structure...  You prefer to say stack of gates made from field effect transistors to make a memory where is read-only programable and electrically erasable??  Also there is flash memories made from static RAM. I believe this is clear philosophical not electronics. Is just the name of an EEPROM electronic component, ROM is the name of a memory type and also if you Call EEPROM which EEPROM you mean there is a ton of memory structures and all them called EEPROM and they are didn't completely the same.

We call engine of a car, of a plane, boat, rocket... what engine? we call EPROM but what EPROM UV EPROM or X-ray EPROM???  The Windows calling hard drive an HDD and an SSD! All the motherboards are just motherboards isn't the same thing! Well if you want to call them EEPROM good, but you are not perfect and the ROM isn't wrong.

Even the dog we say my DOG not my Scottish Terrier...


text:
TIMER1 CTC Interrupts not working with avr-gcc
I am attempting to program my arduino in plain C, and I've come across some very strange behavior. If I load the following code from the Arduino IDE, it works as expected and toggles Pin 6 every 100ms. However, if I compile it with avr-gcc and then load it with avrdude, no interrupts are run.
Here is the C code:
#include <avr/io.h>
#include <avr/interrupt.h>

int main();
void timer1_init();

int main()
{
    // connect led to pin PD6
    DDRD |= (1 << 6);
    PORTD |= (1 << 6);

    // initialize timer
    timer1_init();

    // loop forever
    while(1)
    {
        // do nothing
        // whenever a match occurs, ISR is fired
        // toggle the led in the ISR itself
        // no need to keep track of any flag bits here
        // done!
    }
}

// initialize timer, interrupt and variable
void timer1_init()
{
    /*cli();*/
    /*TCCR1A = 0;*/
    /*TCCR1B = 0;*/
    /*TCNT1 = 0;*/
    OCR1A = 24999;
    TCCR1B |= _BV(WGM12) | _BV(CS11) | _BV(CS10);
    TIMSK1 |= _BV(OCIE1A);
    sei();
}

ISR (TIMER1_COMPA_vect)
{
    // toggle led here
    PORTD ^= (1 << 6);
}

And here is the Makefile I'm using to load it onto the arduino:
CC = avr-gcc
CFLAGS = -g -O0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106

SOURCE = test

all: load

$(SOURCE): $(SOURCE).o
    $(CC) $(SOURCE).o -o $(SOURCE)

hex: $(SOURCE)
    avr-objcopy -O ihex -R .eeprom $(SOURCE) $(SOURCE).hex

load: hex
    avrdude -F -V -c arduino -p ATMEGA328P -P /dev/tty.usbmodem1411 -b 115200 -U flash:w:$(SOURCE).hex

clean:
    rm -f *.o *.hex
    rm -f `find . -perm 755 | perl -pe 's/\.\n//g' | perl -pe 's/\.\/(\w+)\n/\1 /g'`

Is there something that the arduino ide automatically adds to it that makes it work? What am I missing?
Edit: Here is the make output:
avr-gcc -g -O0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106   -c -o test.o test.c
avr-gcc test.o -o test
avr-objcopy -O ihex -R .eeprom test test.hex
avrdude -F -V -c arduino -p ATMEGA328P -P /dev/tty.usbmodem1411 -b 115200 -U flash:w:test.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
         avrdude: erasing chip
         avrdude: reading input file "test.hex"
         avrdude: input file test.hex auto detected as Intel Hex
         avrdude: writing flash (196 bytes):

         Writing | ################################################## | 100% 0.04s

         avrdude: 196 bytes of flash written

         avrdude: safemode: Fuses OK (E:00, H:00, L:00)

         avrdude done.  Thank you.

Can we see the full make output?

I'd uncomment the lines TCCR1A=0; TCCR1B = 0; TCNT1 = 0;.

I tried uncommenting them, it didn't change anything

It seems the make output does not match the makefile you posted: how the first avr-gcc got called from your makefile is a mystery to me...

It's automatically generated from the target "$(SOURCE).o

I just tried using arduino-mk https://github.com/sudar/Arduino-Makefile, and it worked, so I guess I'm just going to stick with that.

Personally, I would recommend using a timer library to achieve interrupts. They are object oriented and so much cleaner and memory efficient.

So it was your makefile that was incorrect?

Yes, it was the makefile

The issue is probably not the Makefile per se, but that your ISR must match the name of something listed in a vectors table in a source file placed in a section placed in the right place by the linker map.  Using an arduino-ish Makefile included a setup for such matching the ISR name you used.


text:
Controlling multiple LED strips with arduino
I want to control several (undecided) cut strips of these led lights:here.
I want to be able to turn the LEDs on and off from the arduino, but I know that the voltage is too high to work with with the arduino and I don't want to fry my arduino. I've looked into relay modules, but I'm a software guy and I don't understand even the difference between voltage and amperage (I think I have the idea down, but I get the two mixed up sometimes). I also don't know how much voltage or amperage I should be giving each strip or how to control that. I have all my code set up to control my arduino with my simple C# form I've made, but I'm dumbfounded when it comes to hardware, can anyone help?
Also, I'm not well into money so I'd like to avoid spending money on some relays if possible.

http://arduino.stackexchange.com/questions/3535/rgb-led-strips-with-arduino or
https://learn.adafruit.com/rgb-led-strips?view=all . I short; use a 12v power supply and switch the strips on/off using a MOSFET.

The bottom line here is you aren't quite ready to do this project. You need about a couple weeks of education and experimenting - not a big deal, get on that right away. I would suggest doing the example programs, learn to blink an LED, then learn to blink multiple LEDs. The ones that are important to you are "Blink" and "BlinkWithoutDelay" to learn programming standards (those are the Hello World of microcontrollers). Then, this example from AdaFruit where you learn to control a high-voltage device with a transistor - https://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors

And, the reason I say that is: money is important to you and you're going to fry parts if you don't address the issue of "don't know how much voltage or amperage I should be giving each strip or how to control that" - because that's basic to everything you will ever do, and without a clear understanding of it, you will end up spending extra money on this project. With some simple knowledge you'll be able to design and program this correctly. Personally, I think relays is the simplest way to do it - but there's at least three other methods I can think of.


text:
Multiple Definition of "_Vectors"?
I'm working on an arduino project that uses the GSM Shield and the eHealthSensor from Cooking Hacks. However I ran into an issue in which the interrupt vectors from the header/cpp files used are being defined multiple time.
While I know where the definitions are, I am unsure as to how to circumvent this issue either by Arduino programming or modifying the files since I'm not too experienced in this field. Below are the code for the conflicting files.
Below are the vectors that are in conflict.
PinChangeInt.h
    #ifndef NO_PORTA_PINCHANGES
    ISR(PCINT0_vect) {
        #ifdef PINMODE
        PCintPort::s_PORT='A';
        #endif
        PCintPort::curr = portA.portInputReg;
        portA.PCint();
    }
    #define PORTBVECT PCINT1_vect
    #define PORTCVECT PCINT2_vect
    #define PORTDVECT PCINT3_vect
    #else
    #define PORTBVECT PCINT0_vect
    #define PORTCVECT PCINT1_vect
    #define PORTDVECT PCINT2_vect
    #endif

    #ifndef NO_PORTB_PINCHANGES
    ISR(PORTBVECT) {
        #ifdef PINMODE
        PCintPort::s_PORT='B';
        #endif
        PCintPort::curr = portB.portInputReg;
        portB.PCint();
    }
    #endif

    #ifndef NO_PORTC_PINCHANGES
    ISR(PORTCVECT) {
        #ifdef PINMODE
        PCintPort::s_PORT='C';
        #endif
        PCintPort::curr = portC.portInputReg;
        portC.PCint();
    }
    #endif

    #ifndef NO_PORTD_PINCHANGES
    ISR(PORTDVECT){
        #ifdef PINMODE
        PCintPort::s_PORT='D';
        #endif
        PCintPort::curr = portD.portInputReg;
        portD.PCint();
    }
    #endif

    #ifdef __USE_PORT_JK
    #ifndef NO_PORTJ_PINCHANGES
    ISR(PCINT1_vect) {
        #ifdef PINMODE
        PCintPort::s_PORT='J';
        #endif
        PCintPort::curr = portJ.portInputReg;
        portJ.PCint();
    }
    #endif

    #ifndef NO_PORTK_PINCHANGES
    ISR(PCINT2_vect){
        #ifdef PINMODE
        PCintPort::s_PORT='K';
        #endif
        PCintPort::curr = portK.portInputReg;
        portK.PCint();
    }
    #endif

    #endif // __USE_PORT_JK

GSM3SoftSerial.cpp
// This is here to avoid problems with Arduino compiler
void GSM3SoftSerialMgr::manageMsg(byte from, byte to){};

//#define PCINT1_vect _VECTOR(2)
//#undef PCINT1_vect

#if defined(PCINT0_vect)
ISR(PCINT0_vect)
{
  GSM3SoftSerial::handle_interrupt();
}
#endif

#if defined(PCINT1_vect)
ISR(PCINT1_vect)
{
  GSM3SoftSerial::handle_interrupt();
}
#endif

#if defined(PCINT2_vect)
ISR(PCINT2_vect)
{
  GSM3SoftSerial::handle_interrupt();
}
#endif

#if defined(PCINT3_vect)
ISR(PCINT3_vect)
{
  GSM3SoftSerial::handle_interrupt();
}
#endif

Any advice on how to fix this will be greatly appreciated.
If it helps, I am using an Arduino Mega 2560.

You need to rewrite the GSM library to use the pcint library instead of handling the interrupts itself.

It's linking problem. More .o files included in linking declares identical global symbol eg. ISR(PCINT1_vect). Ideally write own makefile and compile via standard make. As hack you can loook in PinChangeInt.h conditional parts and make global definitions not to avoid *ISR()*s, e.g. #define __USE_PORT_JK


text:
Serial Connection to Phone Line
I was hoping to create a cheap security system by connecting an Arduino to the phone line output of a base station.
Since the base station should call a phone number if the alarm is tripped I wouldn't have to do much hardware hacking so long as I can read/parse the output from the base station.
My question is can I read serial output from a phone line like this?

Serial connection over a phone line is done using a "modem" - you can probably still find an RS232 external one on a surplus site for which you will need a serial level shifter (with implicit inversion).  You may also be able to find a new module for embedded use, perhaps even one with logic level serial. Most sophisticated enough to use the AT command set can dial.

These days you can find TTL modems, removing the need to deal with RS-232.

Phone lines run off of the RS-232 telecommunications protocol which can run off -25v to 25v, which would completely destroy your Arduino. Luckily there is an IC made to help you with that. You can use the MAX3232 IC to convert RS-232 to TTL 5v or 3.3v (Same chip can do either). Look at providers like Digikey for just the chip or you can get a breakout from providers like SparkFun.
TL;DR Yes, but you need a special IC to not fry your Arduino.


text:
VCNL4000 Proximity/Light sensor
I want to use the VCNL4000 Proximity/Light sensor s.
http://www.adafruit.com/products/466?&main_page=product_info&products_id=466
In the package i've this 6 pin connector but the VCNL has 5 pins (i now i can connect it by myself with male jumper) but  what am i missing here?
I assume that it is not an "accident" that the thing has one more pin then the sensor ; )

You can just cut off the extra pin. Adafruit probably just had a bunch of 6 pin headers in their stock.

Many thanks, i thought i overseen something important :)