text:
Interfacing unusual 4 digits 7 segments display
There is a common anode and common cathode of 7 segments display. But I got an unusual one.
There are 7 pins controlling 4 digits 7 segments.

I find the pinout by a multimeter. Basically, each pin can be anode or cathode.

My questions:

What is the exact name of this 7 segments display?
How to drive this display by Arduino, any website/sample code?
If I am using the 5V tolerant board, which resistor I need to use? And how is the schematic?

It appears to be some sort of proprietary 7-segment display, possibly from a clock or clock radio.  I doubt you are going to find any Arduino library that supports this directly and you may be better off just getting a standard display that can work with existing libraries.  Otherwise you will certainly learn a lot by figuring out how to make this one work and writing your own library.  As far as resistors, it's difficult to say since we don't know what's inside the thing.  Start with something conservative, say 1K, and work down from there.

Looks like a Charlieplexed matrix. You may try a Web search for “Arduino Charlieplexing”.

This display seems to have 32 addressable LEDs controlled by only
7 pins. Judging from this fact, and from the provided pinout table, it
looks like a Charlieplexed matrix.
A typical way to drive this kind of matrix is by looping over the
cathodes. You pull one cathode pin LOW, and then pull HIGH all the
anodes of the LEDs you want to shine which are connected to this
particular cathode. Wait a few milliseconds, then move to the next
cathode. It is important that all pins that are not involved in lighting
an LED remain in INPUT mode.
For example, let's say you want to light all the segments of the first
digit (display an “8”) while keeping everything else off. You first pull
pin 1 LOW (first cathode) and pull HIGH pins 2–5 (segments F, G, C
and D). Let that shine for a few milliseconds, then put everything to
high impedance (pins to INPUT) and move to the next cathode: pin 2
goes LOW and pin 1 (segment A) goes HIGH. And so on until you have
done all the cathodes.
For the coding part, I would suggest using a 7×7 matrix of booleans
telling whether a particular segment is meant to be lit. The indices of
the array would be row = cathode number and column = anode number. The
array would have the same structure as the pinout table you posted,
except for the fact that the lines and columns would have indices
ranging 0–6 instead of 1–7. This should make it easy to handle
refreshing the display.
Drawing the digits is a bit trickier than with traditional 7-segment
displays, as for each segment you will have to find its coordinates in
the matrix (cathode number and anode number). For this, I would use a
“mapping matrix” that stores the mapping (digit number, segment number)
→ (cathode number, anode number).
Below is a tentative, and untested, implementation of these strategies.
Note that I did not write a function to output a digit, but that should
be easy to implement on top of the set_segment() function defined
here. Besides, the question of how to draw a digit once you know how to
control individual segments is the standard 7-segment problem, for which
you should be able to find many tutorials.
Note that this code assumes you drive the display directly, using no
iterface other than current-limiting resistors. This carries the risk of
either overloading the cathode outputs or having the display be too dim,
depending on the current-limiting resistors. You may want to use
transistors for the cathodes, in which case you would have a set of
cathode pins different from the set of anode pins.
// Arduino pins connected to the display.
const uint8_t display_pins[7] = {2, 3, 4, 5, 6, 7, 8};

// Which segments are lit. Each segment is located in this matrix at
// the coordinates [cathode][anode].
bool segment_lit[7][7];

// Coordinates in the matrix above where a segment can be found.
struct SegmentCoordinates {
    uint8_t cathode;
    uint8_t anode;
};

// segments[digit][segment] gives the coordinates of
// any segment (0 = A) of any digit (0 = 1st digit).
const SegmentCoordinates segments[4][7] = {
// seg: A      B        C       D      E        F       G
    {{1, 0}, {2, 0}, {0, 3}, {0, 4}, {3, 0}, {0, 1}, {0, 2}},
    {{2, 1}, {3, 1}, {1, 4}, {5, 1}, {4, 1}, {1, 2}, {1, 3}},
    {{3, 4}, {4, 2}, {4, 3}, {0, 5}, {2, 5}, {2, 3}, {2, 4}},
    {{5, 6}, {6, 5}, {5, 4}, {3, 5}, {5, 3}, {4, 5}, {6, 4}}
};

// Turn a segment OFF (lit = false) or ON (lit = true).
void set_segment(uint8_t digit, uint8_t segment, bool lit) {
    SegmentCoordinates coordinates = segments[digit][segment];
    segment_lit[coordinates.cathode][coordinates.anode] = lit;
}

void setup(){}

void loop() {
    static uint8_t cathode;  // currently used cathode

    // Set the current cathode to OUTPUT LOW.
    digitalWrite(display_pins[cathode], LOW);
    pinMode(display_pins[cathode], OUTPUT);

    // Set the relevant anodes to OUTPUT HIGH.
    for (int anode = 0; anode < 7; anode++) {
        if (segment_lit[cathode][anode]) {
            digitalWrite(display_pins[anode], HIGH);
            pinMode(display_pins[anode], OUTPUT);
        }
    }

    // Let that shine for a while.
    delay(10);

    // Turn off everything.
    for (int pin = 0; pin < 7; pin++) {
        pinMode(display_pins[pin], INPUT);
    }

    // Move to the next cathode.
    if (++cathode >= 7) cathode = 0;
}

I used delay() here for simplicity. In production code you would
handdle the timings with millis() in a non-blocking fashion, in the
spirit of the “Blink without delay” tutorial.

Thanks, it works. I just modify the delay(10) to delay(1), and add the set_segment() into setup()

I don't know. If I had to talk about it, I would say a LED segment display with a matrix layout with a complementary drive.

If a pin is used as a cathode, a LOW signal must be applied. If it is used as an anode, a HIGH signal must be applied.

You could define constants for each segments anode and cathode that define a pin number. e.g :
#define CAT_1A = 2
#define AN_1A  = 1

and so on. Then if you whant to show segment 1A set CAT_1A to LOW and AN_1A to HIGH.
Of course the whole process is more complicated. You have to define which segments must be light up to show a specific digit. You must show all four digits one by one in a fast loop and so on. But that's the same as you would do for an ordinary LED segment bar. The difference is that you have to configure pin pairs and not single pins.

Use your Multimeter to measure the Forward voltage of the segments. If they are red, it should be around 1.8 to 2.4 Volts. Substract this Voltage from 5 Volts. Then devide by 0.02 (20 mA) and you get the Resistor in Ohms. A standard LED is bright enough with about 20 mA.

Example:
(5V - 1.8V) / 0.02A) = 160 Ohm

Use a resistor of say 100 Ohms at each pin. It is common available and as the current flows always through 2 pins, you have 200 Ohms together.
It is also possible that the LED bar has internal resistors. Try to meassure the resistance beetween to pins.
Edit
When I said, "each digit must be shown in a fast loop", I forgot to clearify that, for each digit, the segments must be switched sequentially.
You can do it even more complicated and show all Segments with a common cathode or a common annode at once.   Then you need fewer cycles, but as you use resistors for all pins (see point 3.) this could dim the LEDs remarkably. Also, becaus technically, the forward voltage of different LED may differ, so the some could be brighter the others.
There is also another thing, I did not think of, when I wrote the answer. If you power a segment, say from pin A (+5V) to pin B (GND), you have a resistor (100 Ohms), an LED (minus 1.8 Volts) and a second resitor (100 Ohms) in series. So in an ideal situation the voltage on pin B (also on the second resitor) would by around 1.6 Volts. Pin B is the cathode of the LED segment, but can also be the anode of another segment (S2).  If the cathode of S2 is connected to GND there is a very small chance, that the segment lights up. If you don't see (ghost) lights, all is fine. But if some segments light up (but much darker than the right ones) you have to find a better solution.

Re “You must schow all four digits one by one in a fast loop”: That won't work. At any given time, you can only light segments that all share either the same anode or the same cathode. So, instead of looping over the digits, you will have to loop over the anodes (or over the cathodes).

@EdgarBonet Showing Digit one by one is meant in addition to show each segment one by one. It seams that I did not express myself clearly. I'll edit the answer.

Re “show all Segments with a common cathode [...] could dim the LEDs remarkably”: no more than showing the segments one by one. If you want a brighter display, you have to drive the cathodes with transistors. Re “If the cathode of S2 is connected to GND there is a very small chance, that the segment lights up”: that's why that cathode should not be pulled LOW (connected to GND): it should be left floating (INPUT mode, a.k.a. “high impedance”).

@EdgarBonnet As multiple LEDs with a common cathode or a common anode have a single source or drain with a resistor. The current through all LEDs together is the same as the current through that single resistor. So each LED sees only a part of the current. Say you have 5 LEDs with a common cathode then the current through the common resistor is 5V / (100Ohm+20Ohm) ~~ 41mA. The current through each LED is 1/5 of this ~ 8,3 mA. I think you would see the difference. Using high impedance state for unused pins is one of the better solutions I mentioned.

You are right, of course, the display will be dim. But that's not my point. My point is that it will also be dim if you handle the segments one by one. Think duty cycle, and average the brightness over a full scan cycle.

@EdgarBonnet That's a good point. I did not expect the LED to dim much because of the duty cycle, but now I'm not sure anymore. I'll have to get such a LED Display and try it. Thank you for the comment.

You answered my last question, and give me an idea for the resistor, but I have no idea how to implement your code.


text:
ATmega8L power issue
I am doing a prototype using ATmega8L-8PU to detect temperature and control a relay and buzzer, but the schematic seems not work, therefore I do a simple test to verify the AVR's pins are working perfectly or not.
I using the example sketch - Blink to control Digital-13 to let LED blink. It is work.
Then I do a second sketch to test all pins (Due to leak of LED, I test first 8 pins.) It failed. Second Sketch is quite simple and strict forward: blink D0-D7 LED one by one.
char i, j, pcnt = 1;

char startDigitalPin = 0;
char maxDigitalPin = 7;

void setup()
{
    digitalWrite(13, HIGH);
    delay(100);
    digitalWrite(13, LOW);
    delay(100);

    digitalWrite(13, HIGH);
    delay(100);
    digitalWrite(13, LOW);
    delay(100);

    digitalWrite(13, HIGH);
    delay(100);
    digitalWrite(13, LOW);
    delay(100);

    // put your setup code here, to run once:
    for(i=startDigitalPin; i<=maxDigitalPin; i++) {
        pinMode(i, OUTPUT);
        digitalWrite(i, LOW);
    }
}

