Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 84

The process of designing and writing source code as part of a program (or sketch) for Arduino. For questions about uploading code to an Arduino board, use the [uploading] tag instead.

0 votes

Code for one-time execution in Arduino

As most other answers, I would go for method 2. But I would try to avoid the call, by Arduino library, to an an empty loop() that makes the Atmel consume "a lot" of current for nothing. Edit: As so …
jfpoilpret's user avatar
  • 9,142
0 votes

IR controlled light dimmer

One important problem in your code is concurrent access to dimming variable. That may not be the only problem you have though. Indeed, deeming is accessed for writing in your loop(), but it can be sim …
jfpoilpret's user avatar
  • 9,142
2 votes
Accepted

Default value of global variables is not set

This variable is declared volatile which is generally meaning that it can be modified by an Interrupt Service Routine (ISR). So it is perfectly possible that this ISR gets called before your setup() …
jfpoilpret's user avatar
  • 9,142
3 votes
Accepted

Allocate object memory statically; intialize it dynamically?

Using an initialize() method to a class is contrary to the principle of a class constructor, i.e. once a class instance has been constructed, it should be "ready to use". As suggested by Ignacio's an …
jfpoilpret's user avatar
  • 9,142
1 vote

Measure square wave frequency

It seems you have a problem of concurrent access to duration and pulsecount variables which are inter-related; with your code, it is possible that (and I guarantee that it will): loop() reads durati …
jfpoilpret's user avatar
  • 9,142
3 votes
Accepted

4-digit 7 Segment LED displaying numbers in the wrong order

Here is a datasheet I found that seems a better macth for your display model (that's the datasheet for a display that I use): http://www.play-zone.ch/en/fileuploader/download/download/?d=1&file=custo …
jfpoilpret's user avatar
  • 9,142
1 vote

Convert long to char array and back

I think the last expression is performed exclusively as an int expression and converted to long only at the end, i.e. before assignment to l. long l = buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf …
jfpoilpret's user avatar
  • 9,142
1 vote

I need to build a char array from two integers

Another option in your situation is to not use String at all (which is preferrable for reasons I won't explain here) and exclusively use plain old C strings and their associated functions: // Define …
jfpoilpret's user avatar
  • 9,142
15 votes
Accepted

How much can I recurse? How much can I recurse? How much ca!@#QFSD@$RFW

If you really want to recurse (and as @jippie said it is a bad idea; subliminal message: don't do it) and want to know how much you can recurse, then you will have to perform some calculation and exp …
jfpoilpret's user avatar
  • 9,142
2 votes
Accepted

Timer1 stops firing

The problem you have is that you never reset Timer1 counter (TCNT1) when you stop a note and then play another one. Also, changing the clock divider selection to "no clock" by clearing bits CS10 and …
jfpoilpret's user avatar
  • 9,142
1 vote

Modbus master slave

In Modbus protocol, coils are bits and registers are 16-bit unsigned integers. Hence if you ask Modbus to read your au16data array as coils, and not as registers (which is what they actually are), th …
jfpoilpret's user avatar
  • 9,142
2 votes
Accepted

Program got so many errors about expected ) or ; before either

In C and in C++, #define is not an instruction of the language, but a directive of the pre-processor. What it does is define a "macro" which will be replaced everywhere it appears later on in the sou …
jfpoilpret's user avatar
  • 9,142
0 votes
Accepted

Debugging library - Error- expected unqualified id before '.' token

From what I guess in your code, here is how you want your class declared: class Habitaculo { public: Habitaculo(int refrate, int luzpin, int dhtpin); //Values from Indoor Sensors int …
jfpoilpret's user avatar
  • 9,142
3 votes

Why can't my .cpp file have a class of the same name?

#define XYZ class XYZ { }; The first line tells the "C preprocessor" (called before C and C++ compilers) to replace XYZ with nothing everywhere it happens, hence after preprocessing, and before com …
jfpoilpret's user avatar
  • 9,142
5 votes
Accepted

Led on when not supposed to be

The behavior you describe is symptomatic of a floating input. I guess you have directly wired your buttons between input pins and +5V (or GND, that won't change the observed behavior). The problem i …
jfpoilpret's user avatar
  • 9,142

15 30 50 per page