void loop()
{
    // put your main code here, to run repeatedly:
    digitalWrite(13, HIGH);
    delay(1000);
    digitalWrite(13, LOW);
    delay(1000);

    digitalWrite(13, HIGH);
    delay(1000);
    digitalWrite(13, LOW);
    delay(1000);

    digitalWrite(13, HIGH);
    delay(1000);
    digitalWrite(13, LOW);
    delay(1000);

    for(i=startDigitalPin; i<=maxDigitalPin; i++) {
        for(j=i; j<=maxDigitalPin; j++) {
            digitalWrite(j, HIGH);
            delay(100 * pcnt);
            digitalWrite(j, LOW);
            delay(100 * pcnt);
        }

        digitalWrite(i, HIGH);
        delay(200 * pcnt);
    }

    pcnt++;

    if(pcnt > 10) {
        pcnt = 1;
        delay(8000);
    }
}

Question:

Why I using Blink example sketch, D13 is work fine, the LED light on with normal bright.
Why second sketch, the D13 LED super dark, but it light on.

Check it out these 2 videos in youtube.
https://www.youtube.com/watch?v=sknNPxqg5zc
https://www.youtube.com/watch?v=KWsdP3egsvY
I have burn a bootloader to ATmega8L-8PU (Summary Datasheet) using Arduino IDE 1.6.5 with MiniCore, Config: ATmega8 External 8MHz.
Parts in my bearboard using:

ATmega8L-8PU
2 x 22pf
1 x 100nf
1 x 8MHx crystal
9 x LED with 330Ohm resistor

You forgot the pinMode for pin 13, perhaps the led is blinking very dark with the internal pullup resistor of 50k. The MiniCore is not the official Arduino core. I think the OptiBoot comes with a small bootloader for the ATmega8, and perhaps you need an extra board in "boards.txt", but you can use the normal Arduino software. The resulting code is already small (don't use floating point). I see no need for a special MiniCore.

source: Stack Exchange

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

sort: votes


text:
Arduino Yun and REST call security
I'm not expert about web development but very excited of doing some rest call using the yun as server (with a minimal python or node.js server inside the openwrt machine in the yun) and expose sensors and actuators to the cloud.
I'm also worried about security. I don't want the super-shellproof system but just don't want that accidental visitors reads my home temperature or make my garden light switch on when I'm out.
For instance I have a central unit yun with some logic inside it and few arduino yun that makes reads from sensors and runs actuators around my home. The communication between the central yun and the slaves is happening via REST calls. I'm using curl for testing it, for instance. Here two questions:

Arduino Yun provide a simple user/password account when arduinoname.local/arduino is called. How is it implemented?
Let's say I'm using node.js to make a super simple web-server, what is the best way to protect the communication central-yun and slave-yun? and to protect central-gun and internet communication?

Best way in term of computation (the yun machine is not very powerful and I'm going to use battery in some cases) and in term of "easy to implement".

Just sayin'... I think hackers have much bigger targets than reading the temperature of your garden :) By the way, you never mention if you use session hijacking prevention, HTTPS, or a simple password for the web interface you make. Those three you'll need to implement in the HTML, which is off topic here. Also, unless you have port forwarding, no one is going should able to access your Yun unless they have a physical connection or connected to the same WiFi.

Password protection of the REST API is done with Basic Authentication. This, coupled with HTTPS, makes API calls more secure. Since the SSL certificate is self-generated, you'll need to run curl with -k parameter.
As Annonomus Penguin suggested, before going into securing the Yuns, you should secure the network they are using (e.g.: home WiFi should use a strong password).

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


text:
Using IMU for a small Arduino and bluetooth support
I'm gonna start a project with an IMU with a bluetooth support inside a small board (mini or lillypad) and send datas to the mobile phone. But I'm quite new to those kind of technologies.
I'm going to choose a module for handling both operate voltage restriction and memory capacity for both library (IMU and bluetooth).
Any advice obj which arduino / IMU breakout / bluetooth module / battery to use? Or some similar projects?

A tiny quadcopter board will have the intertial sensors and you can add a bluetooth module.  Or you can use an arduino-with-bluetooth type board and add an intertial module.  Beware that cheap micromachined IMUs (or for that matter just about any you can buy) aren't very good - they are fine for detecting or damping acceleration and rotation, but not for integrating to determine position or even velocity.

can you advice one or two good breakout board?

If you're new to Arduino I'd suggest avoiding the Mini and the BULLSH-fun that external programmers bring.
Something like the Pro Micro is much easier, almost as small, and less likely to bite.
Often the best way to pick hardware is to look for a tutorial (like This one) before deciding what to buy. While I personally haven't used IMUs it looks like the "6 Degrees of Freedom IMU Digital Combo Board - ITG3200/ADXL345" from SparkFun would be (relatively) easy to use.
I've used the RN-41/2 Bluetooth modems (the same as are found in BlueSMiRF modules) and usually gotten on OK with them. There are plenty of tutorials available with a bit of Googleing.
Adafruit do a good line of Lipo batteries and chargers. They also have wireless charging modules if you're looking for extra brag-factor.
Hope this helps.


text:
Use Adafruit 16-Channel 12-bit PWM/Servo Shield to switch relays
I'm wondering if using the Adafruit 16-Channel 12-bit PWM/Servo Shield is it possible to switch relays, such as use that shield as a multiplexer and use digital output without PWM.
Is it possible? example code?

That's silly. Find something with GPIOs.

sorry can you expand a little bit your comment?

Thank you for your interest and the time that to allow to answer to our questions. I have the same problem and i want a sample code to control relay by 16 channel pwm i2c.
can you help me please?
How can i use this code in the answer in the top : pwm.setPWMFreq(1000);//put this in setup()
...
// enable relay at channel 15
pwm.setPWM(15, 1, 0);
...
// disable relay at channel 15
pwm.setPWM(15, 1, 1); thanks

That will work. Just make sure you are not using Servo part of the library, but only the PWM part, and set the duty cycle to 100%. The relay should still work, even if the duty cycle is slightly lower, as the magnetic field takes a bit of time to collapse. Just make sure you don't forget to add a (flyback) diode to the relay.
Looking at the datasheet I think you need to use the following code
pwm.setPWMFreq(1000);//put this in setup()
...
// enable relay at channel 15
pwm.setPWM(15, 1, 0);
...
// disable relay at channel 15
pwm.setPWM(15, 1, 1);

Sorry I haven't specified before, I need both: PWM and digital output. In this way you are "removing" the pwm, right?

No. The only thing I changed is the PWM frequency (to the highest possible value).

@nkint Why would you want to control a relay with PWM? At best, PWM would be fast enough to not affect your relay. At worst it might make it buzz. Or are you saying you need some lines to control relays and others to drive PWM outputs?

Using the adafruit PWM servo shield seems like overkill, you are paying for a lot facilities (PWM) that you won't be using. If you want to use the shield to reduce the number of pins used on your arduino board,  consider a pair of shift out registers (74HC595 for example). The relays need a logic 1 or a logic 0 to change state. You send a bit pattern to the shiftout register that sets the output pins of the shift register to 1 or 0. I found this page helpful.

Sorry I had no specified before, I need both: PWM and digital output. Hanks anyway.

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


text:
What's the smallest (cheap) USB Host solution for Arduino?
I'm building a project that will connect to users' phones (Android at first, but iPhone too, if there's enough interest) via USB. Of course, this means that I need a USB host in the project. The total size of the device has to be about the size of the phone, so answers that seriously suggest shields aren't going to be helpful - they'd put me over my size budget by at least a factor of 3.
I'd also rather not require an adapter to go from the USB Mini B connector type to the Micro B connector type.
Gravitech has a USB Host board for the Nano 3 that has a USB Type A connector, and the combination of a Nano and Gravitech Host is about the right size (maybe a little thick, once the whole thing is soldered to my own board), but the USB host is $25. I can get the Nano for about $4 each and would like to keep the USB host in the neighborhood of $8 each. Are the solder fumes getting to me, or is there such a specimen out there and I'm just not finding it?

Why not go with bluetooth?

I'm uncertain of what you mean by "USB host". Do you wish to be able to plug the Arduino into the phone's USB port and interact with it via USB or GSm or WiFi or ... ...?

Your requirement would probably be better met by something that isn't an Arduino at all, and has native USB host.

Atmel has AVRs with USB OTG support perhaps one of those would work.

In the non-Arduino realm, I've had success with both STM32F401/411 Nucleos and the Kinetis KL25Z freedom board.  Those are all in the $10-12 range and slightly larger than an Arduino, but I've also made the corresponding chips work on smaller custom boards.  A KL25Z64 is just over $3 in a QFN32 package, though it needs another crystal and requires skill to solder (if space is not an extreme concern, the QFP48 will be easier to work with).

The Arduino Due and Arduino Mega ADK can both serve as a USB Host. You can also use the chip that the Mega uses yourself

No, the Arduino Mega is not a USB host (perhaps you confused the Mega for the ADK?).  You can of course add an embedded USB host chip to a Mega, but it is probably not cost effective to do so compared to devices which have that natively.  The Due, while still overpriced, is comparatively a good deal since it costs less than a board + host shield and is in the class of things which are far more capable as computational platforms (but still twice what you need to spend on hardware to do this).

Thanks for clarifying. I guess I misinterpreted when I read about the Mega.

I think you were probably looking at the Mega ADK - not particularly small or cheap -http://arduino.cc/en/Main/ArduinoBoardMegaADK

Some people did it with ESP32:
https://github.com/touchgadget/esp32-usb-host-demos
https://github.com/tobozo/ESP32-USB-Soft-Host   (cheapest)
Or with this USB-Host chip:
https://forum.arduino.cc/t/is-the-max3421e-still-a-viable-part-for-new-usb-designs/668612/2

Cypress makes very small usb chips capable of host mode. Does this board meet your size requirements? http://www.mouser.com/ProductDetail/Cypress-Semiconductor/CY8CKIT-049-41XX/?qs=FSHIiqjonm0YmFbmBQfo1A%3D%3D&kpid=1159933375&gclid=CPjl6KOm4cQCFYGUfgodJh4A_g
You may also consider ditching the arduino and running everything on the cypress

Are you sure that the board you link can do this?  Cypress' own documentation lists the  CY8C4125AXI-483 and  CY8C4245AXI-483 offered on those kits as being without a USB interface while I'm not seeing any indication that the interface IC can function as anything other than a device.  Cheap alternative to an Arduino or USB-serial, yes,.  But apparently not a host solution.


text:
Make an Arduino board act as both a usb storage device and a keyboard?
I am making an interface project that, when plugged into a computer, shows up as both usb flash storage and can type like a keyboard when some physical buttons on the board are pressed.
I have seen projects that do one or the other, but not both at the same time.
I have gotten it to work using a usb hub and two chips that are sharing the same storage (since I want the hot-key buttons to type out information stored in the flash drive side as well), with one acting like a HID and one acting as usb storage, but this has a few problems. First, it feels redundant. Second it's difficult to program since every time I plug the mess in it randomly assigns a name to each chip with no easy way of telling which to send the HID code to and with to send the USB Drive code to. I have to plug them in one at a time which wont work once this project is all on the same board. The last problem is the buttons work inconsistently since, im assuming, the two chips are not doing a nice job of sharing access to the text file it's trying to read for the text to 'type out' on the computer.
Is there a nicer way of doing this that uses one arduino acting in both roles accessing the one flash storage? Thanks!

http://www.atmel.com/Images/doc7631.pdf http://www.atmel.com/Images/doc8446.pdf

The Leonardo can easily be used as a keyboard. There are also special codes to turn the USB-to-Serial chip on newe Unos into a keyboard (see here)
USB mass storage is another game all together. The Brondani EasyUSB is a simple chip that exposes 2MB of storage space on both the USB and microcontroller. They say they will be releasing larger capacities.
The easyUSB also has a serial link built into it from uC to computer.
If you really want, you can make your own USB stack to handle this on you own, but the pitifully small amount of ram on these chips would prohibit it.

You're looking to create a USB composite device.  I don't see any examples within the arduino community, but I don't see a reason why you couldn't use the 16u2 as a composite device, it'll just require more effort than you'd normally put into an arduino project.

You can try using an Arduino Mega ADK. This is because it has a separate USB port for USB devices along with many serial ports for other serial device.


text:
Are hardware interrupts used while controlling an LCD screen using the LiquidCrystal library?
I'm working on a tone generator project that uses Mozzi to make sound (sine waves mainly). As I understand, Mozzi can glitch if used along with hardware interrupts.
The plan is to use the classic 2x16 LCD screen, but I don't know the guts of the library or interface. Are hardware interrupts used while interfacing with an LCD screen, or by the LiquidCrystal library?

The LiquidCrystal code shows that delays are used. That can cause audio glitches in the sound.
The LiquidCrystal library does not use interrupts.
You could try to change the LiquidCrystal code according to the instruction on the Mozzi page.

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


text:
How to improve wiring a breadboard?
just saw this tweet and was interested what wires are used there:
https://twitter.com/EngineersGarage/status/448014811280842752/photo/1

The wiring Looks cleaner than the setup I currently have with "normal" wires.
Thanks!

What exactly is the question?

I think the wire itself is perfectly normal. It looks like he's simply soldered right-angled header pins onto the ends. That way, the wires can lie flat on the breadboard instead of being bent over for connections, meaning the whole thing is lower-profile and a little easier to route neatly.
It also has the advantage that they will probably survive far more insertions/removals. With that said, it brings the disadvantage that it exposes the contacts more above the surface of the board, which could increase the risk of accidental connections (short circuits and such like).

thanks - indeed that was the explanation I was looking for. the wires I use quickly get harder to use, and These right-angle Header pins look helpful. any other advice on maybe special out of the shelve wires that help wiring a Project?

Various places sell packs of pre-cut and pre-bent wire specifically for breadboard prototyping. I find it's not really worth the price though. Fairly standard solid core wire is usually sufficient. Just make sure to use suitable lengths, and try to route things in straight lines (rather than sprawling all over the place!).

Using good wires helps to build clean breadboard setups. I also found that it greatly helps to wire vertically only and to use the breadboard for horizontal connections. If you look at my picture, wires are always vertical. This is easy to achieve when you work with buses like I²C. As you can see, I also used horizontal lines from another breadboard as you can use these like Lego bricks, though you need to cut the adhesive tape in the back. For the wires, I used standard Solderless Breadboard Jumper Cable Wire that you can buy almost everywhere online.
You can also check other pictures on my blog: http://ouilogique.com/horloge_cycles_ultradiens/


text:
Using Arduino Micro with MPU6050
I have an Arduino Micro and an MPU6050 gyro/accelerometer board; I want to read DMP data from the MPU6050, but the sketch requires the use of the interrupt pin, of which I have none of the interrupt pins available and they cannot be switched around.
I'm wondering how to go about reading the DMP data when needed. I've tried but always just receive the value 180 for any reading.
Thank you!

Do you have any current code that you are using? If so, edit the question to include this. Thanks!

I searched quite some time for everything regarding the MPU6050, but there is just rumors and jokes about the dmp funcionality. One project encorporates the hard reverse-engeneering some wise people did, which is: http://www.i2cdevlib.com/docs/html/class_m_p_u6050.html
This also uses the interrupt, which I suppose you can't really avoid. Why exaclty this would be necessary though, is not a thing I could tell you.. I assume, that the dmp works somehow with the fifo buffer and can only interact through it. The cited library has examples with and without dmp, which I can really recommend.
Using this thing for a quadcopter however I can just say, that the dmp is too slow to control such a fast system, so maybe first consider what you really need. From my experience it does some magic things, but acts strange is due to it's not documentary it is a pain to work with.
Hope this helps.

You can, in fact, avoid the use of an interrupt with the MPU6050/DMP combination.  See the ongoing thread at https://github.com/jrowberg/i2cdevlib/issues/479 and this post for example.  I've been running an MPU-6050 based system using polled (vs interrupt) driven configuration for months without any issues (other than a pesky motor noise issue I'm currently trying to resolve).
Regards,
Frank


text:
Include statement not working
I am creating my own library for the Arduino and I have the following code:
#include <Arduino.h>
#include <Servo.h>

class ServoMotorController {
    public:
        ServoMotorController(int servoPin, int motorPin, int angle);
        void setAngle(int angle);
        void setSpeed(int speed);
    private:
        Servo servo;

        int servoPin;
        int servoAngle;
        int motorPin;
        int motorSpeed;
};

I am getting the error that Servo does not name a type; however if I do
#include <Servo.h>
#include <ServoMotorController.h>

in my actual Arduino code then I do not get the error. Why is the include statement not working in my C++ lib?

It seems this question is similar to http://arduino.stackexchange.com/questions/322/why-do-i-need-to-include-libraries-used-in-other-libraries I suggest you take a look at it, it may provide you with the answer you're looking for.

This is a symptom of the arduino IDE. libraries can't add other libraries to the include path, but the can use other libs if they have already been included. you can use an error directive so your compiler output is more informative at least
#ifndef Servo_h
    #error "ServoMotorController Lib requires Servo.h to be included first to function"
#else

Arduino 1.5.6 beta's new library format has a section for dependencies in the new library.properties file that should allow one library to add another to the include path, but I'm not entirely sure if the functionality is fully implemented yet (its beta after all).


text:
Servo Keeps Trying to Turn
I currently have a servo wired to my Arduino and have imported the Servo.h.  Here is my sketch:
#include <Servo.h>

Servo s1;
Servo s2;

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

  s1.attach(8);
  s2.attach(9);
}
int pos = 0;
void loop()
{
  pos = 0;
  if(s1.read() != pos)
    s1.write(pos);
  if(s2.read() != pos)
    s2.write(pos);

  delay(1000);
}

The problem is that even when my servos are at the position 0 it still tries to turn and I hear it trying.  What do I have to do to tell it to stop turning once it is already at the desired position?
So this is my second bit of code:
s1.write(0);
  delay(5000);
  s1.write(100);
  delay(5000);
  s1.write(180);
  delay(5000);

When I write them to 100/180 (or any number) they are silent after the turn, but when I write them to 0 I hear them keep trying to turn...

Can you command your servo to different positions and have it go there?  Some cheap servos simply do not "settle" well. You can try making a little program to exercise them by cycling them between extremes at a moderate rate, you can even try taking them apart to clean.  But the ultimate solution - assuming your PWM signal itself is reasonable and stable - may be to buy better quality servos.

0 may not be within their mechanical range.  How about you start at 100, and decrement that by 10 every couple of seconds, doing a serial print of the set value - and then see what they can get to without growling.  Or better yet make a sketch where you can type a value on the serial and it will command that to the servo, letting you manually experiment.  You can also print out a protractor scale and put a pointer on them and see where they stop moving.

This probably should not have been migrated - as far as we know, the issue isn't with the arduino, but with the servo.

Is this a continuous rotation? Can you link a model number? Does it get stuck and stop moving?

The reason they keep trying to turn is mechanical. The physical stop in the gears is hit before the encoder/potentiometer reaches its end point.
You can make the servo stop fidgeting by completely relaxing it if you want. just use
s1.detach();
s2.detach();

and your arduino will stop sending any signal.
Bear in mind that "reading" the value of a servo in arduino gives you the servo's current set point, not its current location. Your code in unfortunately unaware of a servo's actual location. With that in mind, setting your servo to go to 0, waiting for it to get there with a delay, and then detaching it will have the desired effect, but since it will not maintain position and you will need to reattach it to function again, using 1 or 2 as your far left endpoint is likely the better option.

A common reason is could be because your servo cannot operate at a PWM signal of 0ms.
For conservative limits, you should stay between 100ms and 2800ms even for very high quality servos.
With lower quality servos that do not specify maximum and minimum values, conservative limits are 700ms to 2400ms.


text:
Are the Arduino Micro, Mini, etc plug'n play?
Also, what about the micro/nano/mini arduinos? Are they easily plug'n'play like the uno?
(This is an edit from another of my questions)

The ones that have a USB connector are plug-and-play with a USB host. The ones that don't need a USB-to-UART bridge.

What's a UART? I'm totally new to this. Also, do the arduinos I mentioned have breadboard-style connectors like the uno?

A UART is what implements the "serial" connection. They come with bare plated holes, so some basic soldering experience is required.


text:
Powering motors
I'm trying to control two DC 3-6V motors with a HG7881 driver and an Arduino Nano, but the Nano is always resetting if it has the same power supply than the driver. I'm connecting the batteries to HG7881 Vcc and Nano Vin (and also same ground).
If I power the Nano with USB and the driver with batteries then it works but that's not a good solution for me.
So the question is, is there any way to make both driver and Nano work with the same power supply?
Thanks!

Do you know how much current the motors and driver are drawing?

@peter Unfortunately I don't know, but enough to reset the Nano board

Is it foreseeable for you to use 2 distinct sets of batteries, one for the nano, one for the motors? They would only share GND. This way the voltage drop on motor batteries would not impact the nano supply voltage.

Otherwise a cap between Vin and GND as near the nano as possible could help regulate the voltage when the motors draw too much current. Finding the right cap value is a matter of experiment...

You can also try adding a capacitor between VCC and GND on the nano.

You need to know the peak current demands of your motor circuit before you can solve this problem. If you have a digital multimeter you can measure the constant current, and make a guess at the peak current. Put your multimeter in series with the motor driver and operate it at full power. The peak current may be as high as twice the steady current of the running motor. Also check the current with the motor under heavy load.
Then you need a power supply that can put out that much current, plus the current of your Arduino, without the voltage dropping below the minimum requirement for the Arduino voltage regulator (~7 volts).
What kind of batteries are you using? If you put 6 C cells in series you'll get 9 volts and pretty high peak current.

OK, it was just the power suppy. I was using 4AA, but wasn't enough. With 6AA it now works! Thanks!

If the reset is due to transients when the motor starts or stops, you can get by with isolating Nano power via a diode and capacitor.  (See below.)  If, on the other hand, the motor is dragging the supply voltage so low the Nano won't run, you may need to add a separate battery for the Nano or upgrade your batteries, as mentioned in Duncan's answer.
To isolate Nano power from motor power, open the connection between battery V+ and Nano Vcc; connect the anode of a diode to V+; connect the cathode to the positive lead of a capacitor of a few hundred microfarads and to Nano Vcc.  Connect the capacitor's negative lead to ground.  If simple diode+capacitor filtering isn't enough, you probably should attach an oscilloscope and find out more exactly what's happening.  Further options include series resistors, wound inductors, and ferrite beads, as seen in some Google images for power supply filtering.

Hi, good description of diode & capacitor isolation, however, a picture or diagram would help any reader dramatically. I recommend you add one.


text:
Can I corrupt my Arduino if it's unplugged during an upload?
When messing around with code and uploading a sketch to my Arduino board, I almost accidentally pulled out the USB cord. Everything is fine, but then I started thinking what would've happened if I had pulled it out.
How safe is avrdude? Could it damage or brick the board? I'd imagine that you would just have to upload code to it again... but what would happen before you upload the new code? I've seen something about how you can always upload new code if the bootloader is intact, but I would imagine that there would be some problems. If this were to happen, should I unplug everything connected in case Arduino writes a HIGH to an input (or similar) that would damage the component?

So I accidentally did this to my Arduino Nano 33 BLE and now my computer cant see it.. I tried restarting my computer, hitting the reset button on the board, unplugging and plugging it back in and still nothing. Is there a way to revive it?

@Coy, use double reset to activate the bootloader

AVRDUDE does not actually perform the write, it merely directs it. The actual writes are performed either by the bootloader or by the ISP firmware/hardware within the MCU itself.
With the bootloader it depends on how itself is coded, but at worst it would finish off the flash byte or page or EEPROM page zero- or one-filled and then fail to communicate further with AVRDUDE, aborting programming.
With ISP, the page write command would never be received and the programming would be aborted at the last full page. Fuse bytes are done singly and so programming a single fuse can be viewed as an atomic operation.
In either case, a chip erase operation should reset the MCU to a known working state, fuse changes excepted.

With the bootloader it depends on how itself is coded, but at worst it would finish off the flash byte or page or EEPROM page zero- or one-filled and then fail to communicate further with AVRDUDE, aborting programming. Wait... how could it abort it if there is no power?

@AnnonomusPerson: External power, USB/serial programming.

What if I'm only using USB power? That doesn't answer my question about your answer.

If all you have is USB power then everything just stops. The bootloader is unable to finish the current byte. But that won't damage any flash cells.

One safety feature that hasn't been mentioned so far is that the ATmega328 has a set of lock bits that prevent read/write access to certain areas. To the best of my knowledge, the way Arduinos are set up, those bits are always set to prevent writing to the boot loader area unless the "Burn Bootloader" command is currently active, and since you can only use that command with an external programmer, you can always write a new bootloader if something goes wrong.
I think the only way of bricking the board (in the sense of leaving the MCU in a state that is functional, yet almost irrepairably unresponsive) is writing bad fuse settings.

It should be fine.
Most boards don't require you to reupload the bootloader every time you upload a sketch, so your program will be corrupted but your bootloader won't. I assume the bootloader is similar to the bootloader on other chips I have seen*, it will stop execution if the code doesn't work properly. I would also think that the micro would not accept a transmission if it's checksum is missing.
I wouldn't try it if I were you, but you can be a little less cautious about this sort of thing.
*: the Propellor chip, among others

Very few embedded MCUs have any sort of error catching facilities. If by the code doesn't work properly you mean the code in the program memory is invalid/corrupted, you are incorrect. The MCU will just happily continue executing the invalid code, leading to undetermined behaviour. If you mean the bootloader will ignore invalid commands, that is entirely dependent on the bootloader.

Yep, nothing to catch or check for errors in user code in Optiboot. This is what the watchdog timer is for.


text:
Seeedstudio Wifi shield v1.1 Not working with Arduino Mega 2560
I have been trying use the Seeedstudio wifi shield v1.1 with Arduino Mega 2560 as part of my project but I could not make the WiFly library provided on the wiki work with the Mega. I tried to run the example sketch wifly_test but it did not work I tried some troubleshooting and found that the write commands to the shield were not successful. After a few hours of searching on the internet, I found out the problem and was able to solve it. I am posting my solution below. Anyone is welcome to add to my solution.

I figured the problem as a result of my search and not the solution. Please refer to my solution below

The WiFly library provided at the Seeedstudio wiki uses the software serial to communicate with the WiFi shield. All the example files provided by the WiFly library use pins 2 and 3 as the Rx and Tx of the software serial. Moreover, the Wifi shield only allows pins 0-7 to be chosen as Rx and Tx by using different jumper combinations.
The SoftwareSerial library, on the other hand, has the following limitation for the Arduino Mega

Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).

Thus, as a workaround, I jumped pin 2 of the shiled with pin 10 (Rx of Software Serial) and pin 3 with pin 11 (Tx of Software Serial) using connecting wires and used the jumper setting given on the wiki. Finally I made the following changes in the example code
// Pins' connection
// Arduino       WiFly
//  10    <---->    TX (via connecting pin 2 to 10 on wifi shield)
//  11    <---->    RX (via connecting pin 3 to 11 on wifi shield)

SoftwareSerial uart(10, 11); //change software serial pins for Mega

This allowed the Mega to communicate with the Wifi shield successfully using the WiFly library.


text:
cc3000 WiFi distrupting DS18b20 temp measurements
I am trying to post temperature measurements from DS18b20 thermal sensors to an online repository using a cc3000 WiFi shield on an Arduino Mega.  It works great, once.  All the temperatures get read fine. Then I post the data. Then the temperatures all return -127 error values.
If I fix the temperatures to const values, I can send any amount of data over wifi. If I don't send the data over wifi, I can pull temperatures indefinitely.
I can't imagine anyone is set up to test this or has a good way to debug it, so I am open to wild speculation- Any guesses what is going wrong? Any suggestions on how to debug it?
Here is my code:
#include <OneWire.h>
#include <DallasTemperature.h>

#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>

#define temppin 53

#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
#define ADAFRUIT_CC3000_VBAT  5  // any pin
#define ADAFRUIT_CC3000_CS    10  // any pin
// On an UNO, SCK = 13, MISO = 12, and MOSI = 11
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
                                     SPI_CLOCK_DIVIDER); // you can change this clock speed but DI

#define WLAN_SSID       "MyNetwork"        // cannot be longer than 32 characters!
#define WLAN_PASS       "mypassword"
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2
uint32_t dweetioIp = 0;
char c;
unsigned long lastpost = 15000L;

OneWire oneWire(temppin);
DallasTemperature sensors(&oneWire);  // Pass our oneWire reference to Dallas Temperature.

DeviceAddress TS1 = {0x28, 0xFF, 0xB4, 0x5E, 0x68, 0x14, 0x03, 0x60};  // serial numbers
DeviceAddress TS2 = {0x28, 0xFF, 0xFE, 0x4F, 0x68, 0x14, 0x02, 0xDD};  // for DS18b20's
DeviceAddress TS3 = {0x28, 0xFF, 0x3D, 0x5C, 0x68, 0x14, 0x03, 0x5F};
DeviceAddress TS4 = {0x28, 0xFF, 0x16, 0x5C, 0x68, 0x14, 0x03, 0xD7};
DeviceAddress TS5 = {0x28, 0xFF, 0xA3, 0x62, 0x51, 0x14, 0x04, 0xC4};
DeviceAddress TS6 = {0x28, 0xFF, 0xA9, 0x61, 0x68, 0x14, 0x03, 0x22};
DeviceAddress TS7 = {0x28, 0xFF, 0x2A, 0x72, 0x68, 0x14, 0x03, 0x17};
DeviceAddress TS8 = {0x28, 0xFF, 0xD2, 0x61, 0x68, 0x14, 0x03, 0x3F};
DeviceAddress TS9 = {0x28, 0xFF, 0xFA, 0x43, 0x68, 0x14, 0x02, 0xD0};
DeviceAddress TS10 = {0x28, 0xFF, 0x0B, 0x63, 0x68, 0x14, 0x02, 0xCB};
DeviceAddress TS11 = {0x28, 0xFF, 0x97, 0x41, 0x68, 0x14, 0x02, 0x2A};
DeviceAddress TS12 = {0x28, 0xFF, 0x47, 0x7E, 0x68, 0x14, 0x03, 0xF8};

DeviceAddress TS16 = {0x28, 0xC8, 0x47, 0x15, 0x06, 0x00, 0x00, 0xF0};

float t1;
float t2;
float t3;
float t4;
float t5;
float t6;
float t7;
float t8;
float t9;
float t10;
float t11;
float t12;
float t13;

String command = "";
boolean stringComplete = false;

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

  pinMode(temppin, INPUT);

  // Initialize wifi shield
  if (!cc3000.begin()) {
    Serial.println(F("\n\nFailed to initialize WiFi shield."));
  }
  Serial.println(F("\n\nInitialized WiFi shield"));

  // Connect to wifi network
  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed to connect to WiFi network"));
  }
  Serial.print(F("Connected to "));
  Serial.println(F(WLAN_SSID));

  // Wait for DHCP to complete (get an IP address)
  while (!cc3000.checkDHCP()) {
    delay(1000);
    Serial.println(F("Waiting to get IP address"));
  }
  Serial.println(F("Got an IP address\n"));

  // Connect to dweet.io
  while (dweetioIp == 0) {
    if (! cc3000.getHostByName("dweet.io", &dweetioIp)) {
      Serial.println(F("Failed to resolve dweetio website"));
    }
    delay(500);
    Serial.println(F("Resolving dweetio website"));
  }
  Serial.print("Accessed dweetio website at IP address: ");
  cc3000.printIPdotsRev(dweetioIp);
  Serial.println();
}

void loop() {
  // Get temperatures
  sensors.requestTemperatures();
  delay(1000);
  t1 = sensors.getTempC(TS1);
  t2 = sensors.getTempC(TS2);
  t3 = sensors.getTempC(TS3);
  t4 = sensors.getTempC(TS4);
  t5 = sensors.getTempC(TS5);
  t6 = sensors.getTempC(TS6);
  t7 = sensors.getTempC(TS7);
  t8 = sensors.getTempC(TS8);
  t9 = sensors.getTempC(TS9);
  t10 = sensors.getTempC(TS10);
  t11 = sensors.getTempC(TS11);
  t12 = sensors.getTempC(TS12);
  t13 = sensors.getTempC(TS16);

  Serial.println(t1);
  Serial.println(t2);
  Serial.println(t3);
  Serial.println(t4);
  Serial.println(t5);
  Serial.println(t6);
  Serial.println(t7);
  Serial.println(t8);
  Serial.println(t9);
  Serial.println(t10);
  Serial.println(t11);
  Serial.println(t12);
  Serial.println(t13);

  long curmillis = millis();
  if (curmillis - lastpost > 1000*15L) {
    // Post data to dweetio
    char data[125];
    sprintf(data, "?t1=%i&t2=%i&t3=%i&t4=%i&t5=%i&t6=%i&t7=%i&t8=%i&t9=%i&t10=%i&t11=%i&t12=%i&t13=%i",
            (int)(t1*10.),(int)(t2*10.),(int)(t3*10.),(int)(t4*10.),(int)(t5*10.),
            (int)(t6*10.),(int)(t7*10.),(int)(t8*10.),(int)(t9*10.),(int)(t10*10.),
            (int)(t11*10.),(int)(t12*10.),(int)(t13*10.));
    Adafruit_CC3000_Client client = cc3000.connectTCP(dweetioIp, 80);
    if (client.connected()) {
      client.fastrprint(F("GET "));
      client.fastrprint(F("/dweet/for/testdweets"));
      client.fastrprint(data);
      client.fastrprint(F(" HTTP/1.1\r\n"));
      client.fastrprint(F("Host: https://www.dweet.io\r\n"));
      client.fastrprint(F("\r\n\r\n"));
      // client.println();
      Serial.println(F("Sent dweet\n"));
    } else {
      Serial.println(F("Sending dweet failed"));
      return;
    }

    /* Read data until either the connection is closed, or the idle timeout is reached. */
    unsigned long lastRead = millis();
    while (client.connected() && (millis() - lastRead < 1000)) {
      while (client.available()) {
        char c = client.read();
        Serial.print(c);
        lastRead = millis();
      }
    }

    client.close();
    Serial.println("Connection to dweet.io closed");

    lastpost = millis();
  }
}


text:
Console monitor on different wifi network
I have a Yun doing data logging. It runs nicely and when I am on the same wifi network I can use the Console Monitor to watch what it is doing in more detail. However, my arduino is deployed far from me so it generally isn't possible to get on the same wifi network to monitor the console.
Is there a way to monitor the console from a different wifi network?

The Yun is just an ordinary network device.  However, the tools you are provided with use a system called mDNS to find the Yun.  That only works across the same local subnet that you are on.
If the Yun is on a different subnet then you will have to (assuming the routing between subnets is working fine) do it manually by knowing the IP address of your Yun.  Use that IP address in place of "arduino.local" or whatever your Yun is called.

Please note that you will have to port forward on your router/firewall, although that is beyond the scope of this site.

So if I would be starting with googling "IP address lookup" and "router port forwarding", the answer is probably that it would take more than a few hours to set up?

If you have to google those terms, then yes, probably.  If you know what they are and how to configure your router(s) then it won't take long.  If the two network segments are isolated by NAT then you will need some form of tunnelling mechanism to get from one segment to the other, such as port forwarding (and connect to the router not the Yun) or a VPN.


text:
Connecting GSM Dongle to Intel Galileo-Gen 2
I have tried to connect a GSM dongle to a Intel Galileo Gen2 board and test the functionality of sending and receiving SMS through it.I know that it is easier to use a GSM shield to do above, but I'm currently doing a project in the way i mentioned above.Basically in Linux, we should know the serial port(like ttyACM0 in /dev directory) correspond to the device to communicate with it(Using AT commands).
but when i tried it in Galileo board it doesn't show such a serial port.but it detect device because lsusb command shows the device.
does anyone can help me to solve this matter?

It may detect it as a USB device, but does it know what it is? Check dmesg when you plug it in, and also run usb-devices to see if it has a driver attached.

Many of these have to be kicked out of their initial mode of emulating a CD rom with windows drivers into a different mode which exposes USB-serial like devices.  There's a program called usbmodeswitch which sends the necessary SCSI commands.  This is probably off topic for the arduino site.

Try updating the firmware. I'm not sure if this affects also ACM type serial ports, but the initial version of the firmware was not even creating standard /dev/ttySx, rather some weird proprietary interface.
Luckily this was fixed later on. So, in case you are still running the FW that the board came with, chances are you are having these weird serial ports.

In case my previous observation doesn't help, check the udev rules. It might simply miss the one for creating the appropriate type of character device.


text:
Pixy Pet Robot stuck on uploading code
when I upload the code to my leonardo board it just stuck on uploading, like this:
could someone help me with this?

Is it a real Leonardo or a clone? If a clone, adding a reference would be welcome. Also, is it really connected to COM4?

I am sure it is connected to COM4. Actually, I use SparkFun RedBoard instead of Leonardo, but I also try to use Arduino Uno, it has the same problem.

First off, the sparkfun redboard  must be defined as a UNO in Arduino IDE, not Leonardo. Second; it uses FTDI drivers: did you install these?


text:
How can I get the source files for Arduino libraries?
I've been looking for a while inside Arduino's files to find the core library. However, I haven't found them yet. Where on my hard drive can I obtain the core library files (.cpp and .h) necessary for all Arduino code?
Looking around on Google, I couldn't find a way to find the above files. I did see something about getting an .a file while Arduino is compiling, however, that isn't what I want. I want to browse the code and look at functions such as delay to see how they would react when given the values not expected. (i.e. Will my code stall if I use delay(-200); by not being to exit the loop, or will it create a black hole and disrupt the space-time continuum?)

I was interested in the question, but what I want is the source code for strcpy and strcat in assembler source code. I downloaded the Master Library but I cannot locate anything remotely similar to strcpy or strcat.
OR
Maybe I cannot see the wood for the trees?

@bobzic I suggest that you ask another question specifying which files you want to find.

The base Arduino source files are in the Arduino installation, under cores/arduino/. Source for additional libraries included are in libraries/.

And don't forget /usr/lib/avr/include/ or whatever that translates to on non-Linux systems.

Too bad I installed it as Windows 10 app and cannot access the installation folder.

This information seems outdated. The libraries folder is empty now and hardware has moved

The code is also available online for those times you don't have the IDE installed:
https://github.com/arduino/Arduino

Can't find the header files there.

see my answer below: https://arduino.stackexchange.com/a/68658/59512

On a Mac, the path to the source code folder is:
Arduino.app/Contents/Resources/Java/Hardware/Arduino/Cores/Arduino. I'd expect it would be the same from /Java/ on down in other OSes.

The arduino source files can be found on Github at https://github.com/arduino/Arduino, however the libraries have been moved to their own repositories:

https://github.com/arduino/ArduinoCore-avr
https://github.com/arduino/ArduinoCore-sam
https://github.com/arduino/ArduinoCore-samd

There are multiple places where you can look. As at IDE 1.6.4 (Ubuntu version) some are in:
(install location)/libraries

But these are the high-level libraries, in particular:
Bridge
Esplora
Ethernet
Firmata
GSM
LiquidCrystal
Robot_Control
RobotIRremote
Robot_Motor
SD
Servo
SpacebrewYun
Stepper
Temboo
TFT
WiFi

That does not cover the low-level libraries like Tone, Print, main, etc. These are in:
(install location)/hardware/arduino/avr/cores/arduino

There you would find the Arduino core libraries like:
abi.cpp
Arduino.h
binary.h
CDC.cpp
Client.h
HardwareSerial0.cpp
HardwareSerial1.cpp
HardwareSerial2.cpp
HardwareSerial3.cpp
HardwareSerial.cpp
HardwareSerial.h
HardwareSerial_private.h
HID.cpp
hooks.c
IPAddress.cpp
IPAddress.h
main.cpp
new.cpp
new.h
Printable.h
Print.cpp
Print.h
Server.h
Stream.cpp
Stream.h
Tone.cpp
Udp.h
USBAPI.h
USBCore.cpp
USBCore.h
USBDesc.h
WCharacter.h
WInterrupts.c
wiring_analog.c
wiring.c
wiring_digital.c
wiring_private.h
wiring_pulse.c
wiring_shift.c
WMath.cpp
WString.cpp
WString.h

However even that does not locate things like strcpy. The header files for them can be found at:
(install location)/hardware/tools/avr/avr/include/

There you will find:
alloca.h
assert.h
ctype.h
errno.h
inttypes.h
math.h
setjmp.h
stdfix-avrlibc.h
stdint.h
stdio.h
stdlib.h
string.h

Even that is not the full story. In a subdirectory (avr) you will find the avr-related things, with files for different processors, such as (in part):
boot.h
builtins.h
common.h
cpufunc.h
crc16.h
delay.h
eeprom.h
fuse.h
interrupt.h
io1200.h
io2313.h
...
iox64d4.h
iox8e5.h
lock.h
parity.h
pgmspace.h
portpins.h
power.h
sfr_defs.h
signal.h
signature.h
sleep.h
version.h
wdt.h
xmega.h

As for the source of strcpy, I don't think it is in the distribution. They include the standard libraries, pre-compiled. For example, if you look in:
(install location)/hardware/tools/avr/avr/lib

You will see various pre-compiled libraries, for example:
libc.a
libm.a
libprintf_flt.a
libprintf_min.a
libscanf_flt.a
libscanf_min.a

To find the source you would need to find where the AVR source of libc is (possibly at http://www.nongnu.org/avr-libc/).

As for the Mac, all this stuff is a few levels down in the "Application Package" which you can view by right-clicking and selecting "Show Package Contents". Look in the Contents/Resources/Java folder.

None of these places are where you should put your own libraries (ones you write or download). They should go into the libraries folder which is a subdirectory of your sketchbook folder. Create the libraries folder if it does not exist. That way user-installed libraries persist from one version of the IDE to the next.

I think this may have changed in newer versions. On my Mac Big Sur, Arduino 1.8.15 they are here: /Applications/Arduino.app/Contents/Java/libraries


text:
Arduino starter kit servo is shaking
In the example of the arduino starter kit the point is to use a potenciometer to control a servo.
The code is
angle = map(potVal, 0, 1023, 0, 179);

The output in the serial
potVal: 1023, angle: 179
potVal: 1015, angle: 177
potVal: 1023, angle: 179
potVal: 1016, angle: 177
potVal: 1023, angle: 179
potVal: 1023, angle: 179

I noticed that the servo is shaking like trying to go passing over the 179, when it is suppose to use an angle max 180º (0-179)
What could be the problem?

Does the serial output above occur without changing the pot position?

Yes, when I reach the "top" 1023 it shakes and oscilates between close values. Could it be a mechanical problem?

No, I just included the Servo library. It is a basic example, where a pot controls the servo.

It seems the problem comes from the pot not the servo. Since 2 consecutive reads don't provide the same value, the servo will change its position of a few degrees and looks like it is vibrating.

I like this method the best (personal preference) for smoothing signals:
//In setup
int bufferedVal = analogRead(A0);
int unbufferedVal = analogRead(A0);
#define _TOLERANCE_ 5

//The loop
unbufferedVal = analogRead(A0);
if(abs(unbufferedVal - bufferedVal) >= _TOLERANCE_ ) {
  bufferedVal = unbufferedVal;
}

This finds the error using the abs() function (absolute value; makes sure it is positive).
Another thing you can do is round it to the tenth placeholder (i.e. 88 -> 90, 83 -> 80) so it always is a good number to work with:
int val = analogRead(A0);
val += 5;
val = val / 10;
val = val * 10;

The last two lines work because of the lack of precision that integers offer with decimals. If I divide 88 by 10, it doesn't output 8.8; it outputs 8 instead. We then multiply by ten again so it isn't 8 when it really should be 80. The only problem with this is it only rounds down. We can fix this by adding 5 (the halfway point between 10 and 0). That way, it goes: 88 to 93 to 9.3 to 9 to 90.
NOTE: I'm not sure if the compiler will notice the redundancy of the last two lines. If it acts weird, try using the volatile keyword.

I had to set the tolerance to 10, but it worked.

Rounding the one's digit is likely to sometimes make the problem quite a bit worse - if the average value is near the rounding threshold, then small noise variations can get substantially amplified +1/-1 can become +5/-5.

If the problem is due to jittery pot readings, you may want to smooth the potval data sequence by code like the following, where rawreading stands for what you just read from the potentiometer's input line.
potval = alpha*potval + (1-alpha)*rawreading;

Set alpha to a number (eg 0.8 or 0.9 or 0.95 etc) between 0 and 1.  alpha represents the fraction of the old value that you retain, and  1-alpha represents the fractional influence of the new raw reading.   alpha closer to 1 causes smoother but slower response.
If you prefer integer arithmetic for faster or smaller code, then represent alpha as a ratio of integers.  For example:
potval = (potval*12 + rawreading)/13;

The technique mentioned above is called exponential smoothing or  exponential moving average.

Since the previous answers were all code-related, let me suggest you use a smoothing capacitor. In noisy environments, or where you want to get more consistent readings, place a capacitor across your signal lines (signal to ground). The result is less "spikes" in your readings, and can sometimes cause a slight delay in signal changes, as charge has to build up in the capacitor before the voltage goes up.
http://www.learningaboutelectronics.com/Articles/What-is-a-smoothing-capacitor

The circuit already uses 2 100microF capacitors. I forgot to specify.


text:
Burning sketch with I2C
Not a pure Arduino question really. I'm actually using a standalone ATmega168. So far I've been using AVR-ISP programmer (working from AVR Studio) to program the chip. After everything is done, the chip will be covered and I will only have access to the I2C pins. The MISO,MOSI, etc pins will be unreachable.
I was just wondering if there was a way to use the I2C pins to update the program that is burned on the chip. I won't need to burn the bootloader again, but just to update the program if it needs to be.

You need to write a I2C bootloader to the AVR. There seems to be a project that has already created such a bootloader.
Atmel has provided a TWI/I2C bootloader for their XMega processors (not the ATmega168).
Next problem is uploading the code via I2C. You'd need some hardware to convert USB  to I2C. And some software to talk to this hardware. The last part is probably supported by AVR studio, as Atmel has provided an I2C bootloader. Though I'm not sure both of the above bootloaders are using a compatible protocol over the I2C.

Take a look at miniboot. I implemented it as a self-contained bootloader. Instructions about uploading from USB to I2C are also provided. Live long and prosper.


text:
Should I try to make my sketches as small as possible, even when I have enough room?
There has been a lot of talk about shrinking sketches recently, but if you don't need the room, should it be done? Will it speed up my program?
Take this code:
int led = 13;
int val;

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

void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second

  val = digitalRead(10);
}

1,396 bytes on Arduino Uno. Now let's shrink it a bit:
int led = 13;
int val;

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

void loop() {
  blink();
  val = digitalRead(10);
}

void blink() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

1,270 bytes. A 10% decrease! It could be shrunk even more. I have the space... is it more efficient (as far as speed) to make it the most compact I can or leave it "uncompressed?" I would imagine that it would be a little more work (not much) calling blink();, therefore slowing down my code. Is this true? Are there other advantages/disadvantages of making it as small as possible (besides storage/distribution of C++ files)?

I believe that one should be fastidious about their code, but never resort to micro-optimization where unwarranted.

For me, what comes first regarding code is its readability. If it's longer it can be more difficult or it may take longer to understand properly. If a gvensize optimization makes the code clearer, then you should use it.

Generally speaking, smaller is better. However, there is a point where too small actually makes the program run slower.
My suggestion is if you are working on a sketch and it is blatantly obvious that you are repeating code over and over again, I would rip that out and put it into a function, not only does it make the program smaller, it makes it easier to read.
There is also some optimization going on behind the scenes as well during compilation, so even though the C/C++ code looks to be large, chances are the compiler/linker are determining that something are repeats and consolidating them... Or at least the AVR compiler I used previously did, cannot remember if Arduino does this.

I believe it does have some optimizations... Arduino IDE compiles with avr-gcc.

Putting repeated code into a function also makes only one piece of code providing an opportunity to make mistakes, and only one one place to have to fix it/them. Also only one place to update later when you need to change something.

You second code may be smaller in size but due to the function call overhead the max execution speed is reduced.
Does this matter in your case? No, because you have huge delays anyway, but if the code was an actual series of repeated calculations that should be executed as fast as possible then it would make a difference.
As a general rule, smaller code is not necessarily faster too.
For code optimization (either size or speed) you can refer to this application note from Atmel AVR4027: Tips and Tricks to Optimize Your C Code for 8-bit AVR Microcontrollers
I could repeat everything it says here but I don't think there is a point, you can read the original article directly.

Regarding the compiler optimization level. Arduino IDE uses the avr-gcc compiler with a setting for Os optimization.
The avr-gcc available optimization levels are (source1 source2)

O0 or no -O option
At this optimization level GCC does not perform any optimization and compiles the source code in the most straightforward way possible. Each command in the source code is converted directly to the corresponding instructions in the executable file, without rearrangement. This is the best option to use when debugging a program and is the default if no optimization level option is specified.
O1 or -O
This level turns on the most common forms of optimization that do not require any speed-space tradeoffs. With this option the resulting executables should be smaller and faster than with -O0. The more expensive optimizations, such as instruction scheduling, are not used at this level. Compiling with the option -O1 can often take less time than compiling with -O0, due to the reduced amounts of data that need to be processed after simple optimizations.
O2
This option turns on further optimizations, in addition to those used by -O1. These additional optimizations include instruction scheduling. Only optimizations that do not require any speed-space tradeoffs are used, so the executable should not increase in size. The compiler will take longer to compile programs and require more memory than with -O1. This option is generally the best choice for deployment of a program, because it provides maximum optimization without increasing the executable size. It is the default optimization level for releases of GNU packages.
O3
This option turns on more expensive optimizations, such as function inlining, in addition to all the optimizations of the lower levels -O2 and -O1. The -O3 optimization level may increase the speed of the resulting executable, but can also increase its size. Under some circumstances where these optimizations are not favorable, this option might actually make a program slower.
Os
This option selects optimizations which reduce the size of an executable. The aim of this option is to produce the smallest possible executable, for systems constrained by memory or disk space. In some cases a smaller executable will also run faster, due to better cache usage.

+1 It's better to tell the compiler to make your code bigger/faster or smaller/slower rather than doing such asinine things like needlessly unrolling loops.

Your refactor should be done simply because it's better code, not because it's smaller. The advantage is that it's easier to modify.
If making the code size smaller results in a loss of clarity (not so in your case), then you should probably view it as a premature optimization.

When considering optimization, think carefully about what resource is most valuable.
You can optimize for code size; this will let you put more code onto your processor. What will the rest of the space be used for? If your code doesn't fit onto your arduino, and your alternative is buying a larger chip, then this is worth the effort.
You can optimize for speed - you can run more code in the same amount of time. If you are sampling data once per second, and sleeping the rest of the time, then this won't help.
You can optimize for power usage - very important if you're on a battery, less important if you are on mains. This might also not just be power consumed by the arduino, but also sensors & motors - can they be turned off for a while?
There are two optimizations that a lot of programmers forget - optimizing for development time, and optimizing for readability.
Any optimization for one thing will tend to de-optimize for at least one (often several) other things. If you don't know which optimization is going to be most useful, then go for readability, then development time (because today's readability = tomorrow's development time x 10!)
Usually, the most expensive thing is the development time (i.e. YOUR time, especially if you are on the clock for a customer). Most other optimization has a threshold - so long as you are over (under?) a specific threshold, further optimization doesn't help. Code size and execution speed (except when shared between competing tasks) are like this - if your code fits on the chip, then it is small enough. If it needs to do something else later, you can optimize it then. If your program can do all it needs to (assuming it is real-time; calculating Pi is a different case), then that's as fast as it needs to be.

When your time has more worth more than the gains to be had, stop optimizing.
Are you writing for someone for pay? Then this should be their call. But in this case, readability and clarity of your code is paramount; someday, someone else will have to modify your code in your absence. If you deliver working, high performance code that someone else can't read and get a handle on, you will not have fulfilled your obligation (unless this was specifically agreed to).


text:
How to avoid odd naming rules for Arduino when writing a library?
I'm building a small library that will be used and production and released open source. I'm paying a lot of attention to the "best practices" to make sure this code is reliable and easy to use. I also would also like to make this easy to edit. I'm having an issue with the naming scheme of the whole project.
There are a few Arduino naming quirks. If I have a sketch called mylib:

...I can't create a tab called mylib.cpp. However, I can create a file called mylib.h...
...The folder and main sketch file must be the same name as the folder it is in
...The sketch name (and folder) cannot contain any spaces.

Well, why are you creating a sketch for a library? The Arduino IDE won't open a .cpp file unless there's a sketch in that folder (and you have to open the .ino/.pde file in that folder). I'm trying to get this to work with the Arduino IDE so, if users need to edit the library, then can just open the file and go to the correct tab. If they use an external editor, they won't be able to compile it to see if there are any errors.
I'd ideally just do this structure:
my_lib
   |- my_lib.ino
   |- mylib.cpp
   |- mylib.h

However, a user might see that the folder is called my_lib and try including the file my_lib.h.
I think this is a major oversight in the Arduino IDE, but I need to have this work with the Arduino IDE. If it was just me working on this code, I might consider making the library directly in a project directory, but that isn't ideal. Is there anything that I can do to bypass this/make it easy for users to edit? Is there any "standard"/"convention" that defines how to do this?

I'm currently trying to spin the thoughts going through my head into something not quite so negative (about the Arduino IDE), but... nothing doing.

@Ignacio after a few things like this, I couldn't agree more. I'm really confused why it does this...

Why not just have them edit the library in an external editor? If they want to compile, they just open the example you include with the library inside Arduino IDE and press verify. Alt-tab back and forth, I use that a lot.

@user2973 but how would you open the .cpp file in the first place to see if it compiles? You can't, and the command line isn't ideal (even if it supports compilation from non .ino files)

@Annonomus Penguin The Arduino IDE will automatically compile all .cpp files in a library folder when you include a header from that same library - regardless of the file name.

The IDE copies your files to a temporary location to compile them. In the process your main sketch gets some preprocessing (ie. adding function prototypes) and copied as a .cpp. Thus your mylib.ino cannot also have a mylib.cpp file in the project, because they would both end up being mylib.cpp once copied to this temporary location. BTW - to avoid this preprocessing stuff just leave the main sketch empty, and just put all your code into .cpp files. There are a few caveats: How to avoid the quirks of the IDE sketch file pre-preprocessing

Yep, the Arduino IDE kinda sucks eventually. There is no best practise really, as Arduino *.ino files aren't proper c / c++ anyway. I would hope that people who know how to write C++ classes (as opposed to Arduino) would be able to do it outside the IDE.
My suggestion would be to make the *.ino file a test file. That is, it runs a set of functions to check that the library behaves as desired. It could also include example code, so people who use the library know how to include it in their programs.
All that being said, time to fly Penguin...  Ditch the Arduino IDE and go with embedXcode or some other third party IDE template :P

(I just wanted to put a pic of a penguin)

+1 for that penguin :) Anyway, I still need the compile with the Arduino IDE, so I don't know if a third party IDE would really work...

I forgot to add i'm in the same situation - writing code that others might have to maintain using the Arduino IDE. I never  thought to including an ino file in there, so thanks for the question.

...well thanks for the penguin! :) Anyway, there doesn't seem to be an ideal situation. I think I'm going to use the naming rule [in my answer] for my main GitHub code and then just rename and move the .ino` file to an "examples" folder when making a release... that way users can get the best of both worlds.

@AnonymousPenguin I know I'm late to the party (as usual) but there's a setting on the Arduino IDE called 'use external editor' that blocks you from editing in the IDE and lets you use an external program (e.g. notepad++) to edit your code, and then you just use the IDE for compiling and uploading. Also creating the .cpp in the directory it's supposed to be in works too if you reboot the IDE afterwards. (These are the sorts of terrible problems you get when you target a tool for programming circuits at non-programmers.)

For anyone curious what I did, I ended up doing a naming convention like this:
my_lib_v1_2
   |- my_lib_v1_2.ino
   |- mylib.cpp
   |- mylib.h

Then, the user could include mylib.h still, and people with the Arduino IDE could edit it.

The Arduino IDE's restriction of not allowing you to create a .cpp tab with the same name as the sketch has been removed since the 1.6.12 release.
In fact, older IDE versions would happily open and save sketches that contained, e.g., mylib.ino and mylib.cpp. You just needed to create the .cpp file outside of the Arduino IDE.
The reason for this restriction in previous IDE versions was that the file in the temporary build folder generated from the preprocessed sketch was named {build.project_name}.cpp, which would be overwritten by the other .cpp "tab" file of the same name. Of course that is not an issue for your desired usage of the Arduino IDE simply to edit library source files. Later, the Arduino developers changed to the much more sensible system of naming the preprocessed file {build.project_name}.ino.cpp. Thus the restriction was no longer necessary.


text:
What is the type parameter on the NRF24NetworkHeader member
Link of the member
What is the character parameter in the above member of the class NRF24Network
I cannot understand the use of it.

It's to identify the type of packet.  Apparently that code supports types of 0-127, and I guess (impossible to tell without digging into the code) that what you use them for is entirely up to you.  Basically it would typically define what is in the rest of the packet - again something which is up to you.

Yes but i have to put a char but it takes types 0-127. What does that mean

Hint: 'a' is 97. '8' is 56.  ASCII.

Oh now I understand. And for example if I want to parse rgb code I will send 3 packets with -for example- type r,g,b ?

Or one packet with 'c' for colour and three values in your packet...

Nice and one last question how can someone parse 3 values in one packet? Can that be achieved by sending 3 variable values or somehow else.

Use a struct and send them as one single compound variable.


text:
Multiple nodes with the same receiving and transmitting address
I want to make a network with arduinos and nrf24l01 chips. The network will be like this:

1 master arduino
multiple (no specific number) slave nodes

I want all nodes to have the same receiving and the same transmitting address and the master arduino to understand which one send the message from the message itself.
For example:
Master:
Receiving: 0xABCDABCD71
Transmitting: 0xABCDABCD01
Slave 1
Receiving: 0xABCDABCD01
Transmitting: 0xABCDABCD71
Slave 2
Receiving: 0xABCDABCD01
Transmitting: 0xABCDABCD71
Slave 3
Receiving: 0xABCDABCD01
Transmitting: 0xABCDABCD71
Slave 4
Receiving: 0xABCDABCD01
Transmitting: 0xABCDABCD71
When master send a message, all nodes will receive it.
What I want to ask is :

Is that possible?
Will there be any problems?
Is there any other way so I can add more nodes in the future without changing the code?

That will work. The only possible problem would be collisions, if the nodes send a lot of data (having different re-transmit intervals might help here).

Generally, having same RX address on all slave nodes is a bad idea except when the slaves are receive only.  If you want to receive data from a specific node, then they should have different addresses, use ACK_PAYLOAD and you poll each one in turn.

Can we do it for only multiple slaves to single data receiver?
I want to get 13 IMUs( gy9250) data on single nrf24lo1 receiver is it possible?

as well as comment #1 the other thing will be the ack packets that the slaves will send back to the master to confirm message recieved. with all slaves sending back a ack at about the same time there will be no way for master to tell which ack is from which client, and thus who needs a retransmit. a way around this is to turn off ack for the clients and make the master transmit max times regardless. there is a rf24 fork that has broadcast mode, the makes it more easy to specify not to wait for ack before retransmitting

Using this as a base library and this as an simplifying overlay (there's actually RF24Mesh too) will make this possible very easily.


text:
8X8 LED not lightning up according to matrix assignment on a Arduino Nano
I'm currently trying to code a simple program that would allow me to light up an individual LED on an 8X8 LED board using a double array.
Here are the problems:
All the rows can ON individually UNTIL I turn all 8 rows ON. When I do this the last column turns OFF by itself (see attached pictures).
The columns aren't even working properly either. Every time I assign a column ON, the last column faintly turns ON too (one of the LEDs light in that column is broken so that is expect to be OFF. See picture).
I think those are the reasons why I am not able to singly assign a particular LED to be ON according to assignments in the array. If someone could spot my mistakes, it would greatly be appreciated. Thanks!
int led2 = 2;
int led3 = 3;
int led4 = 4;
int led5 = 5;
int led6 = 6;
int led7 = 7;
int led8 = 8;
int led9 = 9;
int led10 = 10;
int led11 = 11;
int led12 = 12;
int led13 = 13;
int led16 = 16;
int led17 = 17;
int led18 = 18;
int led19 = 19;

int rowPins [8] ={led19, led18, led11, led7, led12, led5, led4, led16};//assigning each LED to a row.
int columnPins [8] ={led13, led17, led9, led10, led2, led8, led3, led6};//assigning each LED to a column

int image [8][8]=
{

{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},

};

void setup()
{
  for (int i = 0; i<8; i++)
  {
      pinMode(rowPins[i], OUTPUT);
      pinMode(columnPins[i], OUTPUT);
  }
}//end of setup()

void loop ()
{
for (int y=0; y<8; y++)
{
 for (int x=0; x<8; x++)
 {
   if (image[x][y]==1)
   {
     digitalWrite (columnPins[x], HIGH);
   }
   else
   {
     digitalWrite(columnPins[x], LOW);
   }
 }//end of 2nd for loop

  digitalWrite(rowPins[y], LOW);
  delayMicroseconds(100);
  digitalWrite(rowPins[y], HIGH);
}//end of first for loop
}//end of loop

I don't see any program statements in the code as shown to cause the described behavior, and imagine it is some hardware problem.  (I'm assuming you put some non-zero values into the image[][] array; it looks to me like nothing should light up when image[][] is all-zeroes.)
Hardware problems break into several categories:  A wiring problem (which we can't see without much better pictures); incorrect software setup of HW; temporary misbehavior of the processor; or permanent damage.  For the sake of discussion, suppose temporary misbehavior applies.
Temporary misbehavior can be caused by overheating.  Overheating can be caused by drawing or sinking a lot of current for too long a time.  (If a large current is a fast transient event, it may have little effect.)
Note that most Arduino I/O lines are rated to sink or source at most 40 mA current each.  Ground and Vcc lines have higher limits, like 200 or 100 mA.  For more details see the spec sheet for your processor; also see ArduinoPinCurrentLimitations at arduino.cc, and Real maximum current for ATmega328? on Electronics SE.
If an LED is directly connected to 5V, it is likely to draw several times more current than nominal.  Connecting  an LED directly to an Arduino digital line also will allow it to draw too much current.  Connecting 8 LEDs to a single processor IO line is likely to cause enough overheating to damage the processor permanently.  You may need to add 8 or 16 resistors to your circuit.
Anyhow, instead of trying to debug while using a 100 μs multiplexing delay in your program, and instead of turning on lots of lights at the same time, try turning on one at a time for a brief but visible period each, and see if the array of lights scans ok, via code like the following:
int rowPins[]    = {19, 18, 11, 7, 12, 5, 4, 16}; //assign row lines
int columnPins[] = {13, 17, 9, 10,  2, 8, 3,  6}; //assign col lines

void setup() {
  int i;
  for (i=0; i<8; ++i) {
    pinMode(rowPins[i], OUTPUT);
    digitalWrite(rowPins[i], HIGH);
    pinMode(columnPins[i], OUTPUT);
    digitalWrite(columnPins[i], LOW);
  }
}
void loop () {
  int x, y;
  for (y=0; y<8; ++y) {
    digitalWrite(rowPins[y], LOW);
    for (x=0; x<8; ++x)  {
      digitalWrite (columnPins[x], HIGH);
      delay(250);     // wait about .25 seconds
      digitalWrite(columnPins[x], LOW);
    }
    digitalWrite(rowPins[y], HIGH);
  }
}

If multiple lights are on there may be miswiring on your project board, or the chip might be damaged, or there may be some roundabout leakage path from columns to ground or from rows to Vcc.  If you make the delay longer or add a pushbutton to advance manually, you can check voltages on LEDs and wires, or measure currents in wires, and perhaps deduce what the path is.

Thanks for the inputs jwpat7. I really appreciate it. The image [][] array was set to 0s just to show how I set it up. However, I would have put 1's in the array if I wanted to run the LED board. So sorry for not showing those other arrays. I think you might be right in that the problem I'm having might be because of wiring on the board. I copied and ran your example code, however there's always two LEDs ON as it goes through the array. It should have just shown one LED at a time according to your code right? Otherwise, it must be the wiring.

Erebus, the intent was to have 1 light on at a time, but I noticed I didn't initialize the pins.  I've added two digitalWrite() statements in setup().  (All the pins would have been initialized anyway after the first pass thru loop() so it might not make any difference.)

You definitely need to add resistors. Since you need to power 8 leds with one pin you need to limit the current to each led to 5mA (40/8), or add a transistor to each row/column (depending on the type of matrix (common cathode/common anode))

Also, instead of having column lines sitting LOW when off and row lines sitting HIGH, I would tri-state lines not being used (ie would say digitalWrite(pin#,LOW); pinMode(pin#,INPUT); when done with a pin).  See eg forum.arduino.cc Reply #2 re “Tri-state logic on IO pins?”.


text:
Is it ok to share the same power rail for the arduino and a shield?
I have a two amp 5VDC power rail.  I have configured a motor shield to use external DC (by moving a jumper.)  Is it ok to share the rail between the arduino's 5V and Gnd pins, and the motor shield?

the Vin pin on the Arduino is the source to the internal voltage regulator. It needs about 7 volts in order to work. If you try to feed 5V into the Vin then the Arduino won't get a full 5V.
Motors draw a lot of current, and cause transients on the power line as they switch on and off. (They will cause transients even in a regulated supply, because it takes the regulator time to respond to the rapidly changing load of the motor.) If you're going to feed both your motor shield and the Arduino's 5V from the same power supply, you will need a reservoir capacitor between 5V and ground as close to the Arduino 5V input as possible. The reservoir capacitor will even out drops and spikes in power to the Arduino.
You'd be much better off feeding 7-9V into the Arduino's Vin. That way it's power is regulated separately.

Thank you.  How is it that the Arduino (Uno) wants 7-9VDC in, when it may be fed from 5VDC USB?  Also, what size capacitor would you suggest?

You have 2 ways to power the Arudino: Through Vin, which feeds the built-in voltage regulator, or by feeding REGULATED 5V directly into the 5V line. When you feed 5V directly into the 5V line, you bypass the built-in voltage regulator. A linear voltage regulator like the one in an Arduino requires a voltage somewhat above the target (5V) voltage that it then regulates DOWN to the target voltage.

When you run an Arduino off of USB, it feeds the regulated 5V from the USB connector directly into the 5V pin.

When you have high-current loads, you should really regulate the load separately from your logic, or at least isolate it with a capacitor. As for the value of capacitor, I'm not sure. I suggest you post your question to the EE Stack Exchange.

The 5VDC I am splitting between the Arduino board and the motor shield is regulated.  Is there anything wrong with giving it to the Arduino via the USB jack, then, to avoid the on-board regulator?

Sigh... A regulator can't totally eliminate fluctuations in the voltage when large loads like motors switch on and off. If you feed a shared 5V supply into both your motor shield and your Arduino's 5V line, the Arduino may malfunction or shut off when the motor switches on and the voltage droops. To repeat, you should either use separate supplies or put a reservoir capacitor very close to the 5V input to the Arduino.

I was going to vote you best answer until the 'sigh' remark.  Yes, the plan since your earlier comment has been to be to use a capacitor on the power rails.  Thanks.

Make sure your peak current load doesn't exceed the output of your power supply or your voltage will droop and reset/crash the Arduino even with a reservoir capacitor at the Arduino.

Yes, but I wouldn't try to do it through the 5V pin on the Arduino. Run a separate 18AWG or larger wire to bring power and ground to the shield.

What I mean is, I have a 5VDC wire and a ground, and those wires are going to two places: the arduino Vin and ground, and the shield external power.  So they are sharing a source.  The 5V pin on the Arduino I'm talking about is the Vin pin.

Then they're already on the same rail.

Yes, it works that way.  I wonder if it's ok though; for example is there the possibility of ground loops or other negative consequences?


text:
Lego / Meccano style blocks for 'serious' projects
What can be used like Lego or other construction sets, but is more serious and 'professional'?  E.g. what comes with gears and screws and things like that, but is geared to serious modelling or more permanent projects?

Here is what comes to mind (by no means exhaustive):
billed as "the Industrial erector set", 8020 is legitimately used in industry for that kind of purpose, and if I remember correctly, pretty expensive. It is the most "professional" thing I can think of.
OpenBeam styles itself as the the cheaper, "open sourced" 8020. I've frequently heard of it being used in 3d printers.
These are not as serious or professional, but might be worth mentioning:
MINDSi is pretty close to the mindstorms, but tries to be more rigid/durable. It's aimed at robotics.
Servo City's actobotics is an aluminum modular building system. It is also sold on sparkfun.
I have not used these enough to give good comparisons, but I hope one of these will be what you are looking for.


text:
What is the simplest way to "ask" the arduino which input pins are HIGH?
I am trying to build a 36-line cable tester, using the Digistump DigiX (99 i/o pins). Digital pins 0-35 are outputs, connected via the cable in question, to (in a perfect world) digital input pins 36-72. The plan is to have 36 neopixels (to conserve DigiX pins), one corresponding to each line in the cable. Currently they light up green for connection and red for no connection.
It's easy to check if output 0 goes to input 36, but there are more potential problems in a cable than no connection...
What if there is a short and output 0 goes to 36 and 42? It will still show up as correct when it tests 0 to 36... I somehow need to "ask" it what, if any, inputs (pins 36-72) are HIGH when only output 0 is HIGH.
I'm not sure how I'm going to display this extra data yet (Lcd maybe? Or maybe any pins shorted together all use a unique led color...), but I want to make sure the idea will work before I move on to that. Here is what I have working so far, just using a 3-line cable for now. And yes, I'm new to this. Any advice would be greatly appreciated!
#include <FastLED.h>
#define NUM_LEDS 3
#define LED_PIN 6
CRGB leds[NUM_LEDS];
#define brightness 25
int var = 0;

void setup() {
  for (int sendPins=0; sendPins <= 2; sendPins++) {
    pinMode(sendPins, OUTPUT); }

  for (int recPins=3; recPins <= 5; recPins++) {
    pinMode(recPins, INPUT); }

    FastLED.addLeds<NEOPIXEL, LED_PIN>(leds, NUM_LEDS);
    FastLED.clear();
}

void loop() {
  while (var < 3) {    //so it only runs once for each line in the cable.
    var++;
  for (int sendPins=0; sendPins < 3; sendPins++) {
    digitalWrite(sendPins, HIGH);

    int recPins = map(sendPins, 0, 2, 3, 5);  //made more sense to me than another for loop.

     int recPin = digitalRead(recPins);
     if (recPin == HIGH)
     {
      leds[sendPins].g = brightness;
      leds[sendPins].r = 0;
      FastLED.show();
     }
     else
     {
      leds[sendPins].r = brightness;
      leds[sendPins].g = 0;
      FastLED.show();
     }

      digitalWrite(sendPins, LOW);
      delay(250);      //just for testing so i know it's going through them all.
  }
 }
}

Low-level access to the ports, which will give you all input bits at once.

If you are testing for shorts, but sure to only set one pin to output at a time. If all pins 0-36 are outputs, and you set pin 0 to HIGH (and the rest to LOW). Then in you example a short between inputs 36 and 42 would mean there's also a short between outputs 0 and 6. Which would mean there is a dead-short between a HIGH and a LOW output, resulting the AVR browning out and maybe even damaging the output pins.

There is a technique, which I used some 40 years ago to test for changes on a set of input pins. This can easily be configured to test serially.
Put a 1 on an output pin say 5. Create an integer e.g. 010000 with a 1 in the appropriate position. Read ALL inputs and XOR with the created integer. If one and only one input is 1 the resultant value will be 0. This is easy to implement in a loop just by shifting the 1 left each time.
The technique works if you can read all inputs into a integer. This was OK for our 32 bits, but could be extended.
It is probably easier to code than explain, but depends on what you have to do to read all inputs.

I believe you can read the port register that contains the current state for your pin. The port names take the form of "PORTA" - "PORTE". (The number of port registers varies with the processor in your arduino, and the pin to port mappings are also different across processor models, so this approach will tie you to Arduino models that use the same processor chip)
Another approach would be to store the state you write to each pin to a boolean variable and just read that. Create a central method that takes a pin number and a new state. That method would save the new value to an array, indexed using the pin number, and then also set the pin. You could then write a method that would read the current pin value from the same array .

Use nested loops.  Test each pin one by one.  For each one pin test, look for the correct wire to be on and check all the others and either look for an "on" or count how many bad on's there are.
HTH.


text:
Can I use custom ethernet shield with standard libraries?
I would like to make a custom ethernet card that uses the enc28j60 like this:
DIY Ethernet card
but first I would like to know if I can use the standard libraries which can be used with the ethernet card which is in the market like this:
ENC28J60 ethernet module

The libraries don't care whether or not you're using a shield, only that you're using a device they support and that you've wired it up how they expect (or that you've modified the library to use the actual wiring you're using). So find a library that supports the ENC28J60 and knock yourself out.


text:
Is crystal mandatory on attiny84?
I am trying to make a mini project with attiny84 and I searched the web so I can make an arduino on breadboard. What I saw on the internet is that they didnt use crystal. Is it mandatory if I want to use 1 pwm pin and the SPI interface on the attiny84?

Only if you need crystal accuracy. If the internal RC oscillator is accurate enough then feel free to use it instead.

Is there any way that i should anable the internal oscillator from the arduino IDE?

The Arduino IDE has no way to manipulate the fuses without using a programmer. And even with one, you can only modify them to the values set in boards.txt.

Just to add. The internal oscillator runs at 8mHz, while most arduino boards have a 16mHz crystal. So you lose half the processing speed. In most cases this is not a big deal. On the plus side, it reduces the power usage a bit, and you can use those 2 crystal pins for something else